diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-20 03:13:57 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-22 19:01:17 -0400 |
commit | 2ba24864d2f61b52210ba645ee5af1d0422a7ea9 (patch) | |
tree | eba93e99ffddc7639eb8f7f9a29599db93d1d54a /fs | |
parent | 70dd062e27e679247cd8828c23c0e12728de5465 (diff) | |
download | lwn-2ba24864d2f61b52210ba645ee5af1d0422a7ea9.tar.gz lwn-2ba24864d2f61b52210ba645ee5af1d0422a7ea9.zip |
bcachefs: Fix stack oob in __bch2_encrypt_bio()
Reported-by: syzbot+fff6b0fb00259873576a@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/checksum.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c index 4b3d6f0137f6..3bd3aba90d8f 100644 --- a/fs/bcachefs/checksum.c +++ b/fs/bcachefs/checksum.c @@ -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, |