From mboxrd@z Thu Jan 1 00:00:00 1970 From: William Tu Subject: Re: [PATCH net-next] net: ip6_gre: get ipv6hdr after skb_cow_head() Date: Fri, 13 Jul 2018 15:39:43 -0700 Message-ID: References: <20180713054050.5656-1-bhole_prashant_q7@lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Linux Kernel Network Developers To: Prashant Bhole Return-path: Received: from mail-qt0-f195.google.com ([209.85.216.195]:39159 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbeGMW5C (ORCPT ); Fri, 13 Jul 2018 18:57:02 -0400 Received: by mail-qt0-f195.google.com with SMTP id q12-v6so28485362qtp.6 for ; Fri, 13 Jul 2018 15:40:24 -0700 (PDT) In-Reply-To: <20180713054050.5656-1-bhole_prashant_q7@lab.ntt.co.jp> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, Jul 12, 2018 at 10:40 PM, Prashant Bhole wrote: > 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 > --- Thanks for the fix. Acked-by: William Tu