diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-10 15:27:09 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-15 01:00:12 +0200 |
commit | 9cc8eb3098b8e78c727bc136f8e97ce5178fcce8 (patch) | |
tree | 3592d22f9fcc1c6199a21991ec06e723f3ebd2c0 /fs/bcachefs/btree_io.c | |
parent | bcachefs: Use try_cmpxchg() family of functions instead of cmpxchg() (diff) | |
download | linux-9cc8eb3098b8e78c727bc136f8e97ce5178fcce8.tar.xz linux-9cc8eb3098b8e78c727bc136f8e97ce5178fcce8.zip |
bcachefs: Check for bsets past bch_btree_ptr_v2.sectors_written
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_io.c')
-rw-r--r-- | fs/bcachefs/btree_io.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 0f3d01225878..f523039f1be9 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -689,6 +689,7 @@ static int validate_bset(struct bch_fs *c, struct bch_dev *ca, int write, bool have_retry, bool *saw_error) { unsigned version = le16_to_cpu(i->version); + unsigned ptr_written = btree_ptr_sectors_written(&b->key); struct printbuf buf1 = PRINTBUF; struct printbuf buf2 = PRINTBUF; int ret = 0; @@ -732,11 +733,13 @@ static int validate_bset(struct bch_fs *c, struct bch_dev *ca, btree_node_unsupported_version, "BSET_SEPARATE_WHITEOUTS no longer supported"); - if (btree_err_on(offset + sectors > btree_sectors(c), + if (!write && + btree_err_on(offset + sectors > (ptr_written ?: btree_sectors(c)), -BCH_ERR_btree_node_read_err_fixable, c, ca, b, i, NULL, bset_past_end_of_btree_node, - "bset past end of btree node")) { + "bset past end of btree node (offset %u len %u but written %zu)", + offset, sectors, ptr_written ?: btree_sectors(c))) { i->u64s = 0; ret = 0; goto out; |