]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: fix transaction abort on set received ioctl due to item overflow
authorFilipe Manana <fdmanana@suse.com>
Thu, 26 Feb 2026 23:41:07 +0000 (23:41 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Mar 2026 15:15:28 +0000 (16:15 +0100)
commit41fb97353ff58fa4f31904c343fc8e3df2f7517d
tree80f0c610c845754b1af69cd370e4654763475df9
parent0625e564290450c1921b115fc3d9abef74e055bd
btrfs: fix transaction abort on set received ioctl due to item overflow

commit 87f2c46003fce4d739138aab4af1942b1afdadac upstream.

If the set received ioctl fails due to an item overflow when attempting to
add the BTRFS_UUID_KEY_RECEIVED_SUBVOL we have to abort the transaction
since we did some metadata updates before.

This means that if a user calls this ioctl with the same received UUID
field for a lot of subvolumes, we will hit the overflow, trigger the
transaction abort and turn the filesystem into RO mode. A malicious user
could exploit this, and this ioctl does not even requires that a user
has admin privileges (CAP_SYS_ADMIN), only that he/she owns the subvolume.

Fix this by doing an early check for item overflow before starting a
transaction. This is also race safe because we are holding the subvol_sem
semaphore in exclusive (write) mode.

A test case for fstests will follow soon.

Fixes: dd5f9615fc5c ("Btrfs: maintain subvolume items in the UUID tree")
CC: stable@vger.kernel.org # 3.12+
Reviewed-by: Anand Jain <asj@kernel.org>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ioctl.c
fs/btrfs/uuid-tree.c
fs/btrfs/uuid-tree.h