Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp331221ybi; Fri, 7 Jun 2019 08:45:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWOvUg64icJ0QhhV2WZ58SOSwqRg9RRak6gIOVaa5bYJMoEIcmFGmr2Z5asUre2KNVqQwf X-Received: by 2002:a63:eb0d:: with SMTP id t13mr3462154pgh.37.1559922327750; Fri, 07 Jun 2019 08:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559922327; cv=none; d=google.com; s=arc-20160816; b=OCrlXr8ulqPPFVx6V4tCGppHxqEXQxgpB5UFM4XSbORkjeryRoPN5n9zCI8OT2pfPW qkY8z8+RhVPJXi1fFD5V5biZIkn8eanwrOMG/mc+eb+7UNNefpUe8xmyGnnq0cvWTsed MtJGe1lYwmFwHy8F93XYe0fSOcGxzSQ+dhFRDW0saU4o1MA+fjdzcpKN+XhIMvRgktBN hsyNglah+KjRU9DhCPysi56/z3lmOg+seUckWk7VqiiLMaasv6AV8Tih4/z6afYv5ijd KA7RTA5U3dt7fxn/XaE6GA0LWVn6GlLbHaqxQvCz0Zat0nW6Px5vljc267Kfu1ttY7u4 IYsQ== 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=ALGZQov/FSFvBtPMCt206k5RKQ4Wez56AmUS+o/DEX0=; b=hm6leeA8PhihS6ksJ6RJ4Ls0xG/vh8ofUwWn1r5cbU7OmEcpLb/l6XSGT4Zy21QSuL R32QNzHzxhf8Kd7PmqAM+6h6QoYMaTvBRj4j7UOM8oPragOSc1QV+oHROVjVuHfIEdp9 fcO2+9fkiMu72qQBUS2260D/8XBZfkz2DkYzy0S13pudB6ah4trdur91wJMq3IqjrXL3 Zy6DJJ0jrP7gBKnQnvAXTdBum/99X+f5hkEbNheJVWpQH3lbWUmwQsH3iW1CRr2SWEOx Rkzx15JFiqpy5BoiAhAQS5dCuE1Uo9o7w/08F5Xq6tRPaJSSYVrYzAiHL0O/h68MKEJZ aWug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BHcR9id+; 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 l23si2063380pff.2.2019.06.07.08.45.10; Fri, 07 Jun 2019 08:45:27 -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=BHcR9id+; 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 S1730202AbfFGPlE (ORCPT + 99 others); Fri, 7 Jun 2019 11:41:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:50554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729783AbfFGPlB (ORCPT ); Fri, 7 Jun 2019 11:41:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 F1AD42146F; Fri, 7 Jun 2019 15:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559922060; bh=oYudx6GRFL5to2nlzf9auCcRhrsv3IIMd6j94J16tRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHcR9id+CLoVYDP38tzixSGZTQ7R9RM5+43j1KdgmA9yTGMnYPtezlhB37t8qbDkA tK8gvOyzOcdjEQstWzHy3WNBVvsMpPw3lVC5Fc7YRB4IfjZU7j9pqzp0LaKD1kiWvu 7o4P8ZJLtYap59y7RVXS3xt7mHQ4SpAhd0dlEcKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , "David S. Miller" Subject: [PATCH 4.14 05/69] net-gro: fix use-after-free read in napi_gro_frags() Date: Fri, 7 Jun 2019 17:38:46 +0200 Message-Id: <20190607153848.925279853@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607153848.271562617@linuxfoundation.org> References: <20190607153848.271562617@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Eric Dumazet [ Upstream commit a4270d6795b0580287453ea55974d948393e66ef ] 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: Greg Kroah-Hartman --- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5067,7 +5067,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)) { @@ -5077,6 +5076,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;