From: mdshahid03@gmail.com
To: Paul Moore <paul@paul-moore.com>,
Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: "Ondrej Mosnáček" <omosnacek@gmail.com>,
selinux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Mohammad Shahid" <mdshahid03@gmail.com>
Subject: [PATCH] selinux: fix potential use-after-free in sel_netif_flush()
Date: Mon, 9 Nov 2026 22:29:39 +0530 [thread overview]
Message-ID: <20261109165939.138448-1-mdshahid03@gmail.com> (raw)
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
next reply other threads:[~2026-11-09 17:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 16:59 mdshahid03 [this message]
2026-11-09 17:58 ` Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261109165939.138448-1-mdshahid03@gmail.com \
--to=mdshahid03@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnacek@gmail.com \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®