Received: by 10.192.165.156 with SMTP id m28csp56371imm; Tue, 10 Apr 2018 16:17:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+4SiWollGt3DrbozVKOIy7U3BEVxZO0gDvrAC+pi9JSbOf1sR88HJfsNxQO7AcNd5ZMXaJ X-Received: by 10.98.228.13 with SMTP id r13mr1347356pfh.51.1523402279514; Tue, 10 Apr 2018 16:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402279; cv=none; d=google.com; s=arc-20160816; b=SOfLoTt3wTMp7yCS6JstFbgX5MDNs8DgdIWg43Sgi0vjcu//1KV9zc+26ypt1c9sZj 7uwtWQ6wCGYPR1EddLcH0so3LITOy2qXn5n0esY9M5yGH5DdYOkmsj9VtyqBPCkpNgUl z7QmVjSGyBjxLjSVIx+l39sZQ/iFk9ZI/n3UHrDBhVoLaneh5xgk2dPNTV0EaTiJJ7r2 /TCUB3+HTjHX5Y+IEgDMt7QvzI0yXVfKw6Ec/1k2ZV80WEgFcU9aVdgi8V1NniU7ZZX5 3RHQntRISO5i7RRbcZbbJsvUNw2PMrdhIdOcPNq1UqP941Y9tzgn+K4p1E6ITGkVCbfA IsAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YExPiThbJ7jZ+ZpH27vMfjtMiLx90fZ8F1/kbgZB00s=; b=QvJfQ8Rj16NO7e40Z2R/YjQrRLc3d223qsDqrIqE2ffScEOpmJd9yqEU2bzEBiVy8G WBmL7OHVgzTGzJHwEwAaiapgpn9iCSR+K1APMUxEZ0U+0N18GeMzvHrKGrZpE71VQF0l egC+zr0/Tk3z4+xsNvePihOcOuc8t4S+8rc/LH/PX9zojsFs+YH7DnJd5oIEN/vJF0fh zCzkOuHIJZQyG665RhyyBj144sF4RaQWZ3VqoVp9Pa6m5P6U/03GtTaV9+oAKCkTZoBX +8gqOAbcwPSbCvvqhJyOlvi6HvMfX+hetYA9ijj5UESQO/GsQ9EKN2Yk8FYeeMFmrWG/ LRwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si2462939pgq.548.2018.04.10.16.17.22; Tue, 10 Apr 2018 16:17:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755791AbeDJXM0 (ORCPT + 99 others); Tue, 10 Apr 2018 19:12:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41006 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755067AbeDJWcl (ORCPT ); Tue, 10 Apr 2018 18:32:41 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CBF398BF; Tue, 10 Apr 2018 22:32:40 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Vlad Yasevich , Neil Horman , syzbot , "David S. Miller" Subject: [PATCH 4.15 135/168] sctp: sctp_sockaddr_af must check minimal addr length for AF_INET6 Date: Wed, 11 Apr 2018 00:24:37 +0200 Message-Id: <20180410212806.798172508@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 81e98370293afcb58340ce8bd71af7b97f925c26 ] Check must happen before call to ipv6_addr_v4mapped() syzbot report was : BUG: KMSAN: uninit-value in sctp_sockaddr_af net/sctp/socket.c:359 [inline] BUG: KMSAN: uninit-value in sctp_do_bind+0x60f/0xdc0 net/sctp/socket.c:384 CPU: 0 PID: 3576 Comm: syzkaller968804 Not tainted 4.16.0+ #82 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x185/0x1d0 lib/dump_stack.c:53 kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067 __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:676 sctp_sockaddr_af net/sctp/socket.c:359 [inline] sctp_do_bind+0x60f/0xdc0 net/sctp/socket.c:384 sctp_bind+0x149/0x190 net/sctp/socket.c:332 inet6_bind+0x1fd/0x1820 net/ipv6/af_inet6.c:293 SYSC_bind+0x3f2/0x4b0 net/socket.c:1474 SyS_bind+0x54/0x80 net/socket.c:1460 do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 RIP: 0033:0x43fd49 RSP: 002b:00007ffe99df3d28 EFLAGS: 00000213 ORIG_RAX: 0000000000000031 RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043fd49 RDX: 0000000000000010 RSI: 0000000020000000 RDI: 0000000000000003 RBP: 00000000006ca018 R08: 00000000004002c8 R09: 00000000004002c8 R10: 00000000004002c8 R11: 0000000000000213 R12: 0000000000401670 R13: 0000000000401700 R14: 0000000000000000 R15: 0000000000000000 Local variable description: ----address@SYSC_bind Variable was created at: SYSC_bind+0x6f/0x4b0 net/socket.c:1461 SyS_bind+0x54/0x80 net/socket.c:1460 Signed-off-by: Eric Dumazet Cc: Vlad Yasevich Cc: Neil Horman Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/socket.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -338,11 +338,14 @@ static struct sctp_af *sctp_sockaddr_af( if (!opt->pf->af_supported(addr->sa.sa_family, opt)) return NULL; - /* V4 mapped address are really of AF_INET family */ - if (addr->sa.sa_family == AF_INET6 && - ipv6_addr_v4mapped(&addr->v6.sin6_addr) && - !opt->pf->af_supported(AF_INET, opt)) - return NULL; + if (addr->sa.sa_family == AF_INET6) { + if (len < SIN6_LEN_RFC2133) + return NULL; + /* V4 mapped address are really of AF_INET family */ + if (ipv6_addr_v4mapped(&addr->v6.sin6_addr) && + !opt->pf->af_supported(AF_INET, opt)) + return NULL; + } /* If we get this far, af is valid. */ af = sctp_get_af_specific(addr->sa.sa_family);