Skip to contentSkip to conversation

net: phonet: free phonet_device after RCU grace period

PATCH Applied Santosh Kalluri 3 participants 3 messages Jun 4 – Jun 9

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

PATCH 1/1 net: phonet: free phonet_device after RCU grace period

phonet_device_destroy() removes a phonet_device from the per-net device list with list_del_rcu(), but frees it immediately. RCU readers walking the same list can still hold a pointer to the object after it has been removed, leading to a slab-use-after-free.

Use kfree_rcu(), matching the lifetime rule already used by phonet_address_del() for the same object type.

Fixes eeb74a9d45f7 ("Phonet: convert devices list to RCU")
---
 net/phonet/pn_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/phonet/pn_dev.c +1 -1
index 86325b7fc1b6..ad44831d6745 100644
@@ -108,7 +108,7 @@ static void phonet_device_destroy(struct net_device *dev)
 		for_each_set_bit(addr, pnd->addrs, 64)
 			phonet_address_notify(net, RTM_DELADDR, ifindex, addr);
 
-		kfree(pnd);
+		kfree_rcu(pnd, rcu);
 	}
 }
 

base-commit: f723ccaff2fb72b71ae8a9fd283f0dee4d9ae7a3

Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Santosh Kalluri

phonet_device_destroy() removes a phonet_device from the per-net device list with list_del_rcu(), but frees it immediately. RCU readers walking the same list can still hold a pointer to the object after it has been removed, leading to a slab-use-after-free.

Quoted 7 lines

Use kfree_rcu(), matching the lifetime rule already used by phonet_address_del() for the same object type.

Fixes eeb74a9d45f7 ("Phonet: convert devices list to RCU")
#2 lore raw
In reply to Santosh Kalluri
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 9 lines · On Wed, 3 Jun 2026 17:08:43 -0700 you wrote:

phonet_device_destroy() removes a phonet_device from the per-net device list with list_del_rcu(), but frees it immediately. RCU readers walking the same list can still hold a pointer to the object after it has been removed, leading to a slab-use-after-free.

Use kfree_rcu(), matching the lifetime rule already used by phonet_address_del() for the same object type.

[...]

Here is the summary with links:
- [net] net: phonet: free phonet_device after RCU grace period

    https://git.kernel.org/netdev/net/c/71de0177b28d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html