]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: validate properties before setting them
authorFilipe Manana <fdmanana@suse.com>
Mon, 8 Jun 2026 10:33:53 +0000 (11:33 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Jun 2026 23:58:43 +0000 (01:58 +0200)
commitcf1afec09e9f004a62c54c471863209ed249fca7
treea8724cb0bf534ae21e99864cd69758fbab5ed08b
parentae2eb64bfd9762536f60b690840adcdf622cdcce
btrfs: validate properties before setting them

We set the xattr and then attempt to apply the property. If the apply
fails we then attempt to delete the xattr to avoid an inconsistency.
However we don't verify if the deletion succeed, so if it fails we
leave an inconsistency between the state in the btree and the in-memory
inode.

Address this by validating first if we can apply the property, then set
the xattr, then apply the property, and this last step should not fail
since the validation succeeded before - assert that it does not fail but
leave code to attempt to delete the xattr if it happens, and then abort
the transaction only if the xattr delete failed.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/props.c