From: Paul Moore <paul@paul-moore.com>
To: Tristan Madani <tristmd@gmail.com>,
Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: Ondrej Mosnacek <omosnace@redhat.com>,
Richard Haines <richard_c_haines@btinternet.com>,
selinux@vger.kernel.org, stable@vger.kernel.org,
linux-kernel@vger.kernel.org, tristan@talencesecurity.com
Subject: Re: [PATCH v3] selinux: avoid sk_socket dereference in selinux_sctp_bind_connect()
Date: Wed, 01 Jul 2026 18:22:20 -0400 [thread overview]
Message-ID: <0fa8e2f769f889368756a1ed1f12ea8e@paul-moore.com> (raw)
In-Reply-To: <20260625235336.3641828-1-tristmd@gmail.com>
On Jun 25, 2026 Tristan Madani <tristmd@gmail.com> wrote:
>
> selinux_sctp_bind_connect() dereferences sk->sk_socket to pass a
> struct socket * to selinux_socket_bind() and
> selinux_socket_connect_helper(). However, when the hook is invoked
> from the ASCONF softirq path (sctp_process_asconf), there is no file
> reference guaranteeing that sk->sk_socket is non-NULL. The setsockopt
> callers (bindx, connectx, set_primary, sendmsg connect) hold a file
> reference and are not affected.
>
> Both selinux_socket_bind() and selinux_socket_connect_helper()
> immediately resolve sock->sk, never using the struct socket * for
> anything else. Refactor the inner logic into helpers that take a
> struct sock * directly so that selinux_sctp_bind_connect() never needs
> to touch sk->sk_socket at all.
>
> Suggested-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> Fixes: d452930fd3b9 ("selinux: Add SCTP support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> Tested-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> ---
> Changes in v3:
> - Keep comment describing IPv4/IPv6 address processing loop
> (Stephen Smalley).
>
> Changes in v2:
> - Refactor selinux_socket_bind() and selinux_socket_connect_helper()
> into sk-based inner helpers instead of adding a NULL check on
> sk->sk_socket (Stephen Smalley).
>
> security/selinux/hooks.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
Thanks, this looks good to me, I'm going to merge it into
selinux/stable-7.2 now.
However, there is another issue relating to the SCTP softirq code paths:
the fact that we call into sock_has_perm() in both
__selinux_socket_bind() and selinux_socket_connect_helper(). The
sock_has_perm() function uses current_sid() as the subject in the
avc_has_perm() call, and in the softirq case that is not what we want.
It's been few years since I spent any serious time with SCTP so it isn't
immediately clear to me what the solution is to this problem, but if you
wanted to look into this and come up with some ideas that would be a big
help!
--
paul-moore.com
next prev parent reply other threads:[~2026-07-01 22:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 23:53 Tristan Madani
2026-06-26 12:33 ` Stephen Smalley
2026-07-01 22:22 ` Paul Moore [this message]
2026-07-02 1:10 ` Tristan Madani
2026-07-06 19:14 ` 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=0fa8e2f769f889368756a1ed1f12ea8e@paul-moore.com \
--to=paul@paul-moore.com \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=richard_c_haines@btinternet.com \
--cc=selinux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
--cc=tristan@talencesecurity.com \
--cc=tristmd@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
Powered by JetHome