Skip to content

Commit 2ba2486

Browse files
author
Kent Overstreet
committed
bcachefs: Fix stack oob in __bch2_encrypt_bio()
Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 70dd062 commit 2ba2486

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/bcachefs/checksum.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,12 @@ int __bch2_encrypt_bio(struct bch_fs *c, unsigned type,
352352
bytes += bv.bv_len;
353353
}
354354

355-
sg_mark_end(sg - 1);
356-
return do_encrypt_sg(c->chacha20, nonce, sgl, bytes);
355+
if (sg != sgl) {
356+
sg_mark_end(sg - 1);
357+
return do_encrypt_sg(c->chacha20, nonce, sgl, bytes);
358+
}
359+
360+
return ret;
357361
}
358362

359363
struct bch_csum bch2_checksum_merge(unsigned type, struct bch_csum a,

0 commit comments

Comments
 (0)