lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250702-hochmoderne-abklatsch-af9c605b57b2@brauner>
Date: Wed, 2 Jul 2025 14:17:57 +0200
From: Christian Brauner <brauner@...nel.org>
To: André Draszik <andre.draszik@...aro.org>
Cc: Song Liu <song@...nel.org>, bpf@...r.kernel.org, 
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-security-module@...r.kernel.org, kernel-team@...a.com, andrii@...nel.org, eddyz87@...il.com, 
	ast@...nel.org, daniel@...earbox.net, martin.lau@...ux.dev, 
	viro@...iv.linux.org.uk, jack@...e.cz, kpsingh@...nel.org, mattbobrowski@...gle.com, 
	amir73il@...il.com, gregkh@...uxfoundation.org, tj@...nel.org, 
	daan.j.demeyer@...il.com, Will McVicker <willmcvicker@...gle.com>, 
	Peter Griffin <peter.griffin@...aro.org>, Tudor Ambarus <tudor.ambarus@...aro.org>, 
	kernel-team@...roid.com
Subject: Re: [PATCH v3 bpf-next 1/4] kernfs: remove iattr_mutex

On Wed, Jul 02, 2025 at 11:47:58AM +0100, André Draszik wrote:
> Hi,
> 
> On Sun, 2025-06-22 at 23:38 -0700, Song Liu wrote:
> > From: Christian Brauner <brauner@...nel.org>
> > 
> > All allocations of struct kernfs_iattrs are serialized through a global
> > mutex. Simply do a racy allocation and let the first one win. I bet most
> > callers are under inode->i_rwsem anyway and it wouldn't be needed but
> > let's not require that.
> > 
> > Signed-off-by: Christian Brauner <brauner@...nel.org>
> > Acked-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> > Acked-by: Tejun Heo <tj@...nel.org>
> > Signed-off-by: Song Liu <song@...nel.org>
> 
> On next-20250701, ls -lA gives errors on /sys:
> 
> $ ls -lA /sys/
> ls: /sys/: No data available
> ls: /sys/kernel: No data available
> ls: /sys/power: No data available
> ls: /sys/class: No data available
> ls: /sys/devices: No data available
> ls: /sys/dev: No data available
> ls: /sys/hypervisor: No data available
> ls: /sys/fs: No data available
> ls: /sys/bus: No data available
> ls: /sys/firmware: No data available
> ls: /sys/block: No data available
> ls: /sys/module: No data available
> total 0
> drwxr-xr-x   2 root root 0 Jan  1  1970 block
> drwxr-xr-x  52 root root 0 Jan  1  1970 bus
> drwxr-xr-x  88 root root 0 Jan  1  1970 class
> drwxr-xr-x   4 root root 0 Jan  1  1970 dev
> drwxr-xr-x  11 root root 0 Jan  1  1970 devices
> drwxr-xr-x   3 root root 0 Jan  1  1970 firmware
> drwxr-xr-x  10 root root 0 Jan  1  1970 fs
> drwxr-xr-x   2 root root 0 Jul  2 09:43 hypervisor
> drwxr-xr-x  14 root root 0 Jan  1  1970 kernel
> drwxr-xr-x 251 root root 0 Jan  1  1970 module
> drwxr-xr-x   3 root root 0 Jul  2 09:43 power
> 
> 
> and my bisect is pointing to this commit. Simply reverting it also fixes
> the errors.
> 
> 
> Do you have any suggestions?

Yes, apparently the xattr selftest don't cover sysfs/kernfs. The issue
is that the commit changed listxattr() to skip allocation of the xattr
header and instead just returned ENODATA. We should just allocate like
before tested just now:

user1@...alhost:~$ sudo ls -al /sys/kernel/
total 0
drwxr-xr-x  17 root root    0 Jul  2 13:41 .
dr-xr-xr-x  12 root root    0 Jul  2 13:41 ..
-r--r--r--   1 root root 4096 Jul  2 13:41 address_bits
drwxr-xr-x   3 root root    0 Jul  2 13:41 boot_params
drwxr-xr-x   2 root root    0 Jul  2 13:41 btf
drwxr-xr-x   2 root root    0 Jul  2 13:41 cgroup
drwxr-xr-x   2 root root    0 Jul  2 13:41 config
-r--r--r--   1 root root 4096 Jul  2 13:41 cpu_byteorder
-r--r--r--   1 root root 4096 Jul  2 13:41 crash_elfcorehdr_size
drwx------  34 root root    0 Jul  2 13:41 debug
-r--r--r--   1 root root 4096 Jul  2 13:41 fscaps
-r--r--r--   1 root root 4096 Jul  2 13:41 hardlockup_count
drwxr-xr-x   2 root root    0 Jul  2 13:41 iommu_groups
drwxr-xr-x 344 root root    0 Jul  2 13:41 irq
-r--r--r--   1 root root 4096 Jul  2 13:41 kexec_crash_loaded
-rw-r--r--   1 root root 4096 Jul  2 13:41 kexec_crash_size
-r--r--r--   1 root root 4096 Jul  2 13:41 kexec_loaded
drwxr-xr-x   9 root root    0 Jul  2 13:41 mm
-r--r--r--   1 root root   84 Jul  2 13:41 notes
-r--r--r--   1 root root 4096 Jul  2 13:41 oops_count
-rw-r--r--   1 root root 4096 Jul  2 13:41 profiling
-rw-r--r--   1 root root 4096 Jul  2 13:41 rcu_expedited
-rw-r--r--   1 root root 4096 Jul  2 13:41 rcu_normal
-r--r--r--   1 root root 4096 Jul  2 13:41 rcu_stall_count
drwxr-xr-x   2 root root    0 Jul  2 13:41 reboot
drwxr-xr-x   2 root root    0 Jul  2 13:41 sched_ext
drwxr-xr-x   4 root root    0 Jul  2 13:41 security
drwxr-xr-x 190 root root    0 Jul  2 13:41 slab
-r--r--r--   1 root root 4096 Jul  2 13:41 softlockup_count
drwxr-xr-x   2 root root    0 Jul  2 13:41 software_nodes
drwxr-xr-x   4 root root    0 Jul  2 13:41 sunrpc
drwxr-xr-x   6 root root    0 Jul  2 13:41 tracing
-r--r--r--   1 root root 4096 Jul  2 13:41 uevent_seqnum
-r--r--r--   1 root root 4096 Jul  2 13:41 vmcoreinfo
-r--r--r--   1 root root 4096 Jul  2 13:41 warn_count

I'm folding:

diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 3c293a5a21b1..457f91c412d4 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -142,9 +142,9 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size)
        struct kernfs_node *kn = kernfs_dentry_node(dentry);
        struct kernfs_iattrs *attrs;

-       attrs = kernfs_iattrs_noalloc(kn);
+       attrs = kernfs_iattrs(kn);
        if (!attrs)
-               return -ENODATA;
+               return -ENOMEM;

        return simple_xattr_list(d_inode(dentry), &attrs->xattrs, buf, size);
 }

which brings it back to the old behavior.

I'm also adding a selftest for this behavior. Patch appended.

View attachment "0001-selftests-kernfs-test-xattr-retrieval.patch" of type "text/x-diff" (2748 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ