Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1194168ybn; Wed, 2 Oct 2019 12:14:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBqG/LCICON62zU4oLtIqebGcurX2RCtI3yBDnvOrFw88XiveN6o5LZ9ASl5Q9BJ7KGFWG X-Received: by 2002:aa7:d9d5:: with SMTP id v21mr5571105eds.106.1570043677647; Wed, 02 Oct 2019 12:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043677; cv=none; d=google.com; s=arc-20160816; b=kDQsC2DLeLO5Ey/Iz8YYIuqLrjcIFxz9F/k83F0d57EGdm6f+iiXa1JU27z+J1Xt9G xPyLofvopes3Tgd1+G4ZLhdsnNbEnqU/9qkakqGdUU0mPbUQjWOFwnu821Z8cIbcI9LW lC+jqCLaqyY6ZaVRbp4+r7pfNVLUeZp/DLjeM10MWxwd3ZZ3Gffsz1YkoHpzNCjemoK4 zvUHpvsPnSooQvbpy4nyokNtS4e4eCUjTSEtr3ehEEYtQ0oOSbL2J/3J67LJlorDWDiz QwxIUmQbagPRMbpHMpFpYg42s2p2UyOESCaZOXecsSZ3PZ89dp7KZcDUyK06sa4++JrE 4bGQ== 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; bh=ZB0zoWxKKNYfzlLRvjGDou4v0ZhBZy33nZ7+A5KTa3A=; b=j4NlJkZJ/BhsSIKRyxvhTTdF7BWqKtcTh4T2nmTpKsc0NXQQEIHsbuI84y2NZTFw3w ihF8nXIm2bI+qj+/uvGN15nbQLrb0niPQx7RrQgnk+O+rnbM//VPV8FgpoQjdI/V4++q XbA0+CRzX9Gk4pdwVRbwMioVhsOcQq533mKlAaU6Tcs018K2BjLxm/CjIz4JSRYj2dKg Fkm0ZZ3ccruFmm3E7ULQ8jcFD76zvKJbcwwbhV5MbqyAbfgt4yusAOiW55epbEnoVzBi zU6TlsrqB+ZvyajMpVvIEUWuZ0i4yXVG6qxeQqD0n8k91xUNmiVR6+gE7CJfKL3XVKRb Mvwg== 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 f45si19912eda.345.2019.10.02.12.14.13; Wed, 02 Oct 2019 12:14:37 -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 S1730150AbfJBTM6 (ORCPT + 99 others); Wed, 2 Oct 2019 15:12:58 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35384 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729098AbfJBTIK (ORCPT ); Wed, 2 Oct 2019 15:08:10 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyo-00036H-Vy; Wed, 02 Oct 2019 20:08:07 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyo-0003d5-5L; Wed, 02 Oct 2019 20:08:06 +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, Denis Kirjanov , "David S. Miller" , "syzbot" , "Eric Dumazet" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 40/87] net-gro: fix use-after-free read in napi_gro_frags() In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 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.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit a4270d6795b0580287453ea55974d948393e66ef upstream. If a network driver provides to napi_gro_frags() an skb with a page fragment of exactly 14 bytes, the call to gro_pull_from_frag0() will 'consume' the fragment by calling skb_frag_unref(skb, 0), and the page might be freed and reused. Reading eth->h_proto at the end of napi_frags_skb() might read mangled data, or crash under specific debugging features. BUG: KASAN: use-after-free in napi_frags_skb net/core/dev.c:5833 [inline] BUG: KASAN: use-after-free in napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841 Read of size 2 at addr ffff88809366840c by task syz-executor599/8957 CPU: 1 PID: 8957 Comm: syz-executor599 Not tainted 5.2.0-rc1+ #32 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x172/0x1f0 lib/dump_stack.c:113 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:188 __kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317 kasan_report+0x12/0x20 mm/kasan/common.c:614 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/generic_report.c:142 napi_frags_skb net/core/dev.c:5833 [inline] napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841 tun_get_user+0x2f3c/0x3ff0 drivers/net/tun.c:1991 tun_chr_write_iter+0xbd/0x156 drivers/net/tun.c:2037 call_write_iter include/linux/fs.h:1872 [inline] do_iter_readv_writev+0x5f8/0x8f0 fs/read_write.c:693 do_iter_write fs/read_write.c:970 [inline] do_iter_write+0x184/0x610 fs/read_write.c:951 vfs_writev+0x1b3/0x2f0 fs/read_write.c:1015 do_writev+0x15b/0x330 fs/read_write.c:1058 Fixes: a50e233c50db ("net-gro: restore frag0 optimization") Signed-off-by: Eric Dumazet 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 @@ -4239,7 +4239,6 @@ static struct sk_buff *napi_frags_skb(st skb_reset_mac_header(skb); skb_gro_reset_offset(skb); - eth = skb_gro_header_fast(skb, 0); if (unlikely(skb_gro_header_hard(skb, hlen))) { eth = skb_gro_header_slow(skb, hlen, 0); if (unlikely(!eth)) { @@ -4247,6 +4246,7 @@ static struct sk_buff *napi_frags_skb(st return NULL; } } else { + eth = (const struct ethhdr *)skb->data; gro_pull_from_frag0(skb, hlen); NAPI_GRO_CB(skb)->frag0 += hlen; NAPI_GRO_CB(skb)->frag0_len -= hlen;