Skip to content

Commit 9798278

Browse files
Tuong Liendavem330
authored andcommitted
tipc: fix NULL pointer dereference in tipc_disc_rcv()
When a bearer is enabled, we create a 'tipc_discoverer' object to store the bearer related data along with a timer and a preformatted discovery message buffer for later probing... However, this is only carried after the bearer was set 'up', that left a race condition resulting in kernel panic. It occurs when a discovery message from a peer node is received and processed in bottom half (since the bearer is 'up' already) just before the discoverer object is created but is now accessed in order to update the preformatted buffer (with a new trial address, ...) so leads to the NULL pointer dereference. We solve the problem by simply moving the bearer 'up' setting to later, so make sure everything is ready prior to any message receiving. Acked-by: Jon Maloy <[email protected]> Signed-off-by: Tuong Lien <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c9aa81f commit 9798278

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/tipc/bearer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ static int tipc_enable_bearer(struct net *net, const char *name,
316316
b->domain = disc_domain;
317317
b->net_plane = bearer_id + 'A';
318318
b->priority = prio;
319-
test_and_set_bit_lock(0, &b->up);
320319
refcount_set(&b->refcnt, 1);
321320

322321
res = tipc_disc_create(net, b, &b->bcast_addr, &skb);
@@ -326,6 +325,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
326325
goto rejected;
327326
}
328327

328+
test_and_set_bit_lock(0, &b->up);
329329
rcu_assign_pointer(tn->bearer_list[bearer_id], b);
330330
if (skb)
331331
tipc_bearer_xmit_skb(net, bearer_id, skb, &b->bcast_addr);

0 commit comments

Comments
 (0)