diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-23 01:14:08 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-23 01:14:36 +0200 |
commit | 2195b755ebd23992c5758d2d02a8080eac2baeca (patch) | |
tree | 9ee5559ebe4e4337f93b56925262981411fe50e4 /fs/bcachefs/dirent.c | |
parent | bcachefs: Fix stack oob in __bch2_encrypt_bio() (diff) | |
download | linux-2195b755ebd23992c5758d2d02a8080eac2baeca.tar.xz linux-2195b755ebd23992c5758d2d02a8080eac2baeca.zip |
bcachefs: Fix unsafety in bch2_dirent_name_bytes()
Reported-by: syzbot+84fa6fb8c7f98b93cdea@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/dirent.c')
-rw-r--r-- | fs/bcachefs/dirent.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index 6bbf9a7d9e4d..c67460d8205d 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -15,6 +15,9 @@ 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_bytes = bkey_u64s * sizeof(u64); u64 last_u64 = ((u64*)d.v)[bkey_u64s - 1]; |