summaryrefslogtreecommitdiff
path: root/fs/bcachefs/inode.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-10-23 01:29:54 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-31 19:18:37 +0300
commit6ddedca2180b095aacca0f628e0d03a32477f68f (patch)
tree5803ddaeb0620d622de35d9915308c774a8de4cb /fs/bcachefs/inode.c
parentef435abd6a99206d9bb93462a1b0508e0d876adb (diff)
downloadlinux-6ddedca2180b095aacca0f628e0d03a32477f68f.tar.xz
bcachefs: Guard against unknown compression options
Since compression options now include compression level, proper validation is a bit more involved. This adds bch2_compression_opt_valid(), and plumbs it around appropriately. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/inode.c')
-rw-r--r--fs/bcachefs/inode.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index bb3f443d8381..a3921c397ea2 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -6,6 +6,7 @@
#include "bkey_methods.h"
#include "btree_update.h"
#include "buckets.h"
+#include "compress.h"
#include "error.h"
#include "extents.h"
#include "extent_update.h"
@@ -422,9 +423,10 @@ static int __bch2_inode_invalid(struct bkey_s_c k, struct printbuf *err)
return -BCH_ERR_invalid_bkey;
}
- if (unpacked.bi_compression >= BCH_COMPRESSION_OPT_NR + 1) {
- prt_printf(err, "invalid data checksum type (%u >= %u)",
- unpacked.bi_compression, BCH_COMPRESSION_OPT_NR + 1);
+ if (unpacked.bi_compression &&
+ !bch2_compression_opt_valid(unpacked.bi_compression - 1)) {
+ prt_printf(err, "invalid compression opt %u",
+ unpacked.bi_compression - 1);
return -BCH_ERR_invalid_bkey;
}