All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tristan Madani <tristmd@gmail.com>
To: Paul Moore <paul@paul-moore.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:10:35 -0700 (PDT)	[thread overview]
Message-ID: <6a45ba8b.940a5a52.377c47.efec@mx.google.com> (raw)
In-Reply-To: <0fa8e2f769f889368756a1ed1f12ea8e@paul-moore.com>

On Wed, 01 Jul 2026, Paul Moore wrote:
> 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.

Had a look at this. The ASCONF softirq path is:

  sctp_rcv()  [NET_RX softirq]
    -> sctp_process_asconf()
      -> sctp_process_asconf_param()
        -> security_sctp_bind_connect(sk, SCTP_PARAM_ADD_IP/SET_PRIMARY)
          -> selinux_sctp_bind_connect()
            -> sock_has_perm()
              -> avc_has_perm(current_sid(), sksec->sid, ...)

In softirq, current is whatever process was interrupted, so the subject
SID is effectively random. Meanwhile the port/node bind checks further
down in __selinux_socket_bind() and the port connect check in
selinux_socket_connect_helper() already use sksec->sid as the subject,
which is the established pattern for softirq context
(selinux_socket_sock_rcv_skb, selinux_sctp_assoc_request, etc.).

The approach I would suggest: thread an explicit subject SID into the inner
helpers. selinux_sctp_bind_connect() would pass sksec->sid, and the
process-context wrappers (selinux_socket_bind, selinux_socket_connect)
would pass current_sid(). That keeps sock_has_perm() semantics
unchanged for the normal path and makes the SID choice visible at each
call site.

I can send a patch for this if this approach works for you.

--
Tristan

  reply	other threads:[~2026-07-02  1:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 23:53 [PATCH v3] selinux: avoid sk_socket dereference in selinux_sctp_bind_connect() Tristan Madani
2026-06-25 23:58 ` sashiko-bot
2026-06-26 12:33 ` Stephen Smalley
2026-07-01 22:22 ` Paul Moore
2026-07-02  1:10   ` Tristan Madani [this message]
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=6a45ba8b.940a5a52.377c47.efec@mx.google.com \
    --to=tristmd@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.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 \
    /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 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.