diff options
| author | Hengyu Liang <hengyul@cs.unc.edu> | 2026-08-22 01:17:05 -0400 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2026-09-01 17:11:19 +0200 |
| commit | 7b15d6cf25e6c2aea77129179b75c191b20d79a9 (patch) | |
| tree | f4e225e997b754297611c4e20bcb1beec27a302a /scripts/Makefile.thinlto | |
| parent | bb3a94a6828336dcc2dd891e51ebd92dcdd0b576 (diff) | |
| download | linux-7b15d6cf25e6c2aea77129179b75c191b20d79a9.tar.gz linux-7b15d6cf25e6c2aea77129179b75c191b20d79a9.zip | |
kernfs: preserve security xattrs without allocating iattrs
Commit d5e81a5650b5 ("kernfs: avoid iattr allocation in listxattr")
made kernfs_iop_listxattr() return an empty list when the kernfs node
has no allocated kernfs_iattrs.
However, this also skips security xattr names provided by
simple_xattr_list(). As of now, applications can retrieve the SELinux
label of a sysfs file with getxattr(), but cannot do it through
listxattr().
A similar issue happened before in commit b09e0fa4b4ea ("tmpfs:
implement generic xattr support"). It was fixed by commit 8b0ba61df5a1c
("fs/xattr.c: fix simple_xattr_list to always include security.* xattrs").
Perhaps this recent commit needs a fix as well.
The issue can be reproduced with a simple python program:
python3 - <<'PY'
import os
path = "/sys/kernel/warn_count"
print("getxattr:", os.getxattr(path, "security.selinux"))
print("listxattr:", os.listxattr(path))
PY
Before commit d5e81a5650b5 ("kernfs: avoid iattr allocation in listxattr"),
the result is:
getxattr: b'system_u:object_r:sysfs_t:s0\x00'
listxattr: ['security.selinux']
After that commit, the result is:
getxattr: b'system_u:object_r:sysfs_t:s0\x00'
listxattr: []
This patch will keep listxattr() consistent with getxattr() when security
xattrs are available.
Fixes: d5e81a5650b5 ("kernfs: avoid iattr allocation in listxattr")
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://patch.msgid.link/20260822051705.1761850-1-hengyul@cs.unc.edu
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
