net: rose: lock the socket in rose_bind()
Subsystems (2)
PATCH 1/1 net: rose: lock the socket in rose_bind()
syzbot reported a soft lockup in rose_loopback_timer(), with a repro calling bind() from multiple threads.
rose_bind() must lock the socket to avoid this issue.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by [email protected]
Signed-off-by Eric Dumazet <[email protected]>
--- net/rose/af_rose.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
net/rose/af_rose.c +16 -8
@@ -701,11 +701,9 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)struct net_device *dev;ax25_address *source;ax25_uid_assoc *user; +int err = -EINVAL ;int n; -if (!sock_flag (sk,SOCK_ZAPPED )) -return -EINVAL ; -if (addr_len !=sizeof (struct sockaddr_rose ) && addr_len !=sizeof (struct full_sockaddr_rose ))return -EINVAL ;
@@ -718,8 +716,15 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)if ((unsigned int ) addr->srose_ndigis >ROSE_MAX_DIGIS )return -EINVAL ; -if ((dev =rose_dev_get (&addr->srose_addr)) ==NULL ) -return -EADDRNOTAVAIL ; +lock_sock (sk); + +if (!sock_flag (sk,SOCK_ZAPPED )) + goto out_release; + + err = -EADDRNOTAVAIL ; + dev =rose_dev_get (&addr->srose_addr); +if (!dev) + goto out_release; source = &addr->srose_call;
@@ -730,7 +735,8 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) }else {if (ax25_uid_policy && !capable (CAP_NET_BIND_SERVICE )) {dev_put (dev); -return -EACCES ; + err = -EACCES ; + goto out_release; } rose->source_call = *source; }
@@ -753,8 +759,10 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)rose_insert_socket (sk);sock_reset_flag (sk,SOCK_ZAPPED ); - -return 0 ; + err =0 ; +out_release: +release_sock (sk); +return err; }static int rose_connect (struct socket *sock,struct sockaddr *uaddr,int addr_len,int flags)
Signature · 1 line
2.48.1.362.g079036d154-goog
Quoted 9 lines · Eric Dumazet
syzbot reported a soft lockup in
rose_loopback_timer(), with a repro callingbind()from multiple threads.
rose_bind()must lock the socket to avoid this issue.Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-by [email protected]Signed-off-by Eric Dumazet <[email protected]>
Acked-by Paolo Abeni <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Mon, 3 Feb 2025 17:08:38 +0000 you wrote:
syzbot reported a soft lockup in
rose_loopback_timer(), with a repro callingbind()from multiple threads.
rose_bind()must lock the socket to avoid this issue.Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-by [email protected]Signed-off-by Eric Dumazet <[email protected]>[...]
Here is the summary with links:
- [net] net: rose: lock the socket in rose_bind()
https://git.kernel.org/netdev/net/c/a1300691aed9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html