From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
Eric Dumazet <edumazet@google.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
Stephan Mueller <smueller@chronox.de>,
Herbert Xu <herbert@gondor.apana.org.au>
Subject: [PATCH net 1/8] crypto: af_alg - fix possible uninit-value in alg_bind()
Date: Sat, 7 Apr 2018 13:42:36 -0700 [thread overview]
Message-ID: <20180407204243.176626-2-edumazet@google.com> (raw)
In-Reply-To: <20180407204243.176626-1-edumazet@google.com>
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>
---
crypto/af_alg.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index c49766b03165ce095d218b09f0e22e7765e05388..7846c0c20cfec1998674e18e0a516a89caea509f 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;
--
2.17.0.484.g0c8726318c-goog
next prev parent reply other threads:[~2018-04-07 20:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-07 20:42 [PATCH net 0/8] net: fix uninit-values in networking stack Eric Dumazet
2018-04-07 20:42 ` Eric Dumazet [this message]
2018-04-07 20:42 ` [PATCH net 2/8] netlink: fix uninit-value in netlink_sendmsg Eric Dumazet
2018-04-07 20:42 ` [PATCH net 3/8] net: fix rtnh_ok() Eric Dumazet
2018-04-07 20:42 ` [PATCH net 4/8] net: initialize skb->peeked when cloning Eric Dumazet
2018-04-07 20:42 ` [PATCH net 5/8] net: fix uninit-value in __hw_addr_add_ex() Eric Dumazet
2018-04-07 20:42 ` [PATCH net 6/8] dccp: initialize ireq->ir_mark Eric Dumazet
2018-04-07 20:42 ` [PATCH net 7/8] ipv4: fix uninit-value in ip_route_output_key_hash_rcu() Eric Dumazet
2018-04-07 20:42 ` [PATCH net 8/8] soreuseport: initialise timewait reuseport field Eric Dumazet
2018-04-08 2:40 ` [PATCH net 0/8] net: fix uninit-values in networking stack David Miller
2018-04-08 16:38 ` Eric Dumazet
2018-04-08 16:49 ` David Miller
2018-04-08 16:55 ` Eric Dumazet
2018-04-08 21:18 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180407204243.176626-2-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=smueller@chronox.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).