Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2221309imm; Thu, 7 Jun 2018 07:17:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJe+4aDLKrW+ZBKTHeF7u6rb8TaR8EUSmVFESXKtqxqtCM9LKIplrfK/6/vbh979QlJac6t X-Received: by 2002:a17:902:224:: with SMTP id 33-v6mr2208020plc.309.1528381022783; Thu, 07 Jun 2018 07:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528381022; cv=none; d=google.com; s=arc-20160816; b=f9F7ZLAyw8v+Ttp68MC5iuDAmQCGKJ/frgbkuPN0RAqSweDyi1OFrxAx9gE3npPZlQ Cdhn+6Pz1Y8dIluJ+jM+aO8cs47YwmTwzszdZfso+QVppG3qKl8qFryeleqP1wq9ZdZE 3djM5yzoORBlgVvkzCJS7QiJmriU7lRBi7KN5B2ix224a/6i9Vh+Wm7fRpsiG72uXqZd LVYePMckTvJNCTNvUxgGAwv1SeZE5NF4LAReFw3+iGK2rqDYfxWjbngp4nQiTKyyGbLA 20HHfgk6LporkgS00Zwv+zBRJshjGDhO5oZCkh9vFo9kMBXxkbGdwjFJfiD5rghQfmCt a6dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=n8l1KN6DJ6im47GVTFU/cENhJZqQzPJU3VqZm4hIcrM=; b=pafXvHcQAtPbG/8sEsj17NK20LnNCo8nbchlIrPpA1AhNB2rHoHcxv8vK72Bc4cIlP T14SWilD5FDRZnxl9uTNjAdin15S4bMz5v1emFWpm+ls3/mC1xDh18qOcjf2KMiuxMIQ BVumm79fI022qQx5XNrH5WVXtkg86+CEdAjGrIuyfRnHHWcGvAdDvjjuqJtu40126Ml0 wrGyYIDJhxvuwxjmlPA/26Y+zLom0DkVRK7oy/h9bkn4JQx2p1tmwyijRA3uE4yW0wpT zQ/v1uoV0UYsMzklttafM6VnMevwHqm+qzljhGPe+CS9LLMxpJ9M5uE47a3mdmP+U1zi gjPg== 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 b1-v6si10793040pgs.125.2018.06.07.07.16.48; Thu, 07 Jun 2018 07:17:02 -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 S933272AbeFGONy (ORCPT + 99 others); Thu, 7 Jun 2018 10:13:54 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39525 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933160AbeFGOJj (ORCPT ); Thu, 7 Jun 2018 10:09:39 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbJ-0005Zp-1L; Thu, 07 Jun 2018 15:09:17 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbF-0003Jy-HQ; Thu, 07 Jun 2018 15:09:13 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David S. Miller" , "Reported-by: syzbot" , "Pravin B Shelar" , "Eric Dumazet" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 404/410] net: fix possible out-of-bound read in skb_network_protocol() In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit 1dfe82ebd7d8fd43dba9948fdfb31f145014baa0 upstream. skb mac header is not necessarily set at the time skb_network_protocol() is called. Use skb->data instead. BUG: KASAN: slab-out-of-bounds in skb_network_protocol+0x46b/0x4b0 net/core/dev.c:2739 Read of size 2 at addr ffff8801b3097a0b by task syz-executor5/14242 CPU: 1 PID: 14242 Comm: syz-executor5 Not tainted 4.16.0-rc6+ #280 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+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23c/0x360 mm/kasan/report.c:412 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:443 skb_network_protocol+0x46b/0x4b0 net/core/dev.c:2739 harmonize_features net/core/dev.c:2924 [inline] netif_skb_features+0x509/0x9b0 net/core/dev.c:3011 validate_xmit_skb+0x81/0xb00 net/core/dev.c:3084 validate_xmit_skb_list+0xbf/0x120 net/core/dev.c:3142 packet_direct_xmit+0x117/0x790 net/packet/af_packet.c:256 packet_snd net/packet/af_packet.c:2944 [inline] packet_sendmsg+0x3aed/0x60b0 net/packet/af_packet.c:2969 sock_sendmsg_nosec net/socket.c:629 [inline] sock_sendmsg+0xca/0x110 net/socket.c:639 ___sys_sendmsg+0x767/0x8b0 net/socket.c:2047 __sys_sendmsg+0xe5/0x210 net/socket.c:2081 Fixes: 19acc327258a ("gso: Handle Trans-Ether-Bridging protocol in skb_network_protocol()") Signed-off-by: Eric Dumazet Cc: Pravin B Shelar Reported-by: Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2336,7 +2336,7 @@ __be16 skb_network_protocol(struct sk_bu if (unlikely(!pskb_may_pull(skb, sizeof(struct ethhdr)))) return 0; - eth = (struct ethhdr *)skb_mac_header(skb); + eth = (struct ethhdr *)skb->data; type = eth->h_proto; }