]> Gentwo Git Trees - linux/.git/commit
btrfs: reject invalid compression level
authorQu Wenruo <wqu@suse.com>
Mon, 25 Aug 2025 10:26:26 +0000 (19:56 +0930)
committerDavid Sterba <dsterba@suse.com>
Thu, 18 Sep 2025 11:18:49 +0000 (13:18 +0200)
commitb98b208300573f4ab29507f81194a6030b208444
tree50a6ec2e44e33a4c5f6689bb1eac0445861e7059
parented4e6b5d644c4dd2bc2872ffec036b7da0ec2e27
btrfs: reject invalid compression level

Inspired by recent changes to compression level parsing in
6db1df415d73fc ("btrfs: accept and ignore compression level for lzo")
it turns out that we do not do any extra validation for compression
level input string, thus allowing things like "compress=lzo:invalid" to
be accepted without warnings.

Although we accept levels that are beyond the supported algorithm
ranges, accepting completely invalid level specification is not correct.

Fix the too loose checks for compression level, by doing proper error
handling of kstrtoint(), so that we will reject not only too large
values (beyond int range) but also completely wrong levels like
"lzo:invalid".

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/compression.h
fs/btrfs/super.c