twx-linux/fs
Eric Sandeen ae668cd567 xfs: do not propagate ENODATA disk errors into xattr code
ENODATA (aka ENOATTR) has a very specific meaning in the xfs xattr code;
namely, that the requested attribute name could not be found.

However, a medium error from disk may also return ENODATA. At best,
this medium error may escape to userspace as "attribute not found"
when in fact it's an IO (disk) error.

At worst, we may oops in xfs_attr_leaf_get() when we do:

	error = xfs_attr_leaf_hasname(args, &bp);
	if (error == -ENOATTR)  {
		xfs_trans_brelse(args->trans, bp);
		return error;
	}

because an ENODATA/ENOATTR error from disk leaves us with a null bp,
and the xfs_trans_brelse will then null-deref it.

As discussed on the list, we really need to modify the lower level
IO functions to trap all disk errors and ensure that we don't let
unique errors like this leak up into higher xfs functions - many
like this should be remapped to EIO.

However, this patch directly addresses a reported bug in the xattr
code, and should be safe to backport to stable kernels. A larger-scope
patch to handle more unique errors at lower levels can follow later.

(Note, prior to 07120f1abdff we did not oops, but we did return the
wrong error code to userspace.)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Fixes: 07120f1abdff ("xfs: Add xfs_has_attr and subroutines")
Cc: stable@vger.kernel.org # v5.9+
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
2025-08-26 11:00:33 +02:00
..
9p vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
adfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
affs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
afs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
autofs new helper: set_default_d_op() 2025-06-10 22:21:16 -04:00
bcachefs vfs-6.17-rc1.fileattr 2025-07-28 15:24:14 -07:00
befs
bfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
btrfs for-6.17-fix-tag 2025-08-06 15:52:56 +03:00
cachefiles vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
ceph Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
coda vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
configfs configfs: use DCACHE_DONTCACHE 2025-06-11 13:41:05 -04:00
cramfs mm: remove callers of pfn_t functionality 2025-07-09 22:42:19 -07:00
crypto fscrypt: Remove gfp_t argument from fscrypt_encrypt_block_inplace() 2025-07-10 12:33:13 -07:00
debugfs Driver core changes for 6.17-rc1 2025-07-29 12:15:39 -07:00
devpts devpts, sunrpc, hostfs: don't bother with ->d_op 2025-06-11 13:40:04 -04:00
dlm treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ecryptfs vfs-6.17-rc1.fileattr 2025-07-28 15:24:14 -07:00
efivarfs vfs-6.17-rc1.fileattr 2025-07-28 15:24:14 -07:00
efs
erofs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
exfat exfat: add cluster chain loop check for dir 2025-08-01 08:34:23 +09:00
exportfs exportfs: use lookup_one_unlocked() 2025-06-11 13:44:15 +02:00
ext2 \n 2025-07-28 16:16:09 -07:00
ext4 Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
f2fs f2fs-for-6.17-rc1 2025-08-04 16:27:21 -07:00
fat Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
freevxfs
fuse Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
gfs2 vfs-6.17-rc1.iomap 2025-07-28 16:09:03 -07:00
hfs hfs/hfsplus updates for v6.17 2025-07-28 16:17:44 -07:00
hfsplus hfs/hfsplus updates for v6.17 2025-07-28 16:17:44 -07:00
hostfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
hpfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
hugetlbfs Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
iomap vfs-6.17-rc1.iomap 2025-07-28 16:09:03 -07:00
isofs Current exclusion rules for ->d_flags stores are rather unpleasant. 2025-07-28 09:17:57 -07:00
jbd2 treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
jffs2 vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
jfs Fixes and cleanups for JFS filesystem 2025-07-31 10:27:11 -07:00
kernfs bpf-next-6.17 2025-07-30 09:58:50 -07:00
lockd
minix vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
netfs netfs: Fix race between cache write completion and ALL_QUEUED being set 2025-07-14 11:05:02 +02:00
nfs NFS client updates for Linux 6.17 2025-08-09 07:20:44 +03:00
nfs_common NFS/localio: nfs_uuid_put() fix the wake up after unlinking the file 2025-08-05 16:45:40 -07:00
nfsd Networking changes for 6.17. 2025-07-30 08:58:55 -07:00
nilfs2 vfs-6.17-rc1.fileattr 2025-07-28 15:24:14 -07:00
nls
notify \n 2025-07-31 10:31:00 -07:00
ntfs3 vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
ocfs2 Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
omfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
openpromfs
orangefs orangefs: fixes for string handling in debugfs and sysfs 2025-07-31 10:22:48 -07:00
overlayfs vfs-6.17-rc1.fileattr 2025-07-28 15:24:14 -07:00
proc Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
pstore pstore: switch to locked_recursive_removal() 2025-07-02 22:36:51 -04:00
qnx4
qnx6
quota VFS: rename lookup_one_len family to lookup_noperm and remove permission check 2025-04-08 11:24:36 +02:00
ramfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
resctrl resctrl: get rid of pointless debugfs_file_{get,put}() 2025-07-09 13:30:28 +02:00
romfs fs: replace mmap hook with .mmap_prepare for simple mappings 2025-06-19 13:56:59 +02:00
smb 33 smb3/cifs client changesets, mostly smbdirect cleanup 2025-08-09 07:12:43 +03:00
squashfs squashfs: fix incorrect argument to sizeof in kmalloc_array call 2025-07-19 19:08:27 -07:00
sysfs sysfs: constify internal references to 'struct bin_attribute' 2025-06-17 10:44:09 +02:00
tests
tracefs Massage rpc_pipefs to use saner primitives and clean up the 2025-07-28 09:56:09 -07:00
ubifs This pull request contains the following changes for UBI and UBIFS: 2025-07-31 10:08:44 -07:00
udf \n 2025-07-28 16:16:09 -07:00
ufs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
unicode
vboxsf vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
verity fsverity: Switch from crypto_shash to SHA-2 library 2025-07-14 11:29:32 -07:00
xfs xfs: do not propagate ENODATA disk errors into xattr code 2025-08-26 11:00:33 +02:00
zonefs zonefs changes for 6.17-rc1 2025-07-28 17:06:51 -07:00
aio.c fs: replace mmap hook with .mmap_prepare for simple mappings 2025-06-19 13:56:59 +02:00
anon_inodes.c fs: export anon_inode_make_secure_inode() and fix secretmem LSM bypass 2025-06-23 12:41:17 +02:00
attr.c docs/vfs: update references to i_mutex to i_rwsem 2025-06-23 12:17:33 +02:00
backing-file.c vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
bad_inode.c
binfmt_elf_fdpic.c execve updates for v6.17 2025-07-28 17:11:40 -07:00
binfmt_elf.c execve updates for v6.17 2025-07-28 17:11:40 -07:00
binfmt_flat.c
binfmt_misc.c binfmt_misc: switch to locked_recursive_removal() 2025-07-02 22:36:51 -04:00
binfmt_script.c
bpf_fs_kfuncs.c bpf: Introduce bpf_cgroup_read_xattr to read xattr of cgroup's node 2025-07-02 14:18:20 +02:00
buffer.c fs: change write_begin/write_end interface to take struct kiocb * 2025-07-16 14:48:18 +02:00
char_dev.c
compat_binfmt_elf.c
coredump.c vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
d_path.c fold fs_struct->{lock,seq} into a seqlock 2025-07-08 10:25:19 +02:00
dax.c fs/dax: Reject IOCB_ATOMIC in dax_iomap_rw() 2025-08-11 14:03:38 +02:00
dcache.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
direct-io.c Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
drop_caches.c
eventfd.c
eventpoll.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
exec.c Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
fcntl.c
fhandle.c fold fs_struct->{lock,seq} into a seqlock 2025-07-08 10:25:19 +02:00
file_attr.c fs: tighten a sanity check in file_attr_to_fileattr() 2025-07-16 10:22:01 +02:00
file_table.c \n 2025-07-31 10:31:00 -07:00
file.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
filesystems.c fs/filesystems: Fix potential unsigned integer underflow in fs_name() 2025-04-14 13:05:59 +02:00
fs_context.c fs/fs_context: Mark an unlikely if condition with unlikely() in vfs_parse_monolithic_sep() 2025-04-14 13:05:59 +02:00
fs_parser.c fs/fs_parse: Remove unused and problematic validate_constant_table() 2025-04-21 10:27:59 +02:00
fs_pin.c
fs_struct.c fold fs_struct->{lock,seq} into a seqlock 2025-07-08 10:25:19 +02:00
fs_types.c
fs-writeback.c
fsopen.c
init.c
inode.c vfs: Remove unnecessary list_for_each_entry_safe() from evict_inodes() 2025-07-10 09:37:32 +02:00
internal.h vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
ioctl.c fs: split fileattr related helpers into separate file 2025-07-01 22:44:22 +02:00
Kconfig fs/Kconfig: enable HUGETLBFS only if ARCH_SUPPORTS_HUGETLBFS 2025-07-24 19:12:38 -07:00
Kconfig.binfmt
kernel_read_file.c
libfs.c vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
locks.c docs/vfs: update references to i_mutex to i_rwsem 2025-06-23 12:17:33 +02:00
Makefile fs: split fileattr related helpers into separate file 2025-07-01 22:44:22 +02:00
mbcache.c
mnt_idmapping.c
mount.h copy_tree(): don't link the mounts via mnt_list 2025-06-29 19:03:37 -04:00
mpage.c fs: use writeback_iter directly in mpage_writepages 2025-05-09 12:37:48 +02:00
namei.c vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
namespace.c vfs-6.17-rc1.nsfs 2025-07-28 12:50:56 -07:00
nsfs.c vfs-6.15-rc1.nsfs 2025-03-24 11:38:12 -07:00
open.c \n 2025-07-31 10:31:00 -07:00
pidfs.c vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
pipe.c fs/pipe: set FMODE_NOWAIT in create_pipe_files() 2025-06-10 13:16:19 +02:00
pnode.c copy_tree(): don't link the mounts via mnt_list 2025-06-29 19:03:37 -04:00
pnode.h get rid of CL_SHARE_TO_SLAVE 2025-06-29 19:03:46 -04:00
posix_acl.c
proc_namespace.c ->mnt_devname is never NULL 2025-05-23 14:20:44 +02:00
read_write.c vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
readdir.c readdir: supply dir_context.count as readdir buffer size hint 2025-05-29 12:31:23 +02:00
remap_range.c
select.c fs: annotate suspected data race between poll_schedule_timeout() and pollwake() 2025-06-23 12:36:51 +02:00
seq_file.c
signalfd.c
splice.c splice: remove duplicate noinline from pipe_clear_nowait 2025-04-25 12:11:56 +02:00
stack.c docs/vfs: update references to i_mutex to i_rwsem 2025-06-23 12:17:33 +02:00
stat.c xfs: New code for 6.16 2025-05-26 12:56:01 -07:00
statfs.c
super.c vfs-6.17-rc1.super 2025-07-28 15:50:15 -07:00
sync.c
sysctls.c
timerfd.c A treewide hrtimer timer cleanup 2025-03-25 10:54:15 -07:00
userfaultfd.c mm/mremap: use an explicit uffd failure path for mremap 2025-07-24 19:12:29 -07:00
utimes.c
xattr.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00