CVE-2024-46688: erofs: fix out-of-bound access when z_erofs_gbuf_growsize() partially fails
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
erofs: fix out-of-bound access when z_erofs_gbuf_growsize() partially fails
If z_erofs_gbuf_growsize() partially fails on a global buffer due to memory allocation failure or fault injection (as reported by syzbot [1]), new pages need to be freed by comparing to the existing pages to avoid memory leaks.
However, the old gbuf->pages[] array may not be large enough, which can lead to null-ptr-deref or out-of-bound access.
Fix this by checking against gbuf->nrpages in advance.
[1] https://lore.kernel.org/r/[email protected]
The Linux kernel CVE team has assigned CVE-2024-46688 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.10 with commit d6db47e571dc and fixed in 6.10.8 with commit 49c0e0819980 Issue introduced in 6.10 with commit d6db47e571dc and fixed in 6.11-rc5 with commit 0005e01e1e87
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-2024-46688
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/erofs/zutil.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/49c0e081998008cde0c872c0ff9affa1ece4b878 https://git.kernel.org/stable/c/0005e01e1e875c5e27130c5e2ed0189749d1e08a