From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net-next] net: ip6_gre: get ipv6hdr after skb_cow_head() Date: Mon, 16 Jul 2018 13:40:33 -0700 (PDT) Message-ID: <20180716.134033.1692048780587026378.davem@davemloft.net> References: <20180713054050.5656-1-bhole_prashant_q7@lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, u9012063@gmail.com, netdev@vger.kernel.org To: bhole_prashant_q7@lab.ntt.co.jp Return-path: Received: from shards.monkeyblade.net ([23.128.96.9]:59774 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728412AbeGPVJj (ORCPT ); Mon, 16 Jul 2018 17:09:39 -0400 In-Reply-To: <20180713054050.5656-1-bhole_prashant_q7@lab.ntt.co.jp> Sender: netdev-owner@vger.kernel.org List-ID: From: Prashant Bhole Date: Fri, 13 Jul 2018 14:40:50 +0900 > A KASAN:use-after-free bug was found related to ip6-erspan > while running selftests/net/ip6_gre_headroom.sh > > It happens because of following sequence: > - ipv6hdr pointer is obtained from skb > - skb_cow_head() is called, skb->head memory is reallocated > - old data is accessed using ipv6hdr pointer > > skb_cow_head() call was added in e41c7c68ea77 ("ip6erspan: make sure > enough headroom at xmit."), but looking at the history there was a > chance of similar bug because gre_handle_offloads() and pskb_trim() > can also reallocate skb->head memory. Fixes tag points to commit > which introduced possibility of this bug. > > This patch moves ipv6hdr pointer assignment after skb_cow_head() call. > > Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") > Signed-off-by: Prashant Bhole This bug goes back to 4.16, therefore applied to 'net' and queued up for -stable. Please do not submit bug fixes against 'net-next' in this situation in the future. Thanks.