All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Stephen Smalley <stephen.smalley.work@gmail.com>,
	selinux@vger.kernel.org
Cc: omosnacek@gmail.com, Stephen Smalley <stephen.smalley.work@gmail.com>
Subject: Re: [PATCH] selinux: preserve NATIVE_LABELS on already-initialized sb  in set_mnt_opts
Date: Wed, 30 Sep 2026 15:10:37 -0400	[thread overview]
Message-ID: <70496fd60aef3673da80b79ee28c8628@paul-moore.com> (raw)
In-Reply-To: <20260928141917.17577-1-stephen.smalley.work@gmail.com>

On Sep 28, 2026 Stephen Smalley <stephen.smalley.work@gmail.com> wrote:
> 
> When an NFSv4 filesystem exported with security_label is mounted a
> second time, sget_fc() returns the existing superblock and
> nfs_get_root() calls security_sb_set_mnt_opts() again on it. Since the
> superblock is already SB_INITIALIZED, selinux_set_mnt_opts() takes an
> early exit without setting SECURITY_LSM_NATIVE_LABELS in
> *set_kern_flags. nfs_get_root() then sees kflags without
> SECURITY_LSM_NATIVE_LABELS set and clears NFS_CAP_SECURITY_LABEL on
> the shared nfs_server, silently disabling per-file labeling for both
> the new and the original mount.
> 
> Commit 3815a245b501 ("security/selinux: fix SECURITY_LSM_NATIVE_LABELS
> on reused superblock") fixed the same problem in
> selinux_sb_clone_mnt_opts().  The reused-superblock path for a plain
> second mount now goes through sb_set_mnt_opts rather than
> sb_clone_mnt_opts, so it needs the same treatment: on both
> SE_SBINITIALIZED early exits, set SECURITY_LSM_NATIVE_LABELS in
> *set_kern_flags when the superblock was already using
> SECURITY_FS_USE_NATVE.
> 
> Closes: https://github.com/SELinuxProject/selinux-kernel/issues/69
> Closes: https://github.com/SELinuxProject/selinux-testsuite/issues/92
> Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> Closes: https://github.com/SELinuxProject/selinux-kernel/issues/70
> Closes: https://github.com/SELinuxProject/selinux-testsuite/issues/91
> Fixes: eb9ae686507b ("SELinux: Add a new labeling type native labels")
> ---
>  security/selinux/hooks.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Nice catch, thanks Stephen!  I'm going to mark this for stable and merge
it into selinux/stable-7.3.

--
paul-moore.com

      parent reply	other threads:[~2026-09-30 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 14:19 [PATCH] selinux: preserve NATIVE_LABELS on already-initialized sb in set_mnt_opts Stephen Smalley
2026-09-28 14:24 ` sashiko-bot
2026-09-28 15:26 ` Stephen Smalley
2026-09-30 19:10 ` Paul Moore [this message]

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=70496fd60aef3673da80b79ee28c8628@paul-moore.com \
    --to=paul@paul-moore.com \
    --cc=omosnacek@gmail.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 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.