Bug 2301467 (CVE-2024-42104)

Summary: CVE-2024-42104 kernel: nilfs2: add missing check for inode numbers on directory entries
Product: [Other] Security Response Reporter: OSIDB Bzimport <bzimport>
Component: vulnerabilityAssignee: Product Security DevOps Team <prodsec-dev>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: dfreiber, drow, jburrell, vkumar
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: kernel 4.19.318, kernel 5.4.280, kernel 5.10.222, kernel 5.15.163, kernel 6.1.98, kernel 6.6.39, kernel 6.9.9, kernel 6.10 Doc Type: If docs needed, set a value
Doc Text:
A vulnerability was found in the Linux kernel in the nilfs2 filesystem where a lack of proper sanity checks can cause a use-after-free of the metadata file inodes, caused when the link count of a metadata file gets corrupted to 0 and the system attempts to delete that inode. This vulnerability can lead to memory corruption or crashes.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2301762    
Bug Blocks:    

Description OSIDB Bzimport 2024-07-30 08:21:35 UTC
In the Linux kernel, the following vulnerability has been resolved:

nilfs2: add missing check for inode numbers on directory entries

Syzbot reported that mounting and unmounting a specific pattern of
corrupted nilfs2 filesystem images causes a use-after-free of metadata
file inodes, which triggers a kernel bug in lru_add_fn().

As Jan Kara pointed out, this is because the link count of a metadata file
gets corrupted to 0, and nilfs_evict_inode(), which is called from iput(),
tries to delete that inode (ifile inode in this case).

The inconsistency occurs because directories containing the inode numbers
of these metadata files that should not be visible in the namespace are
read without checking.

Fix this issue by treating the inode numbers of these internal files as
errors in the sanity check helper when reading directory folios/pages.

Also thanks to Hillf Danton and Matthew Wilcox for their initial mm-layer
analysis.

Comment 1 Mauro Matteo Cascella 2024-07-30 18:27:32 UTC
Upstream advisory:
https://lore.kernel.org/linux-cve-announce/2024073019-CVE-2024-42104-7aa4@gregkh/T

Comment 2 Mauro Matteo Cascella 2024-07-30 18:27:53 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 2301762]