linux-stable/fs/xfs
Eric Sandeen e358d4b622 xfs: do not propagate ENODATA disk errors into xattr code
commit ae668cd567 upstream.

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 07120f1abd we did not oops, but we did return the
wrong error code to userspace.)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Fixes: 07120f1abd ("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>
[ Adjust context: removed metadata health tracking calls ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-04 15:26:31 +02:00
..
libxfs xfs: do not propagate ENODATA disk errors into xattr code 2025-09-04 15:26:31 +02:00
scrub xfs: attr forks require attr, not attr2 2025-06-27 11:07:20 +01:00
Kconfig xfs: verify buffer, inode, and dquot items every tx commit 2025-06-27 11:07:19 +01:00
kmem.c
kmem.h
Makefile
mrlock.h
xfs_acl.c
xfs_acl.h
xfs_aops.c xfs: make xfs_bmapi_convert_delalloc() to allocate the target offset 2025-05-09 09:41:38 +02:00
xfs_aops.h
xfs_attr_inactive.c xfs: make inode unlinked bucket recovery work with quotacheck 2024-09-30 16:23:54 +02:00
xfs_attr_item.c xfs: validate recovered name buffers when recovering xattr items 2025-05-09 09:41:37 +02:00
xfs_attr_item.h
xfs_attr_list.c
xfs_bio_io.c
xfs_bmap_item.c xfs: reserve less log space when recovering log intent items 2025-03-28 21:58:54 +01:00
xfs_bmap_item.h
xfs_bmap_util.c xfs: Fix xfs_prepare_shift() range for RT 2025-06-27 11:07:19 +01:00
xfs_bmap_util.h xfs: fix freeing speculative preallocations for preallocated files 2025-05-09 09:41:38 +02:00
xfs_buf_item_recover.c
xfs_buf_item.c xfs: verify buffer, inode, and dquot items every tx commit 2025-06-27 11:07:19 +01:00
xfs_buf_item.h
xfs_buf.c xfs: force all buffers to be written during btree bulk load 2025-03-28 21:58:55 +01:00
xfs_buf.h xfs: force all buffers to be written during btree bulk load 2025-03-28 21:58:55 +01:00
xfs_dir2_readdir.c
xfs_discard.c
xfs_discard.h
xfs_dquot_item_recover.c xfs: dquot recovery does not validate the recovered dquot 2025-02-01 18:30:09 +01:00
xfs_dquot_item.c xfs: verify buffer, inode, and dquot items every tx commit 2025-06-27 11:07:19 +01:00
xfs_dquot_item.h
xfs_dquot.c xfs: fix error returns from xfs_bmapi_write 2025-05-09 09:41:36 +02:00
xfs_dquot.h
xfs_error.c
xfs_error.h
xfs_export.c xfs: fix reloading entire unlinked bucket lists 2024-09-30 16:23:54 +02:00
xfs_export.h
xfs_extent_busy.c xfs: fix extent busy updating 2024-09-30 16:23:51 +02:00
xfs_extent_busy.h
xfs_extfree_item.c xfs: give xfs_extfree_intent its own perag reference 2025-03-28 21:59:02 +01:00
xfs_extfree_item.h
xfs_file.c xfs: create a new helper to return a file's allocation unit 2025-06-27 11:07:19 +01:00
xfs_file.h xfs: create a new helper to return a file's allocation unit 2025-06-27 11:07:19 +01:00
xfs_filestream.c
xfs_filestream.h
xfs_fsmap.c xfs: use XFS_BUF_DADDR_NULL for daddrs in getfsmap code 2025-06-27 11:07:20 +01:00
xfs_fsmap.h
xfs_fsops.c xfs: fix perag leak when growfs fails 2025-03-28 21:58:55 +01:00
xfs_fsops.h
xfs_globals.c
xfs_health.c
xfs_icache.c xfs: fix freeing speculative preallocations for preallocated files 2025-05-09 09:41:38 +02:00
xfs_icache.h xfs: collect errors from inodegc for unlinked inode recovery 2024-09-30 16:23:52 +02:00
xfs_icreate_item.c
xfs_icreate_item.h
xfs_inode_item_recover.c xfs: inode recovery does not validate the recovered inode 2025-02-01 18:30:08 +01:00
xfs_inode_item.c xfs: verify buffer, inode, and dquot items every tx commit 2025-06-27 11:07:19 +01:00
xfs_inode_item.h xfs: fix AGF vs inode cluster buffer deadlock 2024-09-30 16:23:52 +02:00
xfs_inode.c xfs: create a new helper to return a file's allocation unit 2025-06-27 11:07:19 +01:00
xfs_inode.h xfs: create a new helper to return a file's allocation unit 2025-06-27 11:07:19 +01:00
xfs_ioctl32.c
xfs_ioctl32.h
xfs_ioctl.c xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set 2025-06-27 11:07:20 +01:00
xfs_ioctl.h
xfs_iomap.c xfs: restrict when we try to align cow fork delalloc to cowextsz hints 2025-05-09 09:41:38 +02:00
xfs_iomap.h
xfs_iops.c xfs: declare xfs_file.c symbols in xfs_file.h 2025-06-27 11:07:19 +01:00
xfs_iops.h xfs: declare xfs_file.c symbols in xfs_file.h 2025-06-27 11:07:19 +01:00
xfs_itable.c xfs: fully decouple XFS_IBULK* flags from XFS_IWALK* flags 2025-08-28 16:26:11 +02:00
xfs_itable.h
xfs_iunlink_item.c
xfs_iunlink_item.h
xfs_iwalk.c
xfs_iwalk.h
xfs_linux.h
xfs_log_cil.c
xfs_log_priv.h
xfs_log_recover.c xfs: abort intent items when recovery intents fail 2025-02-01 18:30:08 +01:00
xfs_log.c xfs: up(ic_sema) if flushing data device fails 2025-02-01 18:30:08 +01:00
xfs_log.h
xfs_message.c
xfs_message.h
xfs_mount.c
xfs_mount.h xfs: make inode unlinked bucket recovery work with quotacheck 2024-09-30 16:23:54 +02:00
xfs_mru_cache.c
xfs_mru_cache.h
xfs_notify_failure.c xfs: correct calculation for agend and blockcount 2024-09-30 16:23:53 +02:00
xfs_ondisk.h
xfs_pnfs.c
xfs_pnfs.h
xfs_pwork.c
xfs_pwork.h
xfs_qm_bhv.c xfs: don't over-report free space or inodes in statvfs 2025-02-21 13:49:36 +01:00
xfs_qm_syscalls.c
xfs_qm.c xfs: fix reloading entire unlinked bucket lists 2024-09-30 16:23:54 +02:00
xfs_qm.h
xfs_quota.h
xfs_quotaops.c
xfs_refcount_item.c xfs: reserve less log space when recovering log intent items 2025-03-28 21:58:54 +01:00
xfs_refcount_item.h
xfs_reflink.c xfs: remove a racy if_bytes check in xfs_reflink_end_cow_extent 2025-05-09 09:41:37 +02:00
xfs_reflink.h
xfs_rmap_item.c xfs: reserve less log space when recovering log intent items 2025-03-28 21:58:54 +01:00
xfs_rmap_item.h
xfs_rtalloc.c xfs: reset rootdir extent size hint after growfsrt 2025-06-27 11:07:20 +01:00
xfs_rtalloc.h xfs: move the xfs_rtbitmap.c declarations to xfs_rtbitmap.h 2025-03-28 21:58:54 +01:00
xfs_stats.c
xfs_stats.h
xfs_super.c xfs: report realtime block quota limits on realtime directories 2025-02-21 13:49:35 +01:00
xfs_super.h
xfs_symlink.c xfs: use consistent uid/gid when grabbing dquots for inodes 2025-06-27 11:07:19 +01:00
xfs_symlink.h
xfs_sysctl.c
xfs_sysctl.h
xfs_sysfs.c
xfs_sysfs.h
xfs_trace.c
xfs_trace.h xfs: clean up the rtbitmap fsmap backend 2025-06-27 11:07:19 +01:00
xfs_trans_ail.c
xfs_trans_buf.c
xfs_trans_dquot.c
xfs_trans_priv.h
xfs_trans.c xfs: only run precommits once per transaction object 2024-12-19 18:08:50 +01:00
xfs_trans.h
xfs_xattr.c
xfs_xattr.h
xfs.h xfs: verify buffer, inode, and dquot items every tx commit 2025-06-27 11:07:19 +01:00