linux/fs/ext4
Baokun Li 4e2524ba2c ext4: avoid use-after-free in ext4_ext_show_leaf()
In ext4_find_extent(), path may be freed by error or be reallocated, so
using a previously saved *ppath may have been freed and thus may trigger
use-after-free, as follows:

ext4_split_extent
  path = *ppath;
  ext4_split_extent_at(ppath)
  path = ext4_find_extent(ppath)
  ext4_split_extent_at(ppath)
    // ext4_find_extent fails to free path
    // but zeroout succeeds
  ext4_ext_show_leaf(inode, path)
    eh = path[depth].p_hdr
    // path use-after-free !!!

Similar to ext4_split_extent_at(), we use *ppath directly as an input to
ext4_ext_show_leaf(). Fix a spelling error by the way.

Same problem in ext4_ext_handle_unwritten_extents(). Since 'path' is only
used in ext4_ext_show_leaf(), remove 'path' and use *ppath directly.

This issue is triggered only when EXT_DEBUG is defined and therefore does
not affect functionality.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Tested-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://patch.msgid.link/20240822023545.1994557-5-libaokun@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2024-09-03 22:12:16 -04:00
..
.kunitconfig
acl.c ext4: convert to ctime accessor functions 2023-07-24 10:29:54 +02:00
acl.h Revert "ext4: apply umask if ACL support is disabled" 2024-05-02 18:25:39 -04:00
balloc.c ext4: add some kunit stub for mballoc kunit test 2023-10-05 22:32:16 -04:00
bitmap.c ext4: move checksum length calculation of inode bitmap into ext4_inode_bitmap_csum_[verify/set]() functions 2024-09-03 22:12:15 -04:00
block_validity.c ext4: block_validity: Remove unnecessary ‘NULL’ values from new_node 2024-06-27 09:34:00 -04:00
crypto.c ext4: Move CONFIG_UNICODE defguards into the code flow 2024-06-07 17:00:45 +02:00
dir.c ext4: correct encrypted dentry name hash when not casefolded 2024-08-26 21:20:25 -04:00
ext4_extents.h
ext4_jbd2.c use ->bd_mapping instead of ->bd_inode->i_mapping 2024-05-03 02:36:51 -04:00
ext4_jbd2.h ext4: split ext4_journal_start trace for debug 2022-12-01 10:46:54 -05:00
ext4.h ext4: move checksum length calculation of inode bitmap into ext4_inode_bitmap_csum_[verify/set]() functions 2024-09-03 22:12:15 -04:00
extents_status.c ext4: drop all delonly descriptions 2024-09-02 15:26:15 -04:00
extents_status.h ext4: drop ext4_es_is_delonly() 2024-09-02 15:26:14 -04:00
extents.c ext4: avoid use-after-free in ext4_ext_show_leaf() 2024-09-03 22:12:16 -04:00
fast_commit.c ext4: fix incorrect tid assumption in ext4_fc_mark_ineligible() 2024-08-26 23:40:00 -04:00
fast_commit.h ext4: add missing validation of fast-commit record lengths 2022-12-08 21:49:24 -05:00
file.c ext4: dax: fix overflowing extents beyond inode size when partially writing 2024-08-26 23:56:49 -04:00
fsmap.c ext4: port block device access to file 2024-02-25 12:05:26 +01:00
fsmap.h
fsync.c ext4: drop EXT4_MF_FS_ABORTED flag 2023-07-29 18:37:53 -04:00
hash.c ext4: remove redundant checks of s_encoding 2023-08-27 11:27:13 -04:00
ialloc.c ext4: check buffer_verified in advance to avoid unneeded ext4_get_group_info() 2024-09-03 22:12:16 -04:00
indirect.c ext4: update delalloc data reserve spcae in ext4_es_insert_extent() 2024-09-02 15:26:14 -04:00
inline.c ext4: avoid OOB when system.data xattr changes underneath the filesystem 2024-09-03 22:12:16 -04:00
inode-test.c ext4: add missing MODULE_DESCRIPTION() 2024-07-05 16:07:24 -04:00
inode.c ext4: drop ext4_es_is_delonly() 2024-09-02 15:26:14 -04:00
ioctl.c ext4: use memtostr_pad() for s_volume_name 2024-07-05 13:14:51 -04:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
Makefile ext4: move ext4 crypto code to its own file crypto.c 2022-05-21 22:24:24 -04:00
mballoc-test.c ext4: add test_mb_mark_used_cost to estimate cost of mb_mark_used 2024-05-03 00:12:32 -04:00
mballoc.c ext4: clear EXT4_GROUP_INFO_WAS_TRIMMED_BIT even mount with discard 2024-09-02 16:11:24 -04:00
mballoc.h ext4: convert ac_buddy_page to ac_buddy_folio 2024-05-07 15:38:17 -04:00
migrate.c ext4: avoid deadlock in fs reclaim with page writeback 2023-05-13 18:05:04 -04:00
mmp.c ext4: replace read-only check for shutdown check in mmp code 2023-07-29 18:37:53 -04:00
move_extent.c ext4: tidy the BH loop in mext_page_mkuptodate() 2024-08-26 21:47:04 -04:00
namei.c ext4: explicitly exit when ext4_find_inline_entry returns an error 2024-09-03 22:12:16 -04:00
orphan.c ext4: remove trailing newline from ext4_msg() message 2022-12-08 21:49:23 -05:00
page-io.c ext4: remove calls to to set/clear the folio error flag 2024-05-09 00:23:51 -04:00
readpage.c ext4: reduce stack usage in ext4_mpage_readpages() 2024-08-26 21:47:03 -04:00
resize.c ext4: move checksum length calculation of inode bitmap into ext4_inode_bitmap_csum_[verify/set]() functions 2024-09-03 22:12:15 -04:00
super.c ext4: don't set SB_RDONLY after filesystem errors 2024-08-26 23:53:20 -04:00
symlink.c ext4_get_link(): fix breakage in RCU mode 2024-02-25 02:10:32 -05:00
sysfs.c ext4: add positive int attr pointer to avoid sysfs variables overflow 2024-05-02 23:48:30 -04:00
truncate.h
verity.c - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
xattr_hurd.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_security.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_trusted.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_user.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr.c ext4: nested locking for xattr inode 2024-08-26 23:52:02 -04:00
xattr.h ext4: annotate struct ext4_xattr_inode_array with __counted_by() 2024-08-26 23:40:06 -04:00