CVE-2023-54130: hfs/hfsplus: avoid WARN_ON() for sanity check, use proper error handling
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
hfs/hfsplus: avoid WARN_ON() for sanity check, use proper error handling
Commit 55d1cbbbb29e ("hfs/hfsplus: use WARN_ON for sanity check") fixed a build warning by turning a comment into a WARN_ON(), but it turns out that syzbot then complains because it can trigger said warning with a corrupted hfs image.
The warning actually does warn about a bad situation, but we are much better off just handling it as the error it is. So rather than warn about us doing bad things, stop doing the bad things and return -EIO.
While at it, also fix a memory leak that was introduced by an earlier fix for a similar syzbot warning situation, and add a check for one case that historically wasn't handled at all (ie neither comment nor subsequent WARN_ON).
The Linux kernel CVE team has assigned CVE-2023-54130 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.16 with commit 55d1cbbbb29e6656c662ee8f73ba1fc4777532eb and fixed in 6.0.19 with commit 90e019006644dad35862cb4aa270f561b0732066 Issue introduced in 5.16 with commit 55d1cbbbb29e6656c662ee8f73ba1fc4777532eb and fixed in 6.1.5 with commit 45917be9f0af339a45b4619f31c902d37b8aed59 Issue introduced in 5.16 with commit 55d1cbbbb29e6656c662ee8f73ba1fc4777532eb and fixed in 6.2 with commit cb7a95af78d29442b8294683eca4897544b8ef46 Issue introduced in 4.9.337 with commit 8c40f2dbae603ef0bd21e87c63f54ec59fd88256 Issue introduced in 5.15.86 with commit 367296925c7625c3969d2a78d7a3e1dee161beb5
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-2023-54130
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/hfs/inode.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/cc2164ada548addfa8ee215196661c3afe0c5154 https://git.kernel.org/stable/c/82725be426bce0a425cc5e26fbad61ffd29cff03 https://git.kernel.org/stable/c/da23752d9660ba7a8ca6c5768fd8776f67f59ee7 https://git.kernel.org/stable/c/be01f35efa876eb81cebab2cb0add068b7280ef4 https://git.kernel.org/stable/c/f10defb0be6ac42fb6a97b45920d32da6bd6fde8 https://git.kernel.org/stable/c/90e019006644dad35862cb4aa270f561b0732066 https://git.kernel.org/stable/c/45917be9f0af339a45b4619f31c902d37b8aed59 https://git.kernel.org/stable/c/cb7a95af78d29442b8294683eca4897544b8ef46