mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selinux: fix NULL pointer dereference in selinux_sctp_bind_connect()
@ 2026-06-18 23:21 Tristan Madani
  2026-06-22 14:12 ` Stephen Smalley
  2026-06-22 21:03 ` [PATCH v2] selinux: avoid sk_socket " Tristan Madani
  0 siblings, 2 replies; 7+ messages in thread
From: Tristan Madani @ 2026-06-18 23:21 UTC (permalink / raw)
  To: Paul Moore, Stephen Smalley
  Cc: Ondrej Mosnacek, Richard Haines, selinux, stable, linux-kernel,
	Tristan Madani

From: Tristan Madani <tristan@talencesecurity.com>

selinux_sctp_bind_connect() reads sk->sk_socket and passes it to
selinux_socket_bind() or selinux_socket_connect_helper() without
checking for NULL.  When an SCTP ASCONF chunk is processed in softirq
context on a socket that has been concurrently closed, sock_orphan()
will have already set sk->sk_socket to NULL.  The subsequent
dereference of sock->sk at offset 0x18 triggers a kernel panic.

Add a NULL check on sk->sk_socket before use.

Fixes: d452930fd3b9 ("selinux: Add SCTP support")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
 security/selinux/hooks.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 0f704380a8c8..e45588563caa 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -5717,6 +5717,9 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
 
 	/* Process one or more addresses that may be IPv4 or IPv6 */
 	sock = sk->sk_socket;
+	if (!sock)
+		return -ECONNRESET;
+
 	addr_buf = address;
 
 	while (walk_size < addrlen) {
-- 
2.47.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-06-23 12:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-18 23:21 [PATCH] selinux: fix NULL pointer dereference in selinux_sctp_bind_connect() Tristan Madani
2026-06-22 14:12 ` Stephen Smalley
2026-06-22 18:59   ` Tristan Madani
2026-06-22 19:15     ` Stephen Smalley
2026-06-22 19:38       ` Stephen Smalley
2026-06-22 21:03 ` [PATCH v2] selinux: avoid sk_socket " Tristan Madani
2026-06-23 12:21   ` Stephen Smalley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox