From patchwork Mon Aug 14 18:43:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 801293 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="M6lKQdSl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xWPd86fBGz9s03 for ; Tue, 15 Aug 2017 04:43:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752113AbdHNSnL (ORCPT ); Mon, 14 Aug 2017 14:43:11 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:35744 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750910AbdHNSnJ (ORCPT ); Mon, 14 Aug 2017 14:43:09 -0400 Received: by mail-wm0-f54.google.com with SMTP id m85so43724785wma.0 for ; Mon, 14 Aug 2017 11:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lqBKV8DpeI8sb9GBYXyz1yHr58O+L5RKGh94/rLUKvk=; b=M6lKQdSl4jyB6gJPpohciXtpAcla1GpR2FeBTJpdIE5gdoNs4Yb/2TeTOxw3ChpFsB 9JKyA0k5PQQn4YxtTem4MU+PysBBr9OoFhcXnyGcwxFsH2tOPcsogpoIQtdShkJbTLzj geJnJtAWGrqrOGn/oUhxhnAEyvCYnHEx2vTMsgZN7/v8l+M0pcWTykbNO7m7Fj1Tq5dK LvIAGVO1YMpRIiQ7g69kgu8epXGXZte3sDQiatFsMnFYupAUpwwKQz8WHz5q7YxLfA7w yCK6Lt3ftEkTSZkpFEmko0+te7qjV3sWNqyGju/eTcFG9ahKXHWvm71wT3dVsqy/+3UY G6Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lqBKV8DpeI8sb9GBYXyz1yHr58O+L5RKGh94/rLUKvk=; b=iRBJOIiA8rNNMYE/KZHg9fHk08QXRpJKSx7YzaaGlDTn05epG6gsoAfJK6YvLs7sqU T9OOvvKqtiz9565g3Zo8rr1tfflCzx0M5MCRjSKnxvATi5a8jMmPigTPtNMqXzanQV65 8vJhGeHUjeyjaL6rmm/92arDjcwMcwoSVIHSF0Xwa/GwAK5WGqWubdMH9THVRQxLFVKP +scNjUgDpZ1D1pFv9JlwgTeWhFLseylKbPN/Ua2V/QUHvtSk1Dow1w9hp/GetPLgB3VG 8Y8kghRd7GXd3TmyW8Z2QOiGF+KyypsKfSEX5PrfEF9dHOMEHCPUyEcWCSl3g0Cp9eL0 V4fg== X-Gm-Message-State: AHYfb5hBxdblM2XStW7Zc+2bI94UYdntvF7xzx3XkF/myKhWN9OBX7rv 3vzyI2XzO1Qnk/aC X-Received: by 10.28.225.139 with SMTP id y133mr4279818wmg.41.1502736187679; Mon, 14 Aug 2017 11:43:07 -0700 (PDT) Received: from glider0.muc.corp.google.com ([100.105.28.21]) by smtp.gmail.com with ESMTPSA id 91sm8523930wrg.83.2017.08.14.11.43.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Aug 2017 11:43:06 -0700 (PDT) From: Alexander Potapenko To: dvyukov@google.com, kcc@google.com, edumazet@google.com, marcelo.leitner@gmail.com, lucien.xin@gmail.com, vyasevich@gmail.com, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2] sctp: fully initialize the IPv6 address in sctp_v6_to_addr() Date: Mon, 14 Aug 2017 20:43:04 +0200 Message-Id: <20170814184304.82747-1-glider@google.com> X-Mailer: git-send-email 2.14.0.434.g98096fd7a8-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org KMSAN reported use of uninitialized sctp_addr->v4.sin_addr.s_addr and sctp_addr->v6.sin6_scope_id in sctp_v6_cmp_addr() (see below). Make sure all fields of an IPv6 address are initialized, which guarantees that the IPv4 fields are also initialized. Acked-by: Marcelo Ricardo Leitner ================================================================== BUG: KMSAN: use of uninitialized memory in sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 CPU: 2 PID: 31056 Comm: syz-executor1 Not tainted 4.11.0-rc5+ #2944 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: dump_stack+0x172/0x1c0 lib/dump_stack.c:42 is_logbuf_locked mm/kmsan/kmsan.c:59 [inline] kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:938 native_save_fl arch/x86/include/asm/irqflags.h:18 [inline] arch_local_save_flags arch/x86/include/asm/irqflags.h:72 [inline] arch_local_irq_save arch/x86/include/asm/irqflags.h:113 [inline] __msan_warning_32+0x61/0xb0 mm/kmsan/kmsan_instr.c:467 sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 sctp_v6_get_dst+0x8c7/0x1630 net/sctp/ipv6.c:290 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 sctp_assoc_add_peer+0x66d/0x16f0 net/sctp/associola.c:651 sctp_sendmsg+0x35a5/0x4f90 net/sctp/socket.c:1871 inet_sendmsg+0x498/0x670 net/ipv4/af_inet.c:762 sock_sendmsg_nosec net/socket.c:633 [inline] sock_sendmsg net/socket.c:643 [inline] SYSC_sendto+0x608/0x710 net/socket.c:1696 SyS_sendto+0x8a/0xb0 net/socket.c:1664 entry_SYSCALL_64_fastpath+0x13/0x94 RIP: 0033:0x44b479 RSP: 002b:00007f6213f21c08 EFLAGS: 00000286 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 0000000020000000 RCX: 000000000044b479 RDX: 0000000000000041 RSI: 0000000020edd000 RDI: 0000000000000006 RBP: 00000000007080a8 R08: 0000000020b85fe4 R09: 000000000000001c R10: 0000000000040005 R11: 0000000000000286 R12: 00000000ffffffff R13: 0000000000003760 R14: 00000000006e5820 R15: 0000000000ff8000 origin description: ----dst_saddr@sctp_v6_get_dst local variable created at: sk_fullsock include/net/sock.h:2321 [inline] inet6_sk include/linux/ipv6.h:309 [inline] sctp_v6_get_dst+0x91/0x1630 net/sctp/ipv6.c:241 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 ================================================================== BUG: KMSAN: use of uninitialized memory in sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 CPU: 2 PID: 31056 Comm: syz-executor1 Not tainted 4.11.0-rc5+ #2944 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: dump_stack+0x172/0x1c0 lib/dump_stack.c:42 is_logbuf_locked mm/kmsan/kmsan.c:59 [inline] kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:938 native_save_fl arch/x86/include/asm/irqflags.h:18 [inline] arch_local_save_flags arch/x86/include/asm/irqflags.h:72 [inline] arch_local_irq_save arch/x86/include/asm/irqflags.h:113 [inline] __msan_warning_32+0x61/0xb0 mm/kmsan/kmsan_instr.c:467 sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 sctp_v6_get_dst+0x8c7/0x1630 net/sctp/ipv6.c:290 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 sctp_assoc_add_peer+0x66d/0x16f0 net/sctp/associola.c:651 sctp_sendmsg+0x35a5/0x4f90 net/sctp/socket.c:1871 inet_sendmsg+0x498/0x670 net/ipv4/af_inet.c:762 sock_sendmsg_nosec net/socket.c:633 [inline] sock_sendmsg net/socket.c:643 [inline] SYSC_sendto+0x608/0x710 net/socket.c:1696 SyS_sendto+0x8a/0xb0 net/socket.c:1664 entry_SYSCALL_64_fastpath+0x13/0x94 RIP: 0033:0x44b479 RSP: 002b:00007f6213f21c08 EFLAGS: 00000286 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 0000000020000000 RCX: 000000000044b479 RDX: 0000000000000041 RSI: 0000000020edd000 RDI: 0000000000000006 RBP: 00000000007080a8 R08: 0000000020b85fe4 R09: 000000000000001c R10: 0000000000040005 R11: 0000000000000286 R12: 00000000ffffffff R13: 0000000000003760 R14: 00000000006e5820 R15: 0000000000ff8000 origin description: ----dst_saddr@sctp_v6_get_dst local variable created at: sk_fullsock include/net/sock.h:2321 [inline] inet6_sk include/linux/ipv6.h:309 [inline] sctp_v6_get_dst+0x91/0x1630 net/sctp/ipv6.c:241 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 ================================================================== Signed-off-by: Alexander Potapenko Reviewed-by: Xin Long --- v2 is identical to v1, resending per request by Marcelo Ricardo Leitner. --- net/sctp/ipv6.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 2a186b201ad2..a15d691829c6 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -513,6 +513,8 @@ static void sctp_v6_to_addr(union sctp_addr *addr, struct in6_addr *saddr, addr->sa.sa_family = AF_INET6; addr->v6.sin6_port = port; addr->v6.sin6_addr = *saddr; + addr->v6.sin6_flowinfo = 0; + addr->v6.sin6_scope_id = 0; } /* Compare addresses exactly.