diff options
author | Eric Dumazet <edumazet@google.com> | 2018-04-07 16:42:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-07 22:32:31 -0400 |
commit | a466856e0b7ab269cdf9461886d007e88ff575b0 (patch) | |
tree | e21908fe4aab1743d2da862b976bfec09b371d22 | |
parent | f12c643209db0626f2f54780d86bb93bfa7a9c2d (diff) |
crypto: af_alg - fix possible uninit-value in alg_bind()
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>
-rw-r--r-- | crypto/af_alg.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index c49766b03165..7846c0c20cfe 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) | |||
158 | void *private; | 158 | void *private; |
159 | int err; | 159 | int err; |
160 | 160 | ||
161 | /* If caller uses non-allowed flag, return error. */ | ||
162 | if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed)) | ||
163 | return -EINVAL; | ||
164 | |||
165 | if (sock->state == SS_CONNECTED) | 161 | if (sock->state == SS_CONNECTED) |
166 | return -EINVAL; | 162 | return -EINVAL; |
167 | 163 | ||
168 | if (addr_len < sizeof(*sa)) | 164 | if (addr_len < sizeof(*sa)) |
169 | return -EINVAL; | 165 | return -EINVAL; |
170 | 166 | ||
167 | /* If caller uses non-allowed flag, return error. */ | ||
168 | if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed)) | ||
169 | return -EINVAL; | ||
170 | |||
171 | sa->salg_type[sizeof(sa->salg_type) - 1] = 0; | 171 | sa->salg_type[sizeof(sa->salg_type) - 1] = 0; |
172 | sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0; | 172 | sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0; |
173 | 173 | ||