Skip to content

Commit 543fbac

Browse files
herbertxopsiff
authored andcommitted
crypto: af_alg - Fix page reassignment overflow in af_alg_pull_tsgl
commit 31d00156e50ecad37f2cb6cbf04aaa9a260505ef upstream. When page reassignment was added to af_alg_pull_tsgl the original loop wasn't updated so it may try to reassign one more page than necessary. Add the check to the reassignment so that this does not happen. Also update the comment which still refers to the obsolete offset argument. Reported-by: syzbot+d23888375c2737c17ba5@syzkaller.appspotmail.com Fixes: e870456 ("crypto: algif_skcipher - overhaul memory management") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 56ab3cf commit 543fbac

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crypto/af_alg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst)
704704
* Assumption: caller created af_alg_count_tsgl(len)
705705
* SG entries in dst.
706706
*/
707-
if (dst) {
708-
/* reassign page to dst after offset */
707+
if (dst && plen) {
708+
/* reassign page to dst */
709709
get_page(page);
710710
sg_set_page(dst + j, page, plen, sg[i].offset);
711711
j++;

0 commit comments

Comments
 (0)