* [PATCH] selinux: fix potential use-after-free in sel_netif_flush() @ 2026-11-09 16:59 mdshahid03 2026-11-09 17:03 ` sashiko-bot 2026-11-09 17:58 ` Stephen Smalley 0 siblings, 2 replies; 3+ messages in thread From: mdshahid03 @ 2026-11-09 16:59 UTC (permalink / raw) To: Paul Moore, Stephen Smalley Cc: Ondrej Mosnáček, selinux, linux-kernel, Mohammad Shahid From: Mohammad Shahid <mdshahid03@gmail.com> sel_netif_flush() use list_for_each_entry() while deleting entries from the network interface list. Use list_for_each_entry_safe() to save the next entry before deleting the current one and avoid accessing freed memory. The issue is reported by smatch as potential use-after-free. Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com> --- security/selinux/netif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/selinux/netif.c b/security/selinux/netif.c index fa6d24a37c39..d5e258fd52aa 100644 --- a/security/selinux/netif.c +++ b/security/selinux/netif.c @@ -242,11 +242,11 @@ static void sel_netif_kill(const struct net *ns, int ifindex) void sel_netif_flush(void) { int idx; - struct sel_netif *netif; + struct sel_netif *netif, *tmp; spin_lock_bh(&sel_netif_lock); for (idx = 0; idx < SEL_NETIF_HASH_SIZE; idx++) - list_for_each_entry(netif, &sel_netif_hash[idx], list) + list_for_each_entry_safe(netif, tmp, &sel_netif_hash[idx], list) sel_netif_destroy(netif); spin_unlock_bh(&sel_netif_lock); } -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selinux: fix potential use-after-free in sel_netif_flush() 2026-11-09 16:59 [PATCH] selinux: fix potential use-after-free in sel_netif_flush() mdshahid03 @ 2026-11-09 17:03 ` sashiko-bot 2026-11-09 17:58 ` Stephen Smalley 1 sibling, 0 replies; 3+ messages in thread From: sashiko-bot @ 2026-11-09 17:03 UTC (permalink / raw) Cc: selinux > From: Mohammad Shahid <mdshahid03@gmail.com> > > sel_netif_flush() use list_for_each_entry() while deleting > entries from the network interface list. > > Use list_for_each_entry_safe() to save the next entry before > deleting the current one and avoid accessing freed memory. > > The issue is reported by smatch as potential use-after-free. > > Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com> Sashiko has reviewed this patch and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261109165939.138448-1-mdshahid03@gmail.com?part=1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selinux: fix potential use-after-free in sel_netif_flush() 2026-11-09 16:59 [PATCH] selinux: fix potential use-after-free in sel_netif_flush() mdshahid03 2026-11-09 17:03 ` sashiko-bot @ 2026-11-09 17:58 ` Stephen Smalley 1 sibling, 0 replies; 3+ messages in thread From: Stephen Smalley @ 2026-11-09 17:58 UTC (permalink / raw) To: mdshahid03; +Cc: Paul Moore, Ondrej Mosnáček, selinux, linux-kernel On Mon, Nov 9, 2026 at 12:00 PM <mdshahid03@gmail.com> wrote: > > From: Mohammad Shahid <mdshahid03@gmail.com> > > sel_netif_flush() use list_for_each_entry() while deleting > entries from the network interface list. > > Use list_for_each_entry_safe() to save the next entry before > deleting the current one and avoid accessing freed memory. > > The issue is reported by smatch as potential use-after-free. > > Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com> This isn't actually necessary AFAICT - sel_netif_destroy() preserves the forward link with list_del_rcu() and defers reclamation with kfree_rcu(). The loop holds spin_lock_bh() throughout, so the current entry remains alive through the iterator increment. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-09 17:59 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-09 16:59 [PATCH] selinux: fix potential use-after-free in sel_netif_flush() mdshahid03 2026-11-09 17:03 ` sashiko-bot 2026-11-09 17:58 ` Stephen Smalley
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.