On Tue, Aug 13, 2024 at 07:31:19PM GMT, zhanghao wrote: > The bkey_val_bytes() gets the number of bytes of value > stored in bkey->u64s.If u64s is smaller than BKEY_U64s, > it causes a negative number to be converted to an > unsigned number.
Nope, this patch is is _completely_ wrong > > Reported-by: syzbot+1a11884d9c9f13539...@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=1a11884d9c9f1353942d > Fixes: ba81523eaac3 ("bcachefs: Split out bkey_types.h") > Link: https://lore.kernel.org/all/00000000000025321f061d7b6...@google.com/T/ > > Signed-off-by: zhanghao <zhangh...@kylinos.cn> > --- > fs/bcachefs/bkey_types.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/bcachefs/bkey_types.h b/fs/bcachefs/bkey_types.h > index c9ae9e42b385..60fa5af93032 100644 > --- a/fs/bcachefs/bkey_types.h > +++ b/fs/bcachefs/bkey_types.h > @@ -21,6 +21,8 @@ static inline struct bkey_i *bkey_next(struct bkey_i *k) > > static inline size_t bkey_val_bytes(const struct bkey *k) > { > + if (k->u64s < BKEY_U64s) > + return 0; > return bkey_val_u64s(k) * sizeof(u64); > } > > > base-commit: d74da846046aeec9333e802f5918bd3261fb5509 > prerequisite-patch-id: 1ec511753fc7aab35ba0e982013cf91ba4403da6 > -- > 2.39.2 >