CVE-2023-54185: btrfs: remove BUG_ON()'s in add_new_free_space()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
btrfs: remove BUG_ON()'s in add_new_free_space()
At add_new_free_space() we have these BUG_ON()'s that are there to deal with any failure to add free space to the in memory free space cache. Such failures are mostly -ENOMEM that should be very rare. However there's no need to have these BUG_ON()'s, we can just return any error to the caller and all callers and their upper call chain are already dealing with errors.
So just make add_new_free_space() return any errors, while removing the BUG_ON()'s, and returning the total amount of added free space to an optional u64 pointer argument.
The Linux kernel CVE team has assigned CVE-2023-54185 to this issue.
Affected and fixed versions
===========================
Fixed in 6.1.45 with commit 23e72231f8281505883514b23709076e234d4f27 Fixed in 6.4.10 with commit f775ceb0cb530e4a469b718fb2a24843071087f5 Fixed in 6.5 with commit d8ccbd21918fd7fa6ce3226cffc22c444228e8ad
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-54185
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/btrfs/block-group.c
fs/btrfs/block-group.h
fs/btrfs/free-space-tree.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/23e72231f8281505883514b23709076e234d4f27 https://git.kernel.org/stable/c/f775ceb0cb530e4a469b718fb2a24843071087f5 https://git.kernel.org/stable/c/d8ccbd21918fd7fa6ce3226cffc22c444228e8ad