Skip to content

Commit

Permalink
crypto: af_alg - Initialize sg_num_bytes in error code path
Browse files Browse the repository at this point in the history
The RX SGL in processing is already registered with the RX SGL tracking
list to support proper cleanup. The cleanup code path uses the
sg_num_bytes variable which must therefore be always initialized, even
in the error code path.

Signed-off-by: Stephan Mueller <[email protected]>
Reported-by: [email protected]
#syz test: https://github.com/google/kmsan.git master
CC: <[email protected]> #4.14
Fixes: e870456 ("crypto: algif_skcipher - overhaul memory management")
Fixes: d887c52 ("crypto: algif_aead - overhaul memory management")
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
smuellerDD authored and herbertx committed Jul 13, 2018
1 parent 221e00d commit 2546da9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,10 @@ int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags,

/* make one iovec available as scatterlist */
err = af_alg_make_sg(&rsgl->sgl, &msg->msg_iter, seglen);
if (err < 0)
if (err < 0) {
rsgl->sg_num_bytes = 0;
return err;
}

/* chain the new scatterlist with previous one */
if (areq->last_rsgl)
Expand Down

0 comments on commit 2546da9

Please sign in to comment.