[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEjxPJ4i3fN8qtuY2TRiWRqy+sY3-nV_FYc4uzD-h2ZxAF-M2A@mail.gmail.com>
Date: Thu, 24 Apr 2025 11:43:57 -0400
From: Stephen Smalley <stephen.smalley.work@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: paul@...l-moore.com, omosnace@...hat.com,
linux-security-module@...r.kernel.org, selinux@...r.kernel.org,
Tejun Heo <tj@...nel.org>, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, Hugh Dickins <hughd@...gle.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>, Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [PATCH] vfs,shmem,kernfs: fix listxattr to include security.* xattrs
On Thu, Apr 24, 2025 at 10:55 AM Stephen Smalley
<stephen.smalley.work@...il.com> wrote:
>
> On Thu, Apr 24, 2025 at 9:53 AM Stephen Smalley
> <stephen.smalley.work@...il.com> wrote:
> >
> > On Thu, Apr 24, 2025 at 9:12 AM Greg Kroah-Hartman
> > <gregkh@...uxfoundation.org> wrote:
> > >
> > > On Thu, Apr 24, 2025 at 08:46:43AM -0400, Stephen Smalley wrote:
> > > > The vfs has long had a fallback to obtain the security.* xattrs from the
> > > > LSM when the filesystem does not implement its own listxattr, but
> > > > shmem/tmpfs and kernfs later gained their own xattr handlers to support
> > > > other xattrs. Unfortunately, as a side effect, tmpfs and kernfs-based
> > > > filesystems like sysfs no longer return the synthetic security.* xattr
> > > > names via listxattr unless they are explicitly set by userspace or
> > > > initially set upon inode creation after policy load. coreutils has
> > > > recently switched from unconditionally invoking getxattr for security.*
> > > > for ls -Z via libselinux to only doing so if listxattr returns the xattr
> > > > name, breaking ls -Z of such inodes.
> > > >
> > > > Before:
> > > > $ getfattr -m.* /run/initramfs
> > > > <no output>
> > > > $ getfattr -m.* /sys/kernel/fscaps
> > > > <no output>
> > > >
> > > > After:
> > > > $ getfattr -m.* /run/initramfs
> > > > security.selinux
> > > > $ getfattr -m.* /sys/kernel/fscaps
> > > > security.selinux
> > > >
> > > > Link: https://lore.kernel.org/selinux/CAFqZXNtF8wDyQajPCdGn=iOawX4y77ph0EcfcqcUUj+T87FKyA@mail.gmail.com/
> > > > Link: https://lore.kernel.org/selinux/20250423175728.3185-2-stephen.smalley.work@gmail.com/
> > > > Signed-off-by: Stephen Smalley <stephen.smalley.work@...il.com>
> > >
> > > As this "changed" in the past, shouldn't it have a "Fixes:" tag?
> >
> > Yes, I'll add that on v2. Also appears that it doesn't quite correctly
> > handle the case where listxattr() is called with size == 0 to probe
> > for the required size.
>
> And doesn't correctly handle the case where the list size exceeds the
> original buffer size. On second look, this can be done more simply and
> safely in simple_xattr_list() itself, avoiding the need to modify
> shmem/tmpfs and kernfs. I'll submit an updated patch.
Submitted here,
https://lore.kernel.org/selinux/20250424152822.2719-1-stephen.smalley.work@gmail.com/
Sorry I forgot the Fixes tag again but added it in a reply.
Powered by blists - more mailing lists