Skip to content

Commit 6241b9e

Browse files
herbertxgregkh
authored andcommitted
crypto: af_alg - Set merge to zero early in af_alg_sendmsg
[ Upstream commit 9574b23 ] If an error causes af_alg_sendmsg to abort, ctx->merge may contain a garbage value from the previous loop. This may then trigger a crash on the next entry into af_alg_sendmsg when it attempts to do a merge that can't be done. Fix this by setting ctx->merge to zero near the start of the loop. Fixes: 8ff5909 ("crypto: algif_skcipher - User-space interface for skcipher operations") Reported-by: Muhammad Alifa Ramdhan <[email protected]> Reported-by: Bing-Jhong Billy Jheng <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5656687 commit 6241b9e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crypto/af_alg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,8 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
908908
continue;
909909
}
910910

911+
ctx->merge = 0;
912+
911913
if (!af_alg_writable(sk)) {
912914
err = af_alg_wait_for_wmem(sk, msg->msg_flags);
913915
if (err)

0 commit comments

Comments
 (0)