{"id":"CVE-2026-31702","aliases":["CVE-2026-31702"],"related":[],"kind":"vulnerability","state":"published","title":"f2fs: fix use-after-free of sbi in f2fs_compress_write_end_io()","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nf2fs: fix use-after-free of sbi in f2fs_compress_write_end_io()\n\nIn f2fs_compress_write_end_io(), dec_page_count(sbi, type) can bring\nthe F2FS_WB_CP_DATA counter to zero, unblocking\nf2fs_wait_on_all_pages() in f2fs_put_super() on a concurrent unmount\nCPU. The unmount path then proceeds to call\nf2fs_destroy_page_array_cache(sbi), which destroys\nsbi->page_array_slab via kmem_cache_destroy(), and eventually\nkfree(sbi). Meanwhile, the bio completion callback is still executing:\nwhen it reaches page_array_free(sbi, ...), it dereferences\nsbi->page_array_slab — a destroyed slab cache — to call\nkmem_cache_free(), causing a use-after-free.\n\nThis is the same class of bug as CVE-2026-23234 (which fixed the\nequivalent race in f2fs_write_end_io() in data.c), but in the\ncompressed writeback completion path that was not covered by that fix.\n\nFix this by moving dec_page_count() to after page_array_free(), so\nthat all sbi accesses complete before the counter decrement that can\nunblock unmount. For non-last folios (where atomic_dec_return on\ncic->pending_pages is nonzero), dec_page_count is called immediately\nbefore returning — page_array_free is not reached on this path, so\nthere is no post-decrement sbi access. For the last folio,\npage_array_free runs while the F2FS_WB_CP_DATA counter is still\nnonzero (this folio has not yet decremented it), keeping sbi alive,\nand dec_page_count runs as the final operation.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nf2fs: fix use-after-free of sbi in f2fs_compress_write_end_io()\n\nIn f2fs_compress_write_end_io(), dec_page_count(sbi, type) can bring\nthe F2FS_WB_CP_DATA counter to zero, unblocking\nf2fs_wait_on_all_pages() in f2fs_put_super() on a concurrent unmount\nCPU. The unmount path then proceeds to call\nf2fs_destroy_page_array_cache(sbi), which destroys\nsbi->page_array_slab via kmem_cache_destroy(), and eventually\nkfree(sbi). Meanwhile, the bio completion callback is still executing:\nwhen it reaches page_array_free(sbi, ...), it dereferences\nsbi->page_array_slab — a destroyed slab cache — to call\nkmem_cache_free(), causing a use-after-free.\n\nThis is the same class of bug as CVE-2026-23234 (which fixed the\nequivalent race in f2fs_write_end_io() in data.c), but in the\ncompressed writeback completion path that was not covered by that fix.\n\nFix this by moving dec_page_count() to after page_array_free(), so\nthat all sbi accesses complete before the counter decrement that can\nunblock unmount. For non-last folios (where atomic_dec_return on\ncic->pending_pages is nonzero), dec_page_count is called immediately\nbefore returning — page_array_free is not reached on this path, so\nthere is no post-decrement sbi access. For the last folio,\npage_array_free runs while the F2FS_WB_CP_DATA counter is still\nnonzero (this folio has not yet decremented it), keeping sbi alive,\nand dec_page_count runs as the final operation.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nf2fs: corrige el uso después de liberación de sbi en f2fs_compress_write_end_io()\n\nEn f2fs_compress_write_end_io(), dec_page_count(sbi, type) puede llevar el contador F2FS_WB_CP_DATA a cero, desbloqueando f2fs_wait_on_all_pages() en f2fs_put_super() en una CPU de desmontaje concurrente. La ruta de desmontaje luego procede a llamar a f2fs_destroy_page_array_cache(sbi), que destruye sbi  ->  page_array_slab a través de kmem_cache_destroy(), y finalmente kfree(sbi). Mientras tanto, la devolución de llamada de finalización de bio todavía se está ejecutando: cuando llega a page_array_free(sbi, ...), desreferencia sbi  ->  page_array_slab - una caché de slab destruida - para llamar a kmem_cache_free(), causando un uso después de liberación.\n\nEsta es la misma clase de error que CVE-2026-23234 (que corrigió la condición de carrera equivalente en f2fs_write_end_io() en data.c), pero en la ruta de finalización de escritura diferida comprimida que no fue cubierta por esa corrección.\n\nCorrige esto moviendo dec_page_count() a después de page_array_free(), para que todos los accesos a sbi se completen antes del decremento del contador que puede desbloquear el desmontaje. Para folios no finales (donde atomic_dec_return en cic  ->  pending_pages es distinto de cero), dec_page_count se llama inmediatamente antes de regresar - page_array_free no se alcanza en esta ruta, por lo que no hay acceso a sbi posterior al decremento. Para el último folio, page_array_free se ejecuta mientras el contador F2FS_WB_CP_DATA todavía es distinto de cero (este folio aún no lo ha decrementado), manteniendo sbi vivo, y dec_page_count se ejecuta como la operación final.","source":"nvd"}],"published":"2026-05-01T13:56:01.601Z","modified":"2026-11-11T21:10:00.200Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":["CWE-416"],"affected":[{"ranges":[{"type":"git","introduced":"4c8ff7095bef64fc47e996a938f7d57f9e077da3","fixed":"57bc678f36ac03281e877c6b84877b43f964143f","status":"affected"},{"type":"git","introduced":"4c8ff7095bef64fc47e996a938f7d57f9e077da3","fixed":"ef57cd3329b40c739b9a2e1a8a21ecc4171c6280","status":"affected"},{"type":"git","introduced":"4c8ff7095bef64fc47e996a938f7d57f9e077da3","fixed":"f5154cf3ce1c8193f0c1891d3769f62740cfe6fe","status":"affected"},{"type":"git","introduced":"4c8ff7095bef64fc47e996a938f7d57f9e077da3","fixed":"c76cf339b87975ae5b2c06d2d774d5667d25a12a","status":"affected"},{"type":"git","introduced":"4c8ff7095bef64fc47e996a938f7d57f9e077da3","fixed":"2c97dcb6147c8f7f25c629b93be1e69617de5d4a","status":"affected"},{"type":"git","introduced":"4c8ff7095bef64fc47e996a938f7d57f9e077da3","fixed":"39d4ee19c1e7d753dd655aebee632271b171f43a","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"5.6","status":"affected"},{"type":"semver","introduced":"0","fixed":"5.6","status":"unaffected"},{"type":"semver","introduced":"6.1.175","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.136","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.84","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.25","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"7.0.2","lastAffected":"7.0.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"5.6","fixed":"6.6.136"},{"status":"affected","introduced":"6.7","fixed":"6.12.84"},{"status":"affected","introduced":"6.13","fixed":"6.18.25"},{"status":"affected","introduced":"6.19","fixed":"7.0.2"},{"status":"affected","version":"7.1"},{"status":"affected","version":"7.1"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/57bc678f36ac03281e877c6b84877b43f964143f","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/ef57cd3329b40c739b9a2e1a8a21ecc4171c6280","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/f5154cf3ce1c8193f0c1891d3769f62740cfe6fe","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/c76cf339b87975ae5b2c06d2d774d5667d25a12a","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/2c97dcb6147c8f7f25c629b93be1e69617de5d4a","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/39d4ee19c1e7d753dd655aebee632271b171f43a","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-31702","url":"https://www.cve.org/CVERecord?id=CVE-2026-31702","licence":"CVE Terms of Use","modified":"2026-06-14T17:43:43.186Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-31702","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31702","licence":"Public domain","modified":"2026-11-11T21:10:00.200Z"}],"updatedAt":"2026-11-25T22:59:20.338Z","epss":{"score":0.00122,"percentile":0.02129,"date":"2026-12-01T12:00:22.000Z"}}