Skip to content

Commit 31d0015

Browse files
committed
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: [email protected] Fixes: e870456 ("crypto: algif_skcipher - overhaul memory management") Signed-off-by: Herbert Xu <[email protected]>
1 parent 8eceab1 commit 31d0015

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
@@ -705,8 +705,8 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst)
705705
* Assumption: caller created af_alg_count_tsgl(len)
706706
* SG entries in dst.
707707
*/
708-
if (dst) {
709-
/* reassign page to dst after offset */
708+
if (dst && plen) {
709+
/* reassign page to dst */
710710
get_page(page);
711711
sg_set_page(dst + j, page, plen, sg[i].offset);
712712
j++;

0 commit comments

Comments
 (0)