CVE-2022-49834
Severity CVSS v4.0:
Pending analysis
Type:
CWE-416
Use After Free
Publication date:
01/05/2025
Last modified:
10/11/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
nilfs2: fix use-after-free bug of ns_writer on remount<br />
<br />
If a nilfs2 filesystem is downgraded to read-only due to metadata<br />
corruption on disk and is remounted read/write, or if emergency read-only<br />
remount is performed, detaching a log writer and synchronizing the<br />
filesystem can be done at the same time.<br />
<br />
In these cases, use-after-free of the log writer (hereinafter<br />
nilfs->ns_writer) can happen as shown in the scenario below:<br />
<br />
Task1 Task2<br />
-------------------------------- ------------------------------<br />
nilfs_construct_segment<br />
nilfs_segctor_sync<br />
init_wait<br />
init_waitqueue_entry<br />
add_wait_queue<br />
schedule<br />
nilfs_remount (R/W remount case)<br />
nilfs_attach_log_writer<br />
nilfs_detach_log_writer<br />
nilfs_segctor_destroy<br />
kfree<br />
finish_wait<br />
_raw_spin_lock_irqsave<br />
__raw_spin_lock_irqsave<br />
do_raw_spin_lock<br />
debug_spin_lock_before ns_writer is freed by Task2. After Task1<br />
waked up, Task1 accesses nilfs->ns_writer which is already freed. This<br />
scenario diagram is based on the Shigeru Yoshida&#39;s post [1].<br />
<br />
This patch fixes the issue by not detaching nilfs->ns_writer on remount so<br />
that this UAF race doesn&#39;t happen. Along with this change, this patch<br />
also inserts a few necessary read-only checks with superblock instance<br />
where only the ns_writer pointer was used to check if the filesystem is<br />
read-only.
Impact
Base Score 3.x
7.80
Severity 3.x
HIGH
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.9.334 (excluding) | |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.10 (including) | 4.14.300 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.15 (including) | 4.19.267 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.20 (including) | 5.4.225 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.5 (including) | 5.10.155 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 5.15.79 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.16 (including) | 6.0.9 (excluding) |
| cpe:2.3:o:linux:linux_kernel:6.1:rc1:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.1:rc2:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.1:rc3:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.1:rc4:*:*:*:*:*:* |
To consult the complete list of CPE names with products and versions, see this page
References to Advisories, Solutions, and Tools
- https://git.kernel.org/stable/c/39a3ed68270b079c6b874d4e4727a512b9b4882c
- https://git.kernel.org/stable/c/4feedde5486c07ea79787839153a71ca71329c7d
- https://git.kernel.org/stable/c/8cccf05fe857a18ee26e20d11a8455a73ffd4efd
- https://git.kernel.org/stable/c/9b162e81045266a2d5b44df9dffdf05c54de9cca
- https://git.kernel.org/stable/c/afbd1188382a75f6cfe22c0b68533f7f9664f182
- https://git.kernel.org/stable/c/b152300d5a1ba4258dacf9916bff20e6a8c7603b
- https://git.kernel.org/stable/c/b2fbf10040216ef5ee270773755fc2f5da65b749
- https://git.kernel.org/stable/c/b4736ab5542112fe0a40f140a0a0b072954f34da



