Skip to contentSkip to conversation

net: rose: fix invalid array index in rose_kill_by_device()

PATCH Applied Sai Ritvik Tanksalkar 2 participants 3 messages Dec 22, 2025 – Dec 30, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 64b8bc7d5f143 ("net/rose: fix races in rose_kill_by_device()")
---
 net/rose/af_rose.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/rose/af_rose.c +1 -1
index fd67494f2815..c0f5a515a8ce 100644
@@ -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
#1 lore raw

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 via sock_hold().

Fix the index to use i.

Fixes 64b8bc7d5f143 ("net/rose: fix races in rose_kill_by_device()")
---
 net/rose/af_rose.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/rose/af_rose.c +1 -2
index fd67494f2815..c0f5a515a8ce 100644
@@ -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

#2 lore raw
In reply to Sai Ritvik Tanksalkar
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 via sock_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