Re: [tipc-discussion] [net] tipc: fix NULL pointer dereference in tipc_disc_rcv()

2020-06-11 Thread David Miller
From: Tuong Lien 
Date: Thu, 11 Jun 2020 17:08:08 +0700

> 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 
> Signed-off-by: Tuong Lien 

Applied, thanks.


___
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion


[tipc-discussion] [net] tipc: fix NULL pointer dereference in tipc_disc_rcv()

2020-06-11 Thread Tuong Lien
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 
Signed-off-by: Tuong Lien 
---
 net/tipc/bearer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 34ca7b789eba..e366ec9a7e4d 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -316,7 +316,6 @@ static int tipc_enable_bearer(struct net *net, const char 
*name,
b->domain = disc_domain;
b->net_plane = bearer_id + 'A';
b->priority = prio;
-   test_and_set_bit_lock(0, >up);
refcount_set(>refcnt, 1);
 
res = tipc_disc_create(net, b, >bcast_addr, );
@@ -326,6 +325,7 @@ static int tipc_enable_bearer(struct net *net, const char 
*name,
goto rejected;
}
 
+   test_and_set_bit_lock(0, >up);
rcu_assign_pointer(tn->bearer_list[bearer_id], b);
if (skb)
tipc_bearer_xmit_skb(net, bearer_id, skb, >bcast_addr);
-- 
2.13.7



___
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion


[tipc-discussion] [net] tipc: fix NULL pointer dereference in tipc_disc_rcv()

2020-06-05 Thread Tuong Lien
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.

Signed-off-by: Tuong Lien 
---
 net/tipc/bearer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 34ca7b789eba..e366ec9a7e4d 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -316,7 +316,6 @@ static int tipc_enable_bearer(struct net *net, const char 
*name,
b->domain = disc_domain;
b->net_plane = bearer_id + 'A';
b->priority = prio;
-   test_and_set_bit_lock(0, >up);
refcount_set(>refcnt, 1);
 
res = tipc_disc_create(net, b, >bcast_addr, );
@@ -326,6 +325,7 @@ static int tipc_enable_bearer(struct net *net, const char 
*name,
goto rejected;
}
 
+   test_and_set_bit_lock(0, >up);
rcu_assign_pointer(tn->bearer_list[bearer_id], b);
if (skb)
tipc_bearer_xmit_skb(net, bearer_id, skb, >bcast_addr);
-- 
2.13.7



___
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion