]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phonet: free phonet_device after RCU grace period
authorSantosh Kalluri <santosh.kalluri129@gmail.com>
Thu, 4 Jun 2026 00:08:43 +0000 (17:08 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 9 Jun 2026 00:37:07 +0000 (17:37 -0700)
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")
Cc: stable@vger.kernel.org
Signed-off-by: Santosh Kalluri <santosh.kalluri129@gmail.com>
Acked-by: Rémi Denis-Courmont <remi@remlab.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/phonet/pn_dev.c

index 86325b7fc1b6f1101fcf0e324f63ed0a4488e4da..ad44831d674527879319476469173ef69ffb8e7d 100644 (file)
@@ -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);
        }
 }