From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH net 1/8] crypto: af_alg - fix possible uninit-value in alg_bind() Date: Sat, 7 Apr 2018 13:42:36 -0700 Message-ID: <20180407204243.176626-2-edumazet@google.com> References: <20180407204243.176626-1-edumazet@google.com> Cc: netdev , Eric Dumazet , Eric Dumazet , Stephan Mueller , Herbert Xu To: "David S . Miller" Return-path: Received: from mail-pl0-f65.google.com ([209.85.160.65]:40791 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752764AbeDGUnZ (ORCPT ); Sat, 7 Apr 2018 16:43:25 -0400 Received: by mail-pl0-f65.google.com with SMTP id x4-v6so2715970pln.7 for ; Sat, 07 Apr 2018 13:43:25 -0700 (PDT) In-Reply-To: <20180407204243.176626-1-edumazet@google.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 Reported-by: syzbot Cc: Stephan Mueller Cc: Herbert Xu --- 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