Commit 69e16d0
net: fix a concurrency bug in l2tp_tunnel_register()
l2tp_tunnel_register() registers a tunnel without fully
initializing its attribute. This can allow another kernel thread
running l2tp_xmit_core() to access the uninitialized data and
then cause a kernel NULL pointer dereference error, as shown below.
Thread 1 Thread 2
//l2tp_tunnel_register()
list_add_rcu(&tunnel->list, &pn->l2tp_tunnel_list);
//pppol2tp_connect()
tunnel = l2tp_tunnel_get(sock_net(sk), info.tunnel_id);
// Fetch the new tunnel
...
//l2tp_xmit_core()
struct sock *sk = tunnel->sock;
...
bh_lock_sock(sk);
//Null pointer error happens
tunnel->sock = sk;
Fix this bug by initializing tunnel->sock before adding the
tunnel into l2tp_tunnel_list.
Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Sishuai Gong <sishuai@purdue.edu>
Reported-by: Sishuai Gong <sishuai@purdue.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent 6fd6c48 commit 69e16d0
1 file changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1478 | 1478 | | |
1479 | 1479 | | |
1480 | 1480 | | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
1481 | 1485 | | |
1482 | 1486 | | |
1483 | 1487 | | |
1484 | 1488 | | |
1485 | | - | |
| 1489 | + | |
1486 | 1490 | | |
1487 | 1491 | | |
1488 | 1492 | | |
1489 | 1493 | | |
1490 | 1494 | | |
1491 | 1495 | | |
1492 | 1496 | | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | 1497 | | |
1498 | 1498 | | |
1499 | 1499 | | |
| |||
0 commit comments