In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix to avoid use-after-free in f2fsstopgc_thread()
syzbot reports a f2fs bug as below:
_dumpstack lib/dumpstack.c:88 [inline] dumpstacklvl+0x241/0x360 lib/dumpstack.c:114 printreport+0xe8/0x550 mm/kasan/report.c:491 kasanreport+0x143/0x180 mm/kasan/report.c:601 kasancheckrange+0x282/0x290 mm/kasan/generic.c:189 instrumentatomicreadwrite include/linux/instrumented.h:96 [inline] atomicfetchaddrelaxed include/linux/atomic/atomic-instrumented.h:252 [inline] _refcountadd include/linux/refcount.h:184 [inline] _refcountinc include/linux/refcount.h:241 [inline] refcountinc include/linux/refcount.h:258 [inline] gettaskstruct include/linux/sched/task.h:118 [inline] kthreadstop+0xca/0x630 kernel/kthread.c:704 f2fsstopgcthread+0x65/0xb0 fs/f2fs/gc.c:210 f2fsdoshutdown+0x192/0x540 fs/f2fs/file.c:2283 f2fsiocshutdown fs/f2fs/file.c:2325 [inline] _f2fsioctl+0x443a/0xbe60 fs/f2fs/file.c:4325 vfsioctl fs/ioctl.c:51 [inline] _dosysioctl fs/ioctl.c:907 [inline] _sesysioctl+0xfc/0x170 fs/ioctl.c:893 dosyscallx64 arch/x86/entry/common.c:52 [inline] dosyscall64+0xf3/0x230 arch/x86/entry/common.c:83 entrySYSCALL64afterhwframe+0x77/0x7f
The root cause is below race condition, it may cause use-after-free issue in sbi->gc_th pointer.
We will call f2fsdoshutdown() in two paths: - for f2fsiocshutdown() path, we should grab sb->sumount semaphore for fixing. - for f2fsshutdown() path, it's safe since caller has already grabbed sb->s_umount semaphore.
{ "vanir_signatures": [ { "signature_version": "v1", "signature_type": "Function", "target": { "file": "fs/f2fs/file.c", "function": "f2fs_do_shutdown" }, "deprecated": false, "digest": { "length": 1204.0, "function_hash": "251484158801132109540872531614805961844" }, "id": "CVE-2024-47691-0628fb74", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c339dee7eb0f8e4cadc317c595f898ef04dae30" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "fs/f2fs/f2fs.h" }, "deprecated": false, "digest": { "line_hashes": [ "220412086764861106534959252628118343330", "267651090633403922155860518670358673529", "68515751638892026156822563381129427907", "147135587474753584742963360272589645683" ], "threshold": 0.9 }, "id": "CVE-2024-47691-21a39bff", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c339dee7eb0f8e4cadc317c595f898ef04dae30" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "fs/f2fs/file.c" }, "deprecated": false, "digest": { "line_hashes": [ "129607566220298626807578722927592192387", "303858387511682046974434650948331778215", "312613235512565622992214207426703292148", "219594696806794300666048709218578513469", "107952941548675220177894989453470374478", "17739246540868146830923688781539025273", "287102298512206381384537412355076124079", "248001987736988515415959114456468910410", "113970066448567663101721259463878618920", "291508227576302731772291368873129781865", "240782190291724008658419045177082868576", "186117971349526589537906439335525524711", "97967655880531910629110859123137407288", "96547300312072410248686732071952219326", "336767132907911532111759655953064586640" ], "threshold": 0.9 }, "id": "CVE-2024-47691-2a736ed3", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c339dee7eb0f8e4cadc317c595f898ef04dae30" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "fs/f2fs/file.c", "function": "f2fs_ioc_shutdown" }, "deprecated": false, "digest": { "length": 575.0, "function_hash": "303650049812698794886641051903543938671" }, "id": "CVE-2024-47691-45488165", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c7f114d864ac91515bb07ac271e9824a20f5ed95" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "fs/f2fs/super.c" }, "deprecated": false, "digest": { "line_hashes": [ "77953439003310415457012082935650622330", "288414671332461292429979381467976696012", "244441514582358048310356062655116272018", "214834503425278465910640557622604265266" ], "threshold": 0.9 }, "id": "CVE-2024-47691-45efdd98", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c339dee7eb0f8e4cadc317c595f898ef04dae30" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "fs/f2fs/super.c", "function": "f2fs_shutdown" }, "deprecated": false, "digest": { "length": 110.0, "function_hash": "238471102185464019941002573189448184430" }, "id": "CVE-2024-47691-4bab25bf", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c7f114d864ac91515bb07ac271e9824a20f5ed95" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "fs/f2fs/file.c", "function": "f2fs_ioc_shutdown" }, "deprecated": false, "digest": { "length": 575.0, "function_hash": "303650049812698794886641051903543938671" }, "id": "CVE-2024-47691-518cfd1b", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c339dee7eb0f8e4cadc317c595f898ef04dae30" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "fs/f2fs/super.c" }, "deprecated": false, "digest": { "line_hashes": [ "77953439003310415457012082935650622330", "288414671332461292429979381467976696012", "244441514582358048310356062655116272018", "214834503425278465910640557622604265266" ], "threshold": 0.9 }, "id": "CVE-2024-47691-676f6b56", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c7f114d864ac91515bb07ac271e9824a20f5ed95" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "fs/f2fs/f2fs.h" }, "deprecated": false, "digest": { "line_hashes": [ "220412086764861106534959252628118343330", "267651090633403922155860518670358673529", "68515751638892026156822563381129427907", "147135587474753584742963360272589645683" ], "threshold": 0.9 }, "id": "CVE-2024-47691-79aff160", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c7f114d864ac91515bb07ac271e9824a20f5ed95" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "fs/f2fs/file.c", "function": "f2fs_do_shutdown" }, "deprecated": false, "digest": { "length": 1204.0, "function_hash": "251484158801132109540872531614805961844" }, "id": "CVE-2024-47691-875833b4", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c7f114d864ac91515bb07ac271e9824a20f5ed95" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "fs/f2fs/super.c", "function": "f2fs_shutdown" }, "deprecated": false, "digest": { "length": 110.0, "function_hash": "238471102185464019941002573189448184430" }, "id": "CVE-2024-47691-ad719e5f", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c339dee7eb0f8e4cadc317c595f898ef04dae30" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "fs/f2fs/file.c" }, "deprecated": false, "digest": { "line_hashes": [ "129607566220298626807578722927592192387", "303858387511682046974434650948331778215", "312613235512565622992214207426703292148", "219594696806794300666048709218578513469", "107952941548675220177894989453470374478", "17739246540868146830923688781539025273", "287102298512206381384537412355076124079", "248001987736988515415959114456468910410", "113970066448567663101721259463878618920", "291508227576302731772291368873129781865", "240782190291724008658419045177082868576", "186117971349526589537906439335525524711", "97967655880531910629110859123137407288", "96547300312072410248686732071952219326", "336767132907911532111759655953064586640" ], "threshold": 0.9 }, "id": "CVE-2024-47691-d1e9e000", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c7f114d864ac91515bb07ac271e9824a20f5ed95" } ] }