Skip to content

Commit 2546da9

Browse files
smuellerDDherbertx
authored andcommitted
crypto: af_alg - Initialize sg_num_bytes in error code path
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]>
1 parent 221e00d commit 2546da9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crypto/af_alg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,10 @@ int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags,
11561156

11571157
/* make one iovec available as scatterlist */
11581158
err = af_alg_make_sg(&rsgl->sgl, &msg->msg_iter, seglen);
1159-
if (err < 0)
1159+
if (err < 0) {
1160+
rsgl->sg_num_bytes = 0;
11601161
return err;
1162+
}
11611163

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

0 commit comments

Comments
 (0)