Commit 4e2524b
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>1 parent c26ab35 commit 4e2524b
1 file changed
+4
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3327 | 3327 | | |
3328 | 3328 | | |
3329 | 3329 | | |
3330 | | - | |
| 3330 | + | |
3331 | 3331 | | |
3332 | 3332 | | |
3333 | 3333 | | |
| |||
3403 | 3403 | | |
3404 | 3404 | | |
3405 | 3405 | | |
3406 | | - | |
| 3406 | + | |
3407 | 3407 | | |
3408 | 3408 | | |
3409 | 3409 | | |
| |||
3868 | 3868 | | |
3869 | 3869 | | |
3870 | 3870 | | |
3871 | | - | |
3872 | 3871 | | |
3873 | 3872 | | |
3874 | 3873 | | |
3875 | 3874 | | |
3876 | 3875 | | |
3877 | 3876 | | |
3878 | | - | |
| 3877 | + | |
3879 | 3878 | | |
3880 | 3879 | | |
3881 | 3880 | | |
| |||
3972 | 3971 | | |
3973 | 3972 | | |
3974 | 3973 | | |
3975 | | - | |
| 3974 | + | |
3976 | 3975 | | |
3977 | 3976 | | |
3978 | 3977 | | |
| |||
0 commit comments