Commit 2195b755 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix unsafety in bch2_dirent_name_bytes()

Reported-by: syzbot+84fa6fb8c7f98b93cdea@syzkaller.appspotmail.com
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2ba24864
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
static unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent d) static unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent d)
{ {
if (bkey_val_bytes(d.k) < offsetof(struct bch_dirent, d_name))
return 0;
unsigned bkey_u64s = bkey_val_u64s(d.k); unsigned bkey_u64s = bkey_val_u64s(d.k);
unsigned bkey_bytes = bkey_u64s * sizeof(u64); unsigned bkey_bytes = bkey_u64s * sizeof(u64);
u64 last_u64 = ((u64*)d.v)[bkey_u64s - 1]; u64 last_u64 = ((u64*)d.v)[bkey_u64s - 1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment