Skip to contentSkip to conversation

tipc: Fix missing list initializations in struct tipc_subscription

PATCH Applied Jon Maloy 2 participants 2 messages Apr 3, 2018 – Apr 4, 2018

Subsystems (3)
lore
Share & tools
lore

Jon Maloy

author
#0 lore raw

PATCH 1/1 tipc: Fix missing list initializations in struct tipc_subscription

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 242e82cc95f6 ("tipc:
collapse subscription creation functions"), which is still in net-next.

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

Fixes 242e82cc95f6 ("tipc: collapse subscription creation functions")
Reported-by [email protected]
---
 net/tipc/subscr.c | 2 ++
 1 file changed, 2 insertions(+)
net/tipc/subscr.c +2 -0
index 6925a98..b7d80bc 100644
@@ -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;
Signature · 1 line
2.1.4
maintainer Applied
#1 lore raw

From: Jon Maloy <[email protected]>
Date: Tue, 3 Apr 2018 19:11:19 +0200

Quoted 12 lines

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 242e82cc95f6 ("tipc:
collapse subscription creation functions"), which is still in net-next.

Quoted 5 lines

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

Fixes 242e82cc95f6 ("tipc: collapse subscription creation functions")
Reported-by [email protected]

Applied, thanks Jon.