net: rose: fix invalid array index in rose_kill_by_device()
Subsystems (2)
PATCH 1/1 net: rose: fix invalid array index in rose_kill_by_device()
From: Pwnverse <[email protected]>
rose_kill_by_device() collects sockets into a local array[] and then iterates over them to disconnect sockets bound to a device being brought down.
The loop mistakenly indexes array[cnt] instead of array[i]. For cnt < ARRAY_SIZE(array), this reads an uninitialized entry; for cnt == ARRAY_SIZE(array), it is an out-of-bounds read. Either case can lead to an invalid socket pointer dereference and also leaks references taken via sock_hold().
Fix the index to use i.
--- net/rose/af_rose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rose/af_rose.c +1 -1
@@ -205,7 +205,7 @@ static void rose_kill_by_device(struct net_device *dev)spin_unlock_bh (&rose_list_lock);for (i =0 ; i < cnt; i++) { - sk = array[cnt]; + sk = array[i]; rose =rose_sk (sk);lock_sock (sk);spin_lock_bh (&rose_list_lock);
Signature · 1 line
2.43.0
Hello,
Apologies for another ping. I forgot to attach the POC (results in crash under CAP_NET_ADMIN).
Warm Regards,
Ritvik Tanksalkar
Quoted 39 lines · Sai Ritvik Tanksalkar
From: Pwnverse <[email protected]>
rose_kill_by_device()collects sockets into a local array[] and then iterates over them to disconnect sockets bound to a device being brought down.The loop mistakenly indexes array[cnt] instead of array[i]. For cnt <
ARRAY_SIZE(array), this reads an uninitialized entry; for cnt ==ARRAY_SIZE(array), it is an out-of-bounds read. Either case can lead to an invalid socket pointer dereference and also leaks references taken viasock_hold().Fix the index to use i.
Fixes 64b8bc7d5f143 ("net/rose: fix races in rose_kill_by_device()")Co-developed-by Fatma Alwasmi <[email protected]>Signed-off-by Fatma Alwasmi <[email protected]>Signed-off-by Pwnverse <[email protected]>--- net/rose/af_rose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/rose/af_rose.c +1
-2@@ -205,7 +205,7 @@ static void rose_kill_by_device(struct net_device *dev)spin_unlock_bh (&rose_list_lock);for (i =0 ; i < cnt; i++) { - sk = array[cnt]; + sk = array[i]; rose =rose_sk (sk);lock_sock (sk);spin_lock_bh (&rose_list_lock); --2.43.0
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 6 lines · On Mon, 22 Dec 2025 21:22:27 +0000 you wrote:
From: Pwnverse <[email protected]>
rose_kill_by_device()collects sockets into a local array[] and then iterates over them to disconnect sockets bound to a device being brought down.
Quoted 7 lines
The loop mistakenly indexes array[cnt] instead of array[i]. For cnt <
ARRAY_SIZE(array), this reads an uninitialized entry; for cnt ==ARRAY_SIZE(array), it is an out-of-bounds read. Either case can lead to an invalid socket pointer dereference and also leaks references taken viasock_hold().[...]
Here is the summary with links:
- [net] net: rose: fix invalid array index in rose_kill_by_device()
https://git.kernel.org/netdev/net/c/6595beb40fb0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html