CVE-2024-47691

Source
https://cve.org/CVERecord?id=CVE-2024-47691
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-47691.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2024-47691
Downstream
Related
Published
2024-10-21T11:53:30.555Z
Modified
2026-03-09T23:52:21.814902Z
Summary
f2fs: fix to avoid use-after-free in f2fs_stop_gc_thread()
Details

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] dump_stacklvl+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] __refcount_add 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.

  • remount
    • f2fs_remount
      • f2fsstopgcthread
        • kfree(gcth)
          • f2fsiocshutdown
            • f2fsdoshutdown
              • f2fsstopgcthread
                • kthreadstop(gcth->f2fsgctask) : sbi->gcthread = NULL;

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.

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/47xxx/CVE-2024-47691.json"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
7950e9ac638e84518fbdd5c930939ad46a1068c5
Fixed
fc18e655b62ac6bc9f12f5de0d749b4a3fe1e812
Fixed
7c339dee7eb0f8e4cadc317c595f898ef04dae30
Fixed
d79343cd66343709e409d96b2abb139a0a55ce34
Fixed
c7f114d864ac91515bb07ac271e9824a20f5ed95

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-47691.json"