Commit 5c0f4cc
ext4: drop ppath from ext4_ext_replay_update_ex() to avoid double-free
When calling ext4_force_split_extent_at() in ext4_ext_replay_update_ex(),
the 'ppath' is updated but it is the 'path' that is freed, thus potentially
triggering a double-free in the following process:
ext4_ext_replay_update_ex
ppath = path
ext4_force_split_extent_at(&ppath)
ext4_split_extent_at
ext4_ext_insert_extent
ext4_ext_create_new_leaf
ext4_ext_grow_indepth
ext4_find_extent
if (depth > path[0].p_maxdepth)
kfree(path) ---> path First freed
*orig_path = path = NULL ---> null ppath
kfree(path) ---> path double-free !!!
So drop the unnecessary ppath and use path directly to avoid this problem.
And use ext4_find_extent() directly to update path, avoiding unnecessary
memory allocation and freeing. Also, propagate the error returned by
ext4_find_extent() instead of using strange error codes.
Fixes: 8016e29 ("ext4: fast commit recovery path")
Cc: stable@kernel.org
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-8-libaokun@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>1 parent a164f3a commit 5c0f4cc
1 file changed
+10
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5885 | 5885 | | |
5886 | 5886 | | |
5887 | 5887 | | |
5888 | | - | |
| 5888 | + | |
5889 | 5889 | | |
5890 | 5890 | | |
5891 | 5891 | | |
| |||
5901 | 5901 | | |
5902 | 5902 | | |
5903 | 5903 | | |
5904 | | - | |
5905 | 5904 | | |
5906 | | - | |
| 5905 | + | |
5907 | 5906 | | |
5908 | 5907 | | |
5909 | 5908 | | |
5910 | | - | |
5911 | | - | |
| 5909 | + | |
| 5910 | + | |
5912 | 5911 | | |
5913 | | - | |
5914 | | - | |
| 5912 | + | |
5915 | 5913 | | |
5916 | 5914 | | |
| 5915 | + | |
5917 | 5916 | | |
5918 | 5917 | | |
5919 | | - | |
| 5918 | + | |
5920 | 5919 | | |
5921 | 5920 | | |
5922 | 5921 | | |
5923 | 5922 | | |
5924 | | - | |
5925 | | - | |
| 5923 | + | |
| 5924 | + | |
5926 | 5925 | | |
5927 | | - | |
| 5926 | + | |
5928 | 5927 | | |
5929 | 5928 | | |
5930 | 5929 | | |
| |||
0 commit comments