linux-stable/fs/xfs
Eric Sandeen d3cc7476b8 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:30:29 +02:00
..
libxfs xfs: do not propagate ENODATA disk errors into xattr code 2025-09-04 15:30:29 +02:00
scrub xfs: attr forks require attr, not attr2 2024-12-27 13:58:45 +01:00
Kconfig xfs: verify buffer, inode, and dquot items every tx commit 2024-12-27 13:58:44 +01:00
kmem.c
kmem.h
Makefile
mrlock.h
xfs_acl.c
xfs_acl.h
xfs_aops.c
xfs_aops.h
xfs_attr_inactive.c
xfs_attr_item.c
xfs_attr_item.h
xfs_attr_list.c
xfs_bio_io.c
xfs_bmap_item.c
xfs_bmap_item.h
xfs_bmap_util.c xfs: Fix xfs_prepare_shift() range for RT 2024-12-27 13:58:45 +01:00
xfs_bmap_util.h
xfs_buf_item_recover.c xfs: update the pag for the last AG at recovery time 2025-02-27 04:10:43 -08:00
xfs_buf_item.c xfs: verify buffer, inode, and dquot items every tx commit 2024-12-27 13:58:44 +01:00
xfs_buf_item.h
xfs_buf.c
xfs_buf.h
xfs_dahash_test.c
xfs_dahash_test.h
xfs_dir2_readdir.c
xfs_discard.c
xfs_discard.h
xfs_dquot_item_recover.c
xfs_dquot_item.c xfs: verify buffer, inode, and dquot items every tx commit 2024-12-27 13:58:44 +01:00
xfs_dquot_item.h
xfs_dquot.c
xfs_dquot.h
xfs_drain.c
xfs_drain.h
xfs_error.c
xfs_error.h
xfs_export.c
xfs_export.h
xfs_extent_busy.c
xfs_extent_busy.h
xfs_extfree_item.c
xfs_extfree_item.h
xfs_file.c xfs: create a new helper to return a file's allocation unit 2024-12-27 13:58:44 +01:00
xfs_file.h xfs: create a new helper to return a file's allocation unit 2024-12-27 13:58:44 +01:00
xfs_filestream.c xfs: streamline xfs_filestream_pick_ag 2025-02-27 04:10:44 -08:00
xfs_filestream.h
xfs_fsmap.c xfs: use XFS_BUF_DADDR_NULL for daddrs in getfsmap code 2024-12-27 13:58:46 +01:00
xfs_fsmap.h
xfs_fsops.c xfs: pass the exact range to initialize to xfs_initialize_perag 2025-02-27 04:10:43 -08:00
xfs_fsops.h
xfs_globals.c
xfs_health.c
xfs_icache.c xfs: don't free cowblocks from under dirty pagecache on unshare 2025-02-27 04:10:42 -08:00
xfs_icache.h
xfs_icreate_item.c
xfs_icreate_item.h
xfs_inode_item_recover.c
xfs_inode_item.c xfs: verify buffer, inode, and dquot items every tx commit 2024-12-27 13:58:44 +01:00
xfs_inode_item.h
xfs_inode.c xfs: Check for delayed allocations before setting extsize 2025-02-27 04:10:44 -08:00
xfs_inode.h xfs: Check for delayed allocations before setting extsize 2025-02-27 04:10:44 -08:00
xfs_ioctl32.c
xfs_ioctl32.h
xfs_ioctl.c xfs: Check for delayed allocations before setting extsize 2025-02-27 04:10:44 -08:00
xfs_ioctl.h
xfs_iomap.c xfs: Propagate errors from xfs_reflink_cancel_cow_range in xfs_dax_write_iomap_end 2025-02-17 09:40:31 +01:00
xfs_iomap.h
xfs_iops.c xfs: declare xfs_file.c symbols in xfs_file.h 2024-12-27 13:58:44 +01:00
xfs_iops.h xfs: declare xfs_file.c symbols in xfs_file.h 2024-12-27 13:58:44 +01:00
xfs_itable.c xfs: fully decouple XFS_IBULK* flags from XFS_IWALK* flags 2025-08-28 16:28:40 +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: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate() 2025-02-27 04:10:43 -08:00
xfs_log_priv.h
xfs_log_recover.c xfs: update the file system geometry after recoverying superblock buffers 2025-02-27 04:10:43 -08:00
xfs_log.c
xfs_log.h xfs: Remove empty declartion in header file 2025-02-27 04:10:43 -08:00
xfs_message.c
xfs_message.h
xfs_mount.c xfs: pass the exact range to initialize to xfs_initialize_perag 2025-02-27 04:10:43 -08:00
xfs_mount.h
xfs_mru_cache.c
xfs_mru_cache.h
xfs_notify_failure.c
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-27 04:10:44 -08:00
xfs_qm_syscalls.c
xfs_qm.c
xfs_qm.h
xfs_quota.h
xfs_quotaops.c
xfs_refcount_item.c
xfs_refcount_item.h
xfs_reflink.c xfs: don't free cowblocks from under dirty pagecache on unshare 2025-02-27 04:10:42 -08:00
xfs_reflink.h xfs: don't free cowblocks from under dirty pagecache on unshare 2025-02-27 04:10:42 -08:00
xfs_rmap_item.c
xfs_rmap_item.h
xfs_rtalloc.c xfs: reset rootdir extent size hint after growfsrt 2024-12-27 13:58:46 +01:00
xfs_rtalloc.h
xfs_stats.c
xfs_stats.h
xfs_super.c xfs: report realtime block quota limits on realtime directories 2025-02-27 04:10:44 -08:00
xfs_super.h
xfs_symlink.c xfs: use consistent uid/gid when grabbing dquots for inodes 2024-12-27 13:58:44 +01:00
xfs_symlink.h
xfs_sysctl.c
xfs_sysctl.h
xfs_sysfs.c
xfs_sysfs.h
xfs_trace.c
xfs_trace.h
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:11:25 +01:00
xfs_trans.h
xfs_xattr.c
xfs_xattr.h
xfs.h xfs: verify buffer, inode, and dquot items every tx commit 2024-12-27 13:58:44 +01:00