CVE-2022-50845: ext4: fix inode leak in ext4_xattr_inode_create() on an error path
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
ext4: fix inode leak in ext4_xattr_inode_create() on an error path
There is issue as follows when do setxattr with inject fault:
[localhost]# fsck.ext4 -fn /dev/sda
e2fsck 1.46.6-rc1 (12-Sep-2022)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Unattached zero-length inode 15. Clear? no
Unattached inode 15
Connect to /lost+found? no
Pass 5: Checking group summary information
/dev/sda: ********** WARNING: Filesystem still has errors **********
/dev/sda: 15/655360 files (0.0% non-contiguous), 66755/2621440 blocks
This occurs in 'ext4_xattr_inode_create()'. If 'ext4_mark_inode_dirty()' fails, dropping i_nlink of the inode is needed. Or will lead to inode leak.
The Linux kernel CVE team has assigned CVE-2022-50845 to this issue.
Affected and fixed versions
===========================
Fixed in 4.14.303 with commit 0f709e08caffb41bbc9b38b9a4c1bd0769794007 Fixed in 4.19.270 with commit eab94a46560f68d4bcd15222701ced479f84f427 Fixed in 5.4.229 with commit 9ef603086c5b796fde1c7f22a17d0fc826ba54cb Fixed in 5.10.163 with commit 9882601ee689975c1c0076ee65bf222a2a35e535 Fixed in 5.15.87 with commit 322cf639b0b7f137543072c55545adab782b3a25 Fixed in 6.0.18 with commit fdaaf45786dc8c17a72901021772520fceb18f8c Fixed in 6.1.4 with commit 70e5b46beba64706430a87a6d516054225e8ac8a Fixed in 6.2 with commit e4db04f7d3dbbe16680e0ded27ea2a65b10f766a
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2022-50845
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
fs/ext4/xattr.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/0f709e08caffb41bbc9b38b9a4c1bd0769794007 https://git.kernel.org/stable/c/eab94a46560f68d4bcd15222701ced479f84f427 https://git.kernel.org/stable/c/9ef603086c5b796fde1c7f22a17d0fc826ba54cb https://git.kernel.org/stable/c/9882601ee689975c1c0076ee65bf222a2a35e535 https://git.kernel.org/stable/c/322cf639b0b7f137543072c55545adab782b3a25 https://git.kernel.org/stable/c/fdaaf45786dc8c17a72901021772520fceb18f8c https://git.kernel.org/stable/c/70e5b46beba64706430a87a6d516054225e8ac8a https://git.kernel.org/stable/c/e4db04f7d3dbbe16680e0ded27ea2a65b10f766a