linux/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>
History 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 mm: introduce memalloc_retry_wait() 2022-01-15 16:30:29 +02:00
kmem.h xfs: remove kmem_zone typedef 2021-10-22 16:00:31 -07:00
Makefile - The usual batches of cleanups from Baoquan He, Muchun Song, Miaohe 2022-08-05 16:32:45 -07:00
mrlock.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs.h xfs: verify buffer, inode, and dquot items every tx commit 2025-06-27 11:07:19 +01:00
xfs_acl.c xfs: move xfs_attr_use_log_assist usage out of libxfs 2022-05-27 10:34:04 +10:00
xfs_acl.h xfs: improve __xfs_set_acl 2022-04-26 13:34:42 +10:00
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: add a xfs_inode_buftarg helper 2019-10-28 08:37:54 -07:00
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: share xattr name and value buffers when logging xattr updates 2022-05-23 08:43:46 +10:00
xfs_attr_list.c xfs: use XFS_IFORK_Q to determine the presence of an xattr fork 2022-07-09 15:17:21 -07:00
xfs_bio_io.c fs/xfs: Use the enum req_op and blk_opf_t types 2022-07-14 12:14:33 -06:00
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: rename _zone variables to _cache 2021-10-22 16:04:20 -07:00
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.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_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: convert buffer log item flags to unsigned. 2022-04-21 10:46:40 +10:00
xfs_buf_item_recover.c xfs: verify buffer contents when we skip log replay 2023-06-09 10:34:29 +02:00
xfs_dir2_readdir.c xfs: rearrange the logic and remove the broken comment for xfs_dir2_isxx 2022-10-04 16:39:58 +11:00
xfs_discard.c xfs: pass perag to xfs_alloc_read_agf() 2022-07-07 19:07:40 +10:00
xfs_discard.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xfs_dquot.c xfs: fix error returns from xfs_bmapi_write 2025-05-09 09:41:36 +02:00
xfs_dquot.h xfs: remove warning counters from struct xfs_dquot_res 2022-05-11 17:12:09 +10: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: remove support for disabling quota accounting on a mounted file system 2021-08-06 11:05:36 -07:00
xfs_dquot_item_recover.c xfs: dquot recovery does not validate the recovered dquot 2025-02-01 18:30:09 +01:00
xfs_error.c xfs: drop write error injection is unfixable, remove it 2024-05-25 16:21:32 +02:00
xfs_error.h xfs: convert ptag flags to unsigned. 2022-04-21 10:47:25 +10:00
xfs_export.c xfs: fix reloading entire unlinked bucket lists 2024-09-30 16:23:54 +02:00
xfs_export.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_extent_busy.c xfs: fix extent busy updating 2024-09-30 16:23:51 +02:00
xfs_extent_busy.h xfs: pass perags through to the busy extent code 2021-06-02 10:48:24 +10:00
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: refactor all the EFI/EFD log item sizeof logic 2022-10-31 08:58:20 -07:00
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: pass perag to xfs_alloc_read_agf() 2022-07-07 19:07:40 +10:00
xfs_filestream.h xfs: convert mount flags to features 2021-08-19 10:07:12 -07:00
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: fix deadlock and streamline xfs_getfsmap performance 2020-10-07 08:40:29 -07:00
xfs_fsops.c xfs: fix perag leak when growfs fails 2025-03-28 21:58:55 +01:00
xfs_fsops.h xfs: get rid of xfs_growfs_{data,log}_t 2021-02-03 09:18:50 -08:00
xfs_globals.c xfs: Add larp debug option 2022-05-11 17:01:22 +10:00
xfs_health.c xfs: replace XFS_FORCED_SHUTDOWN with xfs_is_shutdown 2021-08-19 10:07:13 -07:00
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: fix potential log item leak 2022-05-04 11:45:11 +10:00
xfs_icreate_item.h xfs: rename _zone variables to _cache 2021-10-22 16:04:20 -07: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_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_item_recover.c xfs: inode recovery does not validate the recovered inode 2025-02-01 18:30:08 +01:00
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: kill the XFS_IOC_{ALLOC,FREE}SP* ioctls 2022-01-17 09:16:41 -08:00
xfs_ioctl32.c xfs: Set up infrastructure for log attribute replay 2022-05-04 12:41:02 +10:00
xfs_ioctl32.h xfs: remove unused xfs_ioctl32.h declarations 2022-01-18 10:18:36 -08:00
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: use iomap_valid method to detect stale cached iomaps 2024-05-25 16:21:32 +02:00
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: Enable bulkstat ioctl to support 64-bit per-inode extent counters 2022-04-13 07:02:45 +00:00
xfs_iunlink_item.c xfs: add in-memory iunlink log item 2022-07-14 11:47:42 +10:00
xfs_iunlink_item.h xfs: add in-memory iunlink log item 2022-07-14 11:47:42 +10:00
xfs_iwalk.c xfs: avoid buffer deadlocks when walking fs inodes 2021-08-09 11:13:16 -07:00
xfs_iwalk.h xfs: Decouple XFS_IBULK flags from XFS_IWALK flags 2022-04-13 07:02:44 +00:00
xfs_linux.h fs/xfs: Use the enum req_op and blk_opf_t types 2022-07-14 12:14:33 -06: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: move CIL ordering to the logvec chain 2022-07-07 18:56:08 +10:00
xfs_log_cil.c xfs: xlog_sync() manually adjusts grant head space 2022-07-07 18:56:09 +10:00
xfs_log_priv.h xfs: xlog_sync() manually adjusts grant head space 2022-07-07 18:56:09 +10:00
xfs_log_recover.c xfs: abort intent items when recovery intents fail 2025-02-01 18:30:08 +01:00
xfs_message.c Merge branch 'guilt/xfs-unsigned-flags-5.18' into xfs-5.19-for-next 2022-04-21 16:45:03 +10:00
xfs_message.h xfs: implement per-mount warnings for scrub and shrink usage 2022-05-27 10:31:34 +10:00
xfs_mount.c xfs: fix sb write verify for lazysbcount 2024-05-25 16:21:32 +02:00
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: rename _zone variables to _cache 2021-10-22 16:04:20 -07:00
xfs_mru_cache.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_notify_failure.c xfs: correct calculation for agend and blockcount 2024-09-30 16:23:53 +02:00
xfs_ondisk.h xfs: fix memcpy fortify errors in EFI log format copying 2022-10-31 08:58:20 -07:00
xfs_pnfs.c xfs: use iomap_valid method to detect stale cached iomaps 2024-05-25 16:21:32 +02:00
xfs_pnfs.h xfs: prepare xfs_break_layouts() for another layout type 2018-05-22 07:19:08 -07:00
xfs_pwork.c xfs: increase the default parallelism levels of pwork clients 2021-02-03 09:18:49 -08:00
xfs_pwork.h xfs: increase the default parallelism levels of pwork clients 2021-02-03 09:18:49 -08:00
xfs_qm.c xfs: fix reloading entire unlinked bucket lists 2024-09-30 16:23:54 +02:00
xfs_qm.h xfs: remove quota warning limit from struct xfs_quota_limits 2022-05-11 17:12:09 +10:00
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: introduce xfs_inodegc_push() 2022-06-23 13:34:38 -07:00
xfs_quota.h xfs: queue inactivation immediately when quota is nearing enforcement 2021-08-09 10:52:18 -07:00
xfs_quotaops.c xfs: don't set quota warning values 2022-05-11 17:12:09 +10:00
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: rename _zone variables to _cache 2021-10-22 16:04:20 -07:00
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: pass perag to xfs_alloc_read_agf() 2022-07-07 19:07:40 +10:00
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: rename _zone variables to _cache 2021-10-22 16:04:20 -07:00
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: replace unnecessary seq_printf with seq_puts 2022-09-19 06:48:14 +10:00
xfs_stats.h xfs: periodically relog deferred intent items 2020-10-07 08:40:28 -07:00
xfs_super.c xfs: report realtime block quota limits on realtime directories 2025-02-21 13:49:35 +01:00
xfs_super.h xfs: implement ->notify_failure() for XFS 2022-07-17 17:14:30 -07:00
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: support idmapped mounts 2021-01-24 14:43:46 +01:00
xfs_sysctl.c xfs: restore speculative_cow_prealloc_lifetime sysctl 2021-02-24 10:16:08 -08:00
xfs_sysctl.h xfs: Add larp debug option 2022-05-11 17:01:22 +10:00
xfs_sysfs.c xfs: Add larp debug option 2022-05-11 17:01:22 +10:00
xfs_sysfs.h xfs: Fix unreferenced object reported by kmemleak in xfs_sysfs_init() 2022-10-20 09:42:56 -07:00
xfs_trace.c xfs: add trace point for fs shutdown 2021-08-18 18:46:00 -07:00
xfs_trace.h xfs: clean up the rtbitmap fsmap backend 2025-06-27 11:07:19 +01:00
xfs_trans.c xfs: only run precommits once per transaction object 2024-12-19 18:08:50 +01:00
xfs_trans.h xfs: introduce in-memory inode unlink log items 2022-07-14 09:21:42 -07:00
xfs_trans_ail.c xfs: remove redundant pointer lip 2022-10-20 09:42:56 -07:00
xfs_trans_buf.c xfs: introduce xfs_buf_daddr() 2021-08-19 10:07:14 -07:00
xfs_trans_dquot.c xfs: remove quota warning limit from struct xfs_quota_limits 2022-05-11 17:12:09 +10:00
xfs_trans_priv.h xfs: convert log vector chain to use list heads 2022-07-07 18:55:59 +10:00
xfs_xattr.c xfs: fix TOCTOU race involving the new logged xattrs control knob 2022-06-15 23:13:32 -07:00
xfs_xattr.h xfs: move xfs_attr_use_log_assist usage out of libxfs 2022-05-27 10:34:04 +10:00