Commit 31d00156 authored by Herbert Xu's avatar Herbert Xu
Browse files

crypto: af_alg - Fix page reassignment overflow in af_alg_pull_tsgl



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: default avatar <syzbot+d23888375c2737c17ba5@syzkaller.appspotmail.com>
Fixes: e870456d ("crypto: algif_skcipher - overhaul memory management")
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8eceab19
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -705,8 +705,8 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst)
			 * Assumption: caller created af_alg_count_tsgl(len)
			 * SG entries in dst.
			 */
			if (dst) {
				/* reassign page to dst after offset */
			if (dst && plen) {
				/* reassign page to dst */
				get_page(page);
				sg_set_page(dst + j, page, plen, sg[i].offset);
				j++;