]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tipc: Fix missing list initializations in struct tipc_subscription
authorJon Maloy <jon.maloy@ericsson.com>
Tue, 3 Apr 2018 17:11:19 +0000 (19:11 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 Apr 2018 15:33:52 +0000 (11:33 -0400)
When an item of struct tipc_subscription is created, we fail to
initialize the two lists aggregated into the struct. This has so far
never been a problem, since the items are just added to a root
object by list_add(), which does not require the addee list to be
pre-initialized. However, syzbot is provoking situations where this
addition fails, whereupon the attempted removal if the item from
the list causes a crash.

This problem seems to always have been around, despite that the code
for creating this object was rewritten in commit b7de76e2dd7d ("tipc:
collapse subscription creation functions"), which is still in net-next.

We fix this for that commit by initializing the two lists properly.

Fixes: b7de76e2dd7d ("tipc: collapse subscription creation functions")
Reported-by: syzbot+0bb443b74ce09197e970@syzkaller.appspotmail.com
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/subscr.c

index 6925a989569bd61a5333c8ce7fe7df45466af464..b7d80bc5f4abcb6dad2df7f6a5489b6b048f27dc 100644 (file)
@@ -145,6 +145,8 @@ struct tipc_subscription *tipc_sub_subscribe(struct net *net,
                pr_warn("Subscription rejected, no memory\n");
                return NULL;
        }
+       INIT_LIST_HEAD(&sub->service_list);
+       INIT_LIST_HEAD(&sub->sub_list);
        sub->net = net;
        sub->conid = conid;
        sub->inactive = false;