Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
l2tp: close all race conditions in l2tp_tunnel_register()
The code in l2tp_tunnel_register() is racy in several ways: 1. It modifies the tunnel socket _after_ publishing it. 2. It calls setup_udp_tunnel_sock() on an existing socket without locking. 3. It changes sock lock class on fly, which triggers many syzbot reports. This patch amends all of them by moving socket initialization code before publishing and under sock lock. As suggested by Jakub, the l2tp lockdep class is not necessary as we can just switch to bh_lock_sock_nested(). Fixes: 37159ef ("l2tp: fix a lockdep splat") Fixes: 6b9f342 ("l2tp: fix races in tunnel creation") Reported-by: [email protected] Reported-by: [email protected] Reported-by: Tetsuo Handa <[email protected]> Cc: Guillaume Nault <[email protected]> Cc: Jakub Sitnicki <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Tom Parkin <[email protected]> Signed-off-by: Cong Wang <[email protected]> Reviewed-by: Guillaume Nault <[email protected]> Signed-off-by: David S. Miller <[email protected]>
- Loading branch information