CVE-2022-49850: nilfs2: fix deadlock in nilfs_count_free_blocks()
In the Linux kernel, the following vulnerability has been resolved:
nilfs2: fix deadlock in nilfs_count_free_blocks()
A semaphore deadlock can occur if nilfs_get_block() detects metadata
corruption while locating data blocks and a superblock writeback occurs at
the same time:
task 1 task 2
------ ------
* A file operation *
nilfs_truncate()
nilfs_get_block()
down_read(rwsem A) <--
nilfs_bmap_lookup_contig()
... generic_shutdown_super()
nilfs_put_super()
* Prepare to write superblock *
down_write(rwsem B) <--
nilfs_cleanup_super()
* Detect b-tree corruption * nilfs_set_log_cursor()
nilfs_bmap_convert_error() nilfs_count_free_blocks()
__nilfs_error() down_read(rwsem A) <--
nilfs_set_error()
down_write(rwsem B) <--
*** DEADLOCK ***
Here, nilfs_get_block() readlocks rwsem A (= NILFS_MDT(dat_inode)->mi_sem)
and then calls nilfs_bmap_lookup_contig(), but if it fails due to metadata
corruption, __nilfs_error() is called from nilfs_bmap_convert_error()
inside the lock section.
Since __nilfs_error() calls nilfs_set_error() unless the filesystem is
read-only and nilfs_set_error() attempts to writelock rwsem B (=
nilfs->ns_sem) to write back superblock exclusively, hierarchical lock
acquisition occurs in the order rwsem A -> rwsem B.
Now, if another task starts updating the superblock, it may writelock
rwsem B during the lock sequence above, and can deadlock trying to
readlock rwsem A in nilfs_count_free_blocks().
However, there is actually no need to take rwsem A in
nilfs_count_free_blocks() because it, within the lock section, only reads
a single integer data on a shared struct with
nilfs_sufile_get_ncleansegs(). This has been the case after commit
aa474a220180 ("nilfs2: add local variable to cache the number of clean
segments"), that is, even before this bug was introduced.
So, this resolves the deadlock problem by just not taking the semaphore in
nilfs_count_free_blocks().
Security readout for executives and security teams
Plain-English summary
This CVE is a Linux kernel NILFS2 filesystem deadlock. A local user or local workload interacting with a corrupted NILFS2 filesystem can trigger a kernel lockup condition affecting availability. It is not described as data theft or privilege escalation.
Executive priority
Treat as a targeted availability risk, not a broad remote compromise. Patch affected Linux systems during normal kernel maintenance, with higher priority for shared servers or systems that process NILFS2 media from less trusted sources.
Technical view
nilfs2 can deadlock when nilfs_get_block() detects metadata corruption while superblock writeback is occurring. The lock order between NILFS_MDT(dat_inode)->mi_sem and nilfs->ns_sem can invert. The fix removes an unnecessary semaphore acquisition in nilfs_count_free_blocks().
Likely exposure
Exposure is likely limited to Linux systems using NILFS2 on affected kernel versions or affected downstream builds. Systems that do not enable, mount, or process NILFS2 filesystems are unlikely to be exposed based on the provided sources.
Exploitation context
The CVSS vector is local, low complexity, low privileges, no user interaction, and high availability impact. The source bundle does not indicate KEV listing or active exploitation. The trigger requires NILFS2 metadata corruption and concurrent superblock writeback conditions.
Researcher notes
The affected record lists Linux kernel versions and multiple stable commit references, but downstream distribution status is not included. Do not assume all Linux systems are affected; validate NILFS2 usage and vendor kernel backports.
Mitigation direction
Inventory systems that mount or process NILFS2 filesystems.
Apply the relevant Linux stable or distribution kernel update containing the referenced fix.
Prioritize hosts where local users can access NILFS2 volumes.
Avoid mounting untrusted NILFS2 media until vendor guidance is applied.
Check Linux distribution advisories for packaged kernel availability.
Validation and detection
Confirm whether NILFS2 is enabled or mounted on Linux assets.
Compare running kernel builds against vendor advisories and fixed stable commits.
Review crash, hang, or filesystem error logs involving nilfs2.
Verify patched kernels include the nilfs_count_free_blocks() semaphore change.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-667: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-667 · source CWE mapping
Improper Locking
Improper Locking represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.