diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-26 23:17:58 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-27 19:10:43 -0400 |
commit | 650fb60cf7baa38a2453c3a157f39ee415194029 (patch) | |
tree | 5a070da46a0949ad2390991b899715f6516b891e /fs/bcachefs/alloc_background.c | |
parent | 882b5a926d98069b05f8cee07b41c9b993503c71 (diff) |
bcachefs: Check for excess backpointersraof-455
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_background.c')
-rw-r--r-- | fs/bcachefs/alloc_background.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 796b9f5afe8c..1a35b210f737 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -280,6 +280,16 @@ int bch2_alloc_v4_invalid(const struct bch_fs *c, struct bkey_s_c k, } if (rw == WRITE) { + unsigned i, bp_len = 0; + + for (i = 0; i < BCH_ALLOC_V4_NR_BACKPOINTERS(a.v); i++) + bp_len += alloc_v4_backpointers_c(a.v)[i].bucket_len; + + if (bp_len > a.v->dirty_sectors) { + prt_printf(err, "too many backpointers"); + return -EINVAL; + } + if (alloc_data_type(*a.v, a.v->data_type) != a.v->data_type) { prt_printf(err, "invalid data type (got %u should be %u)", a.v->data_type, alloc_data_type(*a.v, a.v->data_type)); |