diff options
| author | Qu Wenruo <[email protected]> | 2025-08-25 10:26:26 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2025-09-18 11:18:49 +0000 |
| commit | b98b208300573f4ab29507f81194a6030b208444 (patch) | |
| tree | 50a6ec2e44e33a4c5f6689bb1eac0445861e7059 /fs/btrfs/compression.h | |
| parent | btrfs: ref-verify: handle damaged extent root tree (diff) | |
| download | kernel-b98b208300573f4ab29507f81194a6030b208444.tar.gz kernel-b98b208300573f4ab29507f81194a6030b208444.zip | |
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 <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'fs/btrfs/compression.h')
| -rw-r--r-- | fs/btrfs/compression.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h index 1b38e707bbd9..7b41b2b5ff44 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h @@ -102,7 +102,7 @@ void btrfs_submit_compressed_write(struct btrfs_ordered_extent *ordered, bool writeback); void btrfs_submit_compressed_read(struct btrfs_bio *bbio); -int btrfs_compress_str2level(unsigned int type, const char *str); +int btrfs_compress_str2level(unsigned int type, const char *str, int *level_ret); struct folio *btrfs_alloc_compr_folio(void); void btrfs_free_compr_folio(struct folio *folio); |
