CVE-2022-49850: nilfs2: fix deadlock in nilfs_count_free_blocks()

Published May 1, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

nilfs2: fix deadlock in nilfscountfreeblocks()

A semaphore deadlock can occur if nilfsgetblock() detects metadata corruption while locating data blocks and a superblock writeback occurs at the same time:

task 1 task 2 ------ ------ A file operation nilfstruncate() nilfsgetblock() downread(rwsem A) <-- nilfsbmaplookupcontig() ... genericshutdownsuper() nilfsputsuper() Prepare to write superblock downwrite(rwsem B) <-- nilfscleanupsuper() Detect b-tree corruption nilfssetlogcursor() nilfsbmapconverterror() nilfscountfreeblocks() nilfserror() downread(rwsem A) <-- nilfsseterror() downwrite(rwsem B) <--

DEADLOCK

Here, nilfsgetblock() readlocks rwsem A (= NILFSMDT(datinode)->misem) and then calls nilfsbmaplookupcontig(), but if it fails due to metadata corruption, nilfserror() is called from nilfsbmapconverterror() inside the lock section.

Since nilfserror() calls nilfsseterror() unless the filesystem is read-only and nilfsseterror() attempts to writelock rwsem B (= nilfs->nssem) 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 nilfscountfreeblocks().

However, there is actually no need to take rwsem A in nilfscountfreeblocks() because it, within the lock section, only reads a single integer data on a shared struct with nilfssufilegetncleansegs(). 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 nilfscountfreeblocks().

Affected Software

12 affected components
Linux Linux kernel
Linux Linux kernel>=2.6.38<4.9.334
Linux Linux kernel>=4.10<4.14.300
Linux Linux kernel>=4.15<4.19.267
Linux Linux kernel>=4.20<5.4.225
Linux Linux kernel>=5.5<5.10.155
Linux Linux kernel>=5.11<5.15.79
Linux Linux kernel>=5.16<6.0.9
Linux Linux kernel=6.1-rc1
Linux Linux kernel=6.1-rc2
Linux Linux kernel=6.1-rc3
Linux Linux kernel=6.1-rc4

Event History

May 1, 2025
CVE Published
via MITRE·02:10 PM
Data Sourced
via MITRE·02:10 PM
Description
Data Sourced
via NVD·03:16 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2022-49850?

CVE-2022-49850 has a severity rating that indicates a moderate risk to systems using the affected Linux kernel versions.

2

How do I fix CVE-2022-49850?

To fix CVE-2022-49850, update your Linux kernel to a version that includes the patches addressing this vulnerability.

3

Which Linux kernel versions are affected by CVE-2022-49850?

CVE-2022-49850 affects multiple versions of the Linux kernel ranging from 2.6.38 to 6.1-rc4.

4

What type of vulnerability is CVE-2022-49850?

CVE-2022-49850 is a semaphore deadlock vulnerability that can result in system hangs under specific conditions.

5

Is CVE-2022-49850 a serious issue for my Linux system?

Yes, CVE-2022-49850 is considered a serious issue because it can lead to deadlock situations, affecting system availability.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203