{"id":"CVE-2022-49834","published":"2025-05-01T14:09:52Z","modified":"2026-08-05T08:56:25Z","title":"nilfs2: fix use-after-free bug of ns_writer on remount","vendor":"Linux","product":"Linux","tier":"tail","description":{"text":"In the Linux kernel, the following vulnerability has been resolved:\n\nnilfs2: fix use-after-free bug of ns_writer on remount\n\nIf a nilfs2 filesystem is downgraded to read-only due to metadata\ncorruption on disk and is remounted read/write, or if emergency read-only\nremount is performed, detaching a log writer and synchronizing the\nfilesystem can be done at the same time.\n\nIn these cases, use-after-free of the log writer (hereinafter\nnilfs->ns_writer) can happen as shown in the scenario below:\n\n Task1                               Task2\n --------------------------------    ------------------------------\n nilfs_construct_segment\n   nilfs_segctor_sync\n     init_wait\n     init_waitqueue_entry\n     add_wait_queue\n     schedule\n                                     nilfs_remount (R/W remount case)\n\t\t\t\t       nilfs_attach_log_writer\n                                         nilfs_detach_log_writer\n                                           nilfs_segctor_destroy\n                                             kfree\n     finish_wait\n       _raw_spin_lock_irqsave\n         __raw_spin_lock_irqsave\n           do_raw_spin_lock\n             debug_spin_lock_before  <-- use-after-free\n\nWhile Task1 is sleeping, nilfs->ns_writer is freed by Task2.  After Task1\nwaked up, Task1 accesses nilfs->ns_writer which is already freed.  This\nscenario diagram is based on the Shigeru Yoshida's post [1].\n\nThis patch fixes the issue by not detaching nilfs->ns_writer on remount so\nthat this UAF race doesn't happen.  Along with this change, this patch\nalso inserts a few necessary read-only checks with superblock instance\nwhere only the ns_writer pointer was used to check if the filesystem is\nread-only.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.8,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00223,"percentile":0.12927,"provenance":"source"},"cwes":[],"references":[{"url":"https://git.kernel.org/stable/c/b2fbf10040216ef5ee270773755fc2f5da65b749","tags":[]},{"url":"https://git.kernel.org/stable/c/39a3ed68270b079c6b874d4e4727a512b9b4882c","tags":[]},{"url":"https://git.kernel.org/stable/c/b4736ab5542112fe0a40f140a0a0b072954f34da","tags":[]},{"url":"https://git.kernel.org/stable/c/9b162e81045266a2d5b44df9dffdf05c54de9cca","tags":[]},{"url":"https://git.kernel.org/stable/c/4feedde5486c07ea79787839153a71ca71329c7d","tags":[]},{"url":"https://git.kernel.org/stable/c/afbd1188382a75f6cfe22c0b68533f7f9664f182","tags":[]},{"url":"https://git.kernel.org/stable/c/b152300d5a1ba4258dacf9916bff20e6a8c7603b","tags":[]},{"url":"https://git.kernel.org/stable/c/8cccf05fe857a18ee26e20d11a8455a73ffd4efd","tags":[]}],"priority":{"score":8.0,"factors":[{"name":"EPSS percentile","points":2.59},{"name":"CVSS severity","points":5.46}]},"vendorSlug":"linux","affectedVersions":[{"vendor":"Linux","product":"Linux","versions":[">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < b2fbf10040216ef5ee270773755fc2f5da65b749",">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < 39a3ed68270b079c6b874d4e4727a512b9b4882c",">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < b4736ab5542112fe0a40f140a0a0b072954f34da",">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < 9b162e81045266a2d5b44df9dffdf05c54de9cca",">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < 4feedde5486c07ea79787839153a71ca71329c7d",">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < afbd1188382a75f6cfe22c0b68533f7f9664f182",">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < b152300d5a1ba4258dacf9916bff20e6a8c7603b",">= fe5f171bb272946ce5fbf843ce2f8467d0d41b9a, < 8cccf05fe857a18ee26e20d11a8455a73ffd4efd"]},{"vendor":"Linux","product":"Linux","versions":["2.6.34"]}],"euvd":{"id":"EUVD-2025-12938","exploited":false,"provenance":"source"}}