Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp266643img; Mon, 18 Mar 2019 02:38:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbz9DCSLLyuDCU6A8BbztYihmtJK64zPIN7JpuhSwQuA7XDqHU5wGKpcp0S3ijAqQS3Lpo X-Received: by 2002:aa7:81ce:: with SMTP id c14mr17813708pfn.51.1552901934250; Mon, 18 Mar 2019 02:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901934; cv=none; d=google.com; s=arc-20160816; b=ISjB5KnHZPLdxmk02EgY2RmcW8B9KzGs8pUW8XwvC41mS+XJd4bB4Q6rNPrAESL/AW rupEeoeYIH01wggNnRFZKEjJ2SCMLG0Al2P2FZTAr0wsA/Z9qtmVV07SFCBLX4xtLdAK GbICF1lMmEyk6ktkzrHmSVwTkGuTHgpXJei1aOEAJpqo6OT+g9jzFyMn579ecD8zGH74 +IGj+Fhmk1jLO5NGsqcqKAqBbN8VSEoRXWg1Du3iXWwxP9MWt5RQE1DXpS5/7rcmQ9Wl e4C0JmCxoDGGpSIp9Y2woTFxm8fmoleH6fvrh8rgrEp0IcmmvvHUKLvwOZ7R1u2S/ZZa ZsTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pkrqjJoju6fExJu/E4bwfk5ucbM5HgNCAMKR8Sf0UEY=; b=z7vTfKZd/PiUzei5eS/89PF0qUnGUEQt984xCxREVAuCKEklXoVvY7nRV36Kl/SEv1 vy2f/K0B8aHLKWT8JKnrq4Q3Nta+PpzbNEun2gHBdIZyLpDOSV3EWpapm8VSgk6GInKC Z6qwvk9eoXBVZGfy+hVO3f0DmY56AD4a76Ei9MhYUJ+ljxy4sXXK7KV1OuoHOFtgqTre 52qMQPK5MqDe5YQouep5OubcLsHU5a1gsQdloclRe42M7hPi1IEmBgi+0h+lnKCJymxJ jkrO2rcJusKMt/mftgfIBxfoezL1F5VwLsjrS4ZKZiRES0gjIEBxtA81pv4QstiQGVjI POcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Xp6ddJEY; 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 r6si8591008plo.269.2019.03.18.02.38.39; Mon, 18 Mar 2019 02:38:54 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Xp6ddJEY; 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 S2387861AbfCRJha (ORCPT + 99 others); Mon, 18 Mar 2019 05:37:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:45774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbfCRJh2 (ORCPT ); Mon, 18 Mar 2019 05:37:28 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A69C8214D8; Mon, 18 Mar 2019 09:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901847; bh=e1BSfuc4ygd+PGjXiupiK5wYAxtXKaa9b9UCdJHiiLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xp6ddJEYYqDftXAm4hTGgLFRosPwtmfJYzZ+EOaApJcYy5CDdAjjmxWI9A4TegGW0 HQdNwULf3Hmuk3TyTpt4BOjk5PYQvtMU6AyhXJI8mAL3uWVNGMdOSYB3Rcdwy2Fowq l9/F4sDCqZBDXITuLvlnzsTTzx/WZKpXhp4fUUS4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linmiaohe , "David S. Miller" Subject: [PATCH 4.9 06/31] net: sit: fix UBSAN Undefined behaviour in check_6rd Date: Mon, 18 Mar 2019 10:25:41 +0100 Message-Id: <20190318084210.652631429@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318084210.397476003@linuxfoundation.org> References: <20190318084210.397476003@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miaohe Lin [ Upstream commit a843dc4ebaecd15fca1f4d35a97210f72ea1473b ] In func check_6rd,tunnel->ip6rd.relay_prefixlen may equal to 32,so UBSAN complain about it. UBSAN: Undefined behaviour in net/ipv6/sit.c:781:47 shift exponent 32 is too large for 32-bit type 'unsigned int' CPU: 6 PID: 20036 Comm: syz-executor.0 Not tainted 4.19.27 #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xca/0x13e lib/dump_stack.c:113 ubsan_epilogue+0xe/0x81 lib/ubsan.c:159 __ubsan_handle_shift_out_of_bounds+0x293/0x2e8 lib/ubsan.c:425 check_6rd.constprop.9+0x433/0x4e0 net/ipv6/sit.c:781 try_6rd net/ipv6/sit.c:806 [inline] ipip6_tunnel_xmit net/ipv6/sit.c:866 [inline] sit_tunnel_xmit+0x141c/0x2720 net/ipv6/sit.c:1033 __netdev_start_xmit include/linux/netdevice.h:4300 [inline] netdev_start_xmit include/linux/netdevice.h:4309 [inline] xmit_one net/core/dev.c:3243 [inline] dev_hard_start_xmit+0x17c/0x780 net/core/dev.c:3259 __dev_queue_xmit+0x1656/0x2500 net/core/dev.c:3829 neigh_output include/net/neighbour.h:501 [inline] ip6_finish_output2+0xa36/0x2290 net/ipv6/ip6_output.c:120 ip6_finish_output+0x3e7/0xa20 net/ipv6/ip6_output.c:154 NF_HOOK_COND include/linux/netfilter.h:278 [inline] ip6_output+0x1e2/0x720 net/ipv6/ip6_output.c:171 dst_output include/net/dst.h:444 [inline] ip6_local_out+0x99/0x170 net/ipv6/output_core.c:176 ip6_send_skb+0x9d/0x2f0 net/ipv6/ip6_output.c:1697 ip6_push_pending_frames+0xc0/0x100 net/ipv6/ip6_output.c:1717 rawv6_push_pending_frames net/ipv6/raw.c:616 [inline] rawv6_sendmsg+0x2435/0x3530 net/ipv6/raw.c:946 inet_sendmsg+0xf8/0x5c0 net/ipv4/af_inet.c:798 sock_sendmsg_nosec net/socket.c:621 [inline] sock_sendmsg+0xc8/0x110 net/socket.c:631 ___sys_sendmsg+0x6cf/0x890 net/socket.c:2114 __sys_sendmsg+0xf0/0x1b0 net/socket.c:2152 do_syscall_64+0xc8/0x580 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Signed-off-by: linmiaohe Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/sit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -767,8 +767,9 @@ static bool check_6rd(struct ip_tunnel * pbw0 = tunnel->ip6rd.prefixlen >> 5; pbi0 = tunnel->ip6rd.prefixlen & 0x1f; - d = (ntohl(v6dst->s6_addr32[pbw0]) << pbi0) >> - tunnel->ip6rd.relay_prefixlen; + d = tunnel->ip6rd.relay_prefixlen < 32 ? + (ntohl(v6dst->s6_addr32[pbw0]) << pbi0) >> + tunnel->ip6rd.relay_prefixlen : 0; pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen; if (pbi1 > 0)