diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-14 00:51:48 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-14 20:02:11 -0400 |
commit | f0a73d4fde5b285d94a702026216d9fd1fd2733d (patch) | |
tree | 3be4fdd62b89b61473f21a20c8ade3adab1a3181 /fs/bcachefs/backpointers.c | |
parent | 27c15ed297cb71c2e7a839439b5a097081a32605 (diff) | |
download | linux-stable-f0a73d4fde5b285d94a702026216d9fd1fd2733d.tar.gz linux-stable-f0a73d4fde5b285d94a702026216d9fd1fd2733d.tar.bz2 linux-stable-f0a73d4fde5b285d94a702026216d9fd1fd2733d.zip |
bcachefs: Check for backpointer bucket_offset >= bucket size
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/backpointers.c')
-rw-r--r-- | fs/bcachefs/backpointers.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/bcachefs/backpointers.c b/fs/bcachefs/backpointers.c index 114328acde72..fadb1078903d 100644 --- a/fs/bcachefs/backpointers.c +++ b/fs/bcachefs/backpointers.c @@ -49,13 +49,15 @@ int bch2_backpointer_invalid(struct bch_fs *c, struct bkey_s_c k, if (!bch2_dev_exists2(c, bp.k->p.inode)) return 0; + struct bch_dev *ca = bch_dev_bkey_exists(c, bp.k->p.inode); struct bpos bucket = bp_pos_to_bucket(c, bp.k->p); int ret = 0; - bkey_fsck_err_on(!bpos_eq(bp.k->p, bucket_pos_to_bp(c, bucket, bp.v->bucket_offset)), + bkey_fsck_err_on((bp.v->bucket_offset >> MAX_EXTENT_COMPRESS_RATIO_SHIFT) >= ca->mi.bucket_size || + !bpos_eq(bp.k->p, bucket_pos_to_bp(c, bucket, bp.v->bucket_offset)), c, err, - backpointer_pos_wrong, - "backpointer at wrong pos"); + backpointer_bucket_offset_wrong, + "backpointer bucket_offset wrong"); fsck_err: return ret; } |