Commit cad83c9
f2fs: fix to avoid racing on fsync_entry_slab by multi filesystem instances
As syzbot reported, there is an use-after-free issue during f2fs recovery:
Use-after-free write at 0xffff88823bc16040 (in kfence-#10):
kmem_cache_destroy+0x1f/0x120 mm/slab_common.c:486
f2fs_recover_fsync_data+0x75b0/0x8380 fs/f2fs/recovery.c:869
f2fs_fill_super+0x9393/0xa420 fs/f2fs/super.c:3945
mount_bdev+0x26c/0x3a0 fs/super.c:1367
legacy_get_tree+0xea/0x180 fs/fs_context.c:592
vfs_get_tree+0x86/0x270 fs/super.c:1497
do_new_mount fs/namespace.c:2905 [inline]
path_mount+0x196f/0x2be0 fs/namespace.c:3235
do_mount fs/namespace.c:3248 [inline]
__do_sys_mount fs/namespace.c:3456 [inline]
__se_sys_mount+0x2f9/0x3b0 fs/namespace.c:3433
do_syscall_64+0x3f/0xb0 arch/x86/entry/common.c:47
entry_SYSCALL_64_after_hwframe+0x44/0xae
The root cause is multi f2fs filesystem instances can race on accessing
global fsync_entry_slab pointer, result in use-after-free issue of slab
cache, fixes to init/destroy this slab cache only once during module
init/destroy procedure to avoid this issue.
Reported-by: [email protected]
Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>1 parent b763f3b commit cad83c9
3 files changed
+23
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3620 | 3620 | | |
3621 | 3621 | | |
3622 | 3622 | | |
| 3623 | + | |
| 3624 | + | |
3623 | 3625 | | |
3624 | 3626 | | |
3625 | 3627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | 791 | | |
799 | 792 | | |
800 | 793 | | |
| |||
867 | 860 | | |
868 | 861 | | |
869 | 862 | | |
870 | | - | |
871 | | - | |
872 | 863 | | |
873 | 864 | | |
874 | 865 | | |
| |||
878 | 869 | | |
879 | 870 | | |
880 | 871 | | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4227 | 4227 | | |
4228 | 4228 | | |
4229 | 4229 | | |
4230 | | - | |
| 4230 | + | |
4231 | 4231 | | |
4232 | 4232 | | |
| 4233 | + | |
| 4234 | + | |
| 4235 | + | |
4233 | 4236 | | |
4234 | 4237 | | |
4235 | 4238 | | |
| |||
4278 | 4281 | | |
4279 | 4282 | | |
4280 | 4283 | | |
| 4284 | + | |
| 4285 | + | |
4281 | 4286 | | |
4282 | 4287 | | |
4283 | 4288 | | |
| |||
4303 | 4308 | | |
4304 | 4309 | | |
4305 | 4310 | | |
| 4311 | + | |
4306 | 4312 | | |
4307 | 4313 | | |
4308 | 4314 | | |
| |||
0 commit comments