bcachefs: Fix stack oob in __bch2_encrypt_bio()

Reported-by: syzbot+fff6b0fb00259873576a@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-05-20 03:13:57 -04:00
parent 70dd062e27
commit 2ba24864d2

View File

@ -352,8 +352,12 @@ int __bch2_encrypt_bio(struct bch_fs *c, unsigned type,
bytes += bv.bv_len;
}
sg_mark_end(sg - 1);
return do_encrypt_sg(c->chacha20, nonce, sgl, bytes);
if (sg != sgl) {
sg_mark_end(sg - 1);
return do_encrypt_sg(c->chacha20, nonce, sgl, bytes);
}
return ret;
}
struct bch_csum bch2_checksum_merge(unsigned type, struct bch_csum a,