blatt A1
Go to file
Boris Burkov 945559be6e btrfs: qgroup: fix qgroup prealloc rsv leak in subvolume operations
commit 74e97958121aa1f5854da6effba70143f051b0cd upstream.

Create subvolume, create snapshot and delete subvolume all use
btrfs_subvolume_reserve_metadata() to reserve metadata for the changes
done to the parent subvolume's fs tree, which cannot be mediated in the
normal way via start_transaction. When quota groups (squota or qgroups)
are enabled, this reserves qgroup metadata of type PREALLOC. Once the
operation is associated to a transaction, we convert PREALLOC to
PERTRANS, which gets cleared in bulk at the end of the transaction.

However, the error paths of these three operations were not implementing
this lifecycle correctly. They unconditionally converted the PREALLOC to
PERTRANS in a generic cleanup step regardless of errors or whether the
operation was fully associated to a transaction or not. This resulted in
error paths occasionally converting this rsv to PERTRANS without calling
record_root_in_trans successfully, which meant that unless that root got
recorded in the transaction by some other thread, the end of the
transaction would not free that root's PERTRANS, leaking it. Ultimately,
this resulted in hitting a WARN in CONFIG_BTRFS_DEBUG builds at unmount
for the leaked reservation.

The fix is to ensure that every qgroup PREALLOC reservation observes the
following properties:

1. any failure before record_root_in_trans is called successfully
   results in freeing the PREALLOC reservation.
2. after record_root_in_trans, we convert to PERTRANS, and now the
   transaction owns freeing the reservation.

This patch enforces those properties on the three operations. Without
it, generic/269 with squotas enabled at mkfs time would fail in ~5-10
runs on my system. With this patch, it ran successfully 1000 times in a
row.

Fixes: e85fde5162 ("btrfs: qgroup: fix qgroup meta rsv leak for subvolume operations")
CC: stable@vger.kernel.org # 6.1+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
[Xiangyu: BP to fix CVE-2024-35956, due to 6.1 btrfs_subvolume_release_metadata()
defined in ctree.h, modified the header file name from root-tree.h to ctree.h]
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-14 19:53:56 +01:00
arch LoongArch: BPF: Sign-extend return values 2024-12-14 19:53:49 +01:00
block block: fix bio_split_rw_at to take zone_write_granularity into account 2024-12-14 19:53:15 +01:00
certs
crypto crypto: api - Add crypto_clone_tfm 2024-12-14 19:53:51 +01:00
Documentation fs_parser: update mount_api doc to match function signature 2024-12-14 19:53:48 +01:00
drivers drm/amd/display: Check phantom_stream before it is used 2024-12-14 19:53:55 +01:00
fs btrfs: qgroup: fix qgroup prealloc rsv leak in subvolume operations 2024-12-14 19:53:56 +01:00
include crypto: api - Add crypto_tfm_get 2024-12-14 19:53:51 +01:00
init initramfs: avoid filename buffer overrun 2024-12-14 19:53:14 +01:00
io_uring io_uring: fix possible deadlock in io_register_iowq_max_workers() 2024-11-17 15:07:21 +01:00
ipc sysctl: treewide: drop unused argument ctl_table_root::set_ownership(table) 2024-08-11 12:35:51 +02:00
kernel rcu-tasks: Fix access non-existent percpu rtpcp variable in rcu_tasks_need_gpcb() 2024-12-14 19:53:56 +01:00
lib lib/buildid: Fix build ID parsing logic 2024-11-22 15:37:32 +01:00
LICENSES
mm mm: resolve faulty mmap_region() error path behaviour 2024-11-22 15:37:34 +01:00
net ipmr: fix tables suspicious RCU usage 2024-12-14 19:53:52 +01:00
rust rust: macros: provide correct provenance when constructing THIS_MODULE 2024-10-17 15:22:24 +02:00
samples bpf: Fix the xdp_adjust_tail sample prog issue 2024-12-14 19:53:27 +01:00
scripts kconfig: qconf: fix buffer overflow in debug links 2024-10-17 15:22:03 +02:00
security apparmor: fix 'Do simple duplicate message elimination' 2024-12-14 19:53:53 +01:00
sound ALSA: usb-audio: Fix out of bounds reads when finding clock sources 2024-12-14 19:53:54 +01:00
tools selftests/mount_setattr: Fix failures on 64K PAGE_SIZE kernels 2024-12-14 19:53:48 +01:00
usr
virt KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin() 2024-06-27 13:46:21 +02:00
.clang-format inet: ping: use hlist_nulls rcu iterator during lookup 2022-12-01 12:42:46 +01:00
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore Remove *.orig pattern from .gitignore 2024-10-17 15:21:15 +02:00
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: add leah to 6.1 MAINTAINERS file 2024-05-17 11:56:16 +02:00
Makefile Linux 6.1.119 2024-11-22 15:37:35 +01:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.