From: Paul Moore <paul@paul-moore.com>
To: Carlos Llamas <cmllamas@google.com>,
Stephen Smalley <stephen.smalley.work@gmail.com>,
Ondrej Mosnacek <omosnace@redhat.com>,
"Christian Brauner (Amutable)" <brauner@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: kernel-team@android.com, linux-kernel@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
linux-fsdevel@vger.kernel.org,
Carlos Llamas <cmllamas@google.com>,
stable@vger.kernel.org,
"open list:SELINUX SECURITY MODULE" <selinux@vger.kernel.org>,
"open list:BPF [MISC]:Keyword:(?:b|_)bpf(?:b|_)"
<bpf@vger.kernel.org>
Subject: Re: [PATCH] selinux: bpf: check SBLABEL_MNT before isec init
Date: Thu, 30 Jul 2026 17:10:00 -0400 [thread overview]
Message-ID: <db6fe5d2d4081f20f85abc6020b831fd@paul-moore.com> (raw)
In-Reply-To: <20260730181008.3654413-1-cmllamas@google.com>
On Jul 30, 2026 Carlos Llamas <cmllamas@google.com> wrote:
>
> selinux_inode_init_security() marks the isec as initialized before
> checking if mount labeling is supported (SBLABEL_MNT). This was fine
> until commit 9722955b5430 ("bpf: Add simple xattr support to bpffs"),
> where genfscon bpffs mounts fail the SBLABEL_MNT check as expected (no
> xattrs) and yet leave the isec->initialized. This breaks subsequent
> calls to inode_doinit_with_dentry().
>
> Do the SBLABEL_MNT check before the inode security is initialized.
>
> Cc: stable@vger.kernel.org
> Closes: https://lore.kernel.org/all/akWdcp6P0FkNDzBk@google.com/
> Fixes: 9722955b5430 ("bpf: Add simple xattr support to bpffs")
> Signed-off-by: Carlos Llamas <cmllamas@google.com>
> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> ---
> security/selinux/hooks.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 8d6945edae7a..09a12eb8652c 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -2980,6 +2980,10 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
> if (rc)
> return rc;
>
> + if (!selinux_initialized() ||
> + !(sbsec->flags & SBLABEL_MNT))
> + return -EOPNOTSUPP;
If we're moving this check, we should probably just move it to right
after we assign 'sbsec' at the top of the function. The calls to
inode_mode_to_security() and selinux_determine_inode_label() aren't
doing anything useful in either the !selinux_initialized() or !SBLABEL_MNT
cases so let's avoid the unnecessary work.
> /* Possibly defer initialization to selinux_complete_init. */
> if (sbsec->flags & SE_SBINITIALIZED) {
> struct inode_security_struct *isec = selinux_inode(inode);
> @@ -2988,10 +2992,6 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
> isec->initialized = LABEL_INITIALIZED;
> }
>
> - if (!selinux_initialized() ||
> - !(sbsec->flags & SBLABEL_MNT))
> - return -EOPNOTSUPP;
> -
> xattr = lsm_get_xattr_slot(xattrs, xattr_count);
> if (xattr) {
> rc = security_sid_to_context_force(newsid,
> --
> 2.55.0.508.g3f0d502094-goog
--
paul-moore.com
next prev parent reply other threads:[~2026-07-30 21:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 7:40 [PATCH vfs/vfs-7.2.xattr v3] bpf: Add simple xattr support to bpffs Daniel Borkmann
2026-06-02 18:07 ` bot+bpf-ci
2026-06-02 18:25 ` Daniel Borkmann
2026-06-03 7:07 ` Christian Brauner
2026-07-01 23:06 ` Carlos Llamas
2026-07-10 12:17 ` Daniel Borkmann
2026-07-30 18:10 ` [PATCH] selinux: bpf: check SBLABEL_MNT before isec init Carlos Llamas
2026-07-30 18:50 ` Stephen Smalley
2026-07-30 21:10 ` Paul Moore [this message]
2026-07-30 22:07 ` Carlos Llamas
2026-07-30 22:15 ` [PATCH v2] " Carlos Llamas
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=db6fe5d2d4081f20f85abc6020b831fd@paul-moore.com \
--to=paul@paul-moore.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=daniel@iogearbox.net \
--cc=kernel-team@android.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=selinux@vger.kernel.org \
--cc=stable@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