All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dominick Grift <dominick.grift@defensec.nl>
To: Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: Rahul Sandhu <nvraxn@gmail.com>,
	 paul@paul-moore.com, omosnace@redhat.com,
	 selinux@vger.kernel.org
Subject: Re: ls from coreutils 9.6 doesn't show labels of some files
Date: Tue, 22 Apr 2025 19:35:22 +0200	[thread overview]
Message-ID: <87fri014md.fsf@defensec.nl> (raw)
In-Reply-To: <CAEjxPJ5GVOrX8-MhQqMJ6U+1TSYJ=mPyL1GxMitetkovgh1O8w@mail.gmail.com> (Stephen Smalley's message of "Tue, 22 Apr 2025 13:28:46 -0400")

Stephen Smalley <stephen.smalley.work@gmail.com> writes:

> On Tue, Apr 22, 2025 at 12:31 PM Rahul Sandhu <nvraxn@gmail.com> wrote:
>>
>> Hey,
>>
>> > I can't think of a good reason why we would ever want the *listxattr()
>> > syscalls to not provide security.selinux, if there is an individual
>> > filesystem that is different/broken in this regard it should be
>> > treated as a BUG and fixed.
>>
>> I've spoken to coreutils upstream[1], and they also seem to see this as
>> something which should be fixed in the kernel too[2][3], and appear to
>> want a solution in the kernel rather than working around it in ls(1).
>
> So I assume this was introduced when tmpfs/shmem grew its own xattr
> handlers, since previously it would just fall back to the LSM
> security_inode_listsecurity() hook and return the SELinux ones
> unconditionally. shmem_mknod() calls security_inode_init_security(),
> so inodes created after policy is loaded get their security.selinux
> xattrs set and returned via listxattr. Root directory of tmpfs mount
> and any tmpfs mount that precedes policy load (e.g. initramfs) would
> be the exceptions. Could modify shmem_listxattr() to call
> security_inode_listsecurity() and combine with its own list before
> returning.
>

This also happens when you mount an unlabeled fs:

mkdir /media/foo && mount /dev/sda1 /media/foo && ls -alZ /media

when you label it the issue goes away:

chcon sys.id:sys.role:media.file:s0 /media/foo && ls -alZ /media

>>
>> Thanks,
>> Rahul
>>
>> [1] https://lists.gnu.org/archive/html/bug-coreutils/2025-04/msg00011.html
>> [2] https://lists.gnu.org/archive/html/bug-coreutils/2025-04/msg00025.html
>> [3] https://lists.gnu.org/archive/html/bug-coreutils/2025-04/msg00031.html
>

-- 
gpg --locate-keys dominick.grift@defensec.nl (wkd)
Key fingerprint = FCD2 3660 5D6B 9D27 7FC6  E0FF DA7E 521F 10F6 4098
Dominick Grift
Mastodon: @kcinimod@defensec.nl

  reply	other threads:[~2025-04-22 17:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28 15:11 ls from coreutils 9.6 doesn't show labels of some files Ondrej Mosnacek
2025-01-28 15:26 ` Stephen Smalley
2025-01-28 16:08   ` Paul Moore
2025-04-22 16:31     ` Rahul Sandhu
2025-04-22 17:28       ` Stephen Smalley
2025-04-22 17:35         ` Dominick Grift [this message]
2025-04-22 18:06       ` Casey Schaufler
2025-04-22 18:57         ` 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=87fri014md.fsf@defensec.nl \
    --to=dominick.grift@defensec.nl \
    --cc=nvraxn@gmail.com \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.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.