summaryrefslogtreecommitdiff
path: root/crypto/af_alg.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2018-04-07 13:42:36 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-16 10:10:23 +0200
commit1b6d0db7ed22902dee6cdbf253eed1fe46294abc (patch)
tree63a0347da02cd46d4c996a2740779793d69d89ad /crypto/af_alg.c
parent19042316b9e12c93bf334a04d4dd7a4e846c7311 (diff)
downloadlinux-exynos-1b6d0db7ed22902dee6cdbf253eed1fe46294abc.tar.gz
linux-exynos-1b6d0db7ed22902dee6cdbf253eed1fe46294abc.tar.bz2
linux-exynos-1b6d0db7ed22902dee6cdbf253eed1fe46294abc.zip
crypto: af_alg - fix possible uninit-value in alg_bind()
commit a466856e0b7ab269cdf9461886d007e88ff575b0 upstream. syzbot reported : BUG: KMSAN: uninit-value in alg_bind+0xe3/0xd90 crypto/af_alg.c:162 We need to check addr_len before dereferencing sa (or uaddr) Fixes: bb30b8848c85 ("crypto: af_alg - whitelist mask and type") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: syzbot <syzkaller@googlegroups.com> Cc: Stephan Mueller <smueller@chronox.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'crypto/af_alg.c')
-rw-r--r--crypto/af_alg.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 4e4640bb82b9..815ee1075574 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -158,16 +158,16 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
void *private;
int err;
- /* If caller uses non-allowed flag, return error. */
- if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed))
- return -EINVAL;
-
if (sock->state == SS_CONNECTED)
return -EINVAL;
if (addr_len < sizeof(*sa))
return -EINVAL;
+ /* If caller uses non-allowed flag, return error. */
+ if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed))
+ return -EINVAL;
+
sa->salg_type[sizeof(sa->salg_type) - 1] = 0;
sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0;