Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2281887ybb; Sat, 30 Mar 2019 00:58:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLkFIw29ODcxPzZT5tiSs77cV9iyJfz7IG8+V+gkCuSBka8fXCH0DxuOMLeaG2YfRQdRQa X-Received: by 2002:a17:902:2865:: with SMTP id e92mr54059476plb.312.1553932736040; Sat, 30 Mar 2019 00:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553932736; cv=none; d=google.com; s=arc-20160816; b=JLfUfC4Rc4ud0pjhvEmbntlILYbgtruYWLxj6FxvXkeR31RZuOr5r7i/4prelYDi4j vu8KmPdEAys28qFPzD+BBrcxVPUePYKK1ila0qT8YABdQa5gJ11uCPdcLO9cFBr4iyMV Cd6RvS7/C8Dzg+nENNxMyZAAM8foKe/QkbvtvUDqY9+wO5qrJOs8/EbTIn+4jXm+uph1 VvwqpnKc7T2aL0dsZJN2TysZt6sMORCm0m5nnofGqD+yWmJrgyPg4Eg2VtJbwJ7sfbN/ iGAWYb4SWXMz/bCzF6hacSA8RCLS1N3uhiZIDugz7l2uC5jO/VDxEwz3+H02DwRqGyRA LzDA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=cCZI3GRmOYbCqRvIGi3XJe8r+zVw9MkB0uujbMoC2iU=; b=pvIaRRTfEHo0312YtDMOhrJaVL/Z4QRj0342ppIF7PntfCkymqvs10Rym90pLbOTeo mBNqMU003Z4vQSQ3jqFepK9/79HsBKJxJed93tANuO9SOYTVbEXwz1AOmOaEYbI81qQw Fhdx9SKLfqlms86/NNSVq6FDGKT9QAnLd0ztLJj9J7aiOFcTlIOj6NOFjtr14Gwytrut gIOUIvfz2oO+pijtBDtedQpU+e/c3yw2nM+syhqMSi/BC/Tvf+YF5QM18H3zhXZ7MRgR o4yiwdXxtAJMBY200HdWGqUS8dBBxtRGfpJtMnCqJt2g+XYd8YcMr9J3uplnZUZSMyis t5JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TWDfwo1q; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33si4004340pld.27.2019.03.30.00.58.38; Sat, 30 Mar 2019 00:58:56 -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=@gmail.com header.s=20161025 header.b=TWDfwo1q; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730388AbfC3H6B (ORCPT + 99 others); Sat, 30 Mar 2019 03:58:01 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52070 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbfC3H6A (ORCPT ); Sat, 30 Mar 2019 03:58:00 -0400 Received: by mail-wm1-f65.google.com with SMTP id 4so4780432wmf.1; Sat, 30 Mar 2019 00:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cCZI3GRmOYbCqRvIGi3XJe8r+zVw9MkB0uujbMoC2iU=; b=TWDfwo1qd0lNl8srnZdAhSqwVQPLNfD9kjFKljiRdJNP5QwuNVomgP+Ha0WigZ6FBY 9PSIChWYARlnCElR87DkLi7DwvllVHwSR6E52RlG1+17hQPfnSOkPKb6lL5LdMbBeWe0 ufl1jDvLm3M+M6efUxeeQdEooxnYVkXLDvedTonHsLRK5kT7tgVJnTPlvQXeKJrhduzT i4LCGGKNwrA0qwyTIr8zkqjV16dFP5brDGUxh4ZIsJ6lTZwKMIrLqjcOKZar9Kmv+9sc 2U/kT9+rfx5UYoY0XH0cAU00BOsSHtPreHcatEqzM1ERluDUXeemUL8ytWDlkV4EJ3Vq wsgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cCZI3GRmOYbCqRvIGi3XJe8r+zVw9MkB0uujbMoC2iU=; b=tY2AXrxfxOY2q1tZsFPzHLCvOwvTCdemyyhMxQ2b01O1au5ZAp5jGNwmZRMOSqXh0z l9IumhcC9U4Qljb4gPYCXs6j7q5qYzcGmiFAgTVI6SqznTV5DuIN4481TaIqj+T1GQlC nxLaIxPH4T8nBNiE+TZ/OSoOqNmETRHp0cNKPdNfRZA03ejBwRIxtm5mLZiWBBExGO5w 0Bz7BeAhdMMBFaLVYBiF/NOUjGyqyxhgRdBEMjctzqF/E7wqIrhoOAWQMvMTfzdGwD7m MzRTDRrhmBunsHXKTIMsd0d1l1xztDu9fTFIgvCOZtm4yH3NmiMRvXoNI0hFGRax79VF yxEg== X-Gm-Message-State: APjAAAUZdboTMU5JWRrxHI2rRN5j7b5IE3reJucZIfo3LBZyx+IqBsdY y1gi8SwiWKeY1DTjrJ4z4sk= X-Received: by 2002:a1c:208c:: with SMTP id g134mr437732wmg.70.1553932678876; Sat, 30 Mar 2019 00:57:58 -0700 (PDT) Received: from [192.168.8.147] (58.85.136.77.rev.sfr.net. [77.136.85.58]) by smtp.gmail.com with ESMTPSA id v16sm8545787wro.48.2019.03.30.00.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 00:57:58 -0700 (PDT) Subject: Re: [PATCH net] ipv6: Fix dangling pointer when ipv6 fragment From: Eric Dumazet To: hujunwei , davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: mingfangsen@huawei.com, liuzhiqiang26@huawei.com, zhangwenhao8@huawei.com References: Message-ID: Date: Sat, 30 Mar 2019 00:57:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/30/2019 12:48 AM, Eric Dumazet wrote: > > > On 03/30/2019 12:29 AM, hujunwei wrote: >> From: Junwei Hu >> >> At the beginning of ip6_fragment func, the prevhdr pointer is >> obtained in the ip6_find_1stfragopt func. >> However, all the pointers pointing into skb header may change >> when calling skb_checksum_help func with >> skb->ip_summed = CHECKSUM_PARTIAL condition. >> The prevhdr pointe will be dangling if it is not reloaded after >> calling __skb_linearize func in skb_checksum_help func. >> >> Here, I add a variable, nexthdr_offset, to evaluate the offset, >> which does not changes even after calling __skb_linearize func. >> ... >> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c >> index edbd12067170..6db3c60b3b66 100644 >> --- a/net/ipv6/ip6_output.c >> +++ b/net/ipv6/ip6_output.c >> @@ -606,12 +606,14 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, >>      __be32 frag_id; >>      int ptr, offset = 0, err = 0; >>      u8 *prevhdr, nexthdr = 0; >> +    u8 nexthdr_offset; Why u8 here ? I would use "unsigned int" really. >>   >>      err = ip6_find_1stfragopt(skb, &prevhdr); >>      if (err < 0) >>          goto fail; >>      hlen = err; >>      nexthdr = *prevhdr; >> +    nexthdr_offset = prevhdr - skb_network_header(skb); >>   >>      mtu = ip6_skb_dst_mtu(skb); >>   >> @@ -646,6 +648,8 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, >>          (err = skb_checksum_help(skb))) >>          goto fail; >>   >> +    prevhdr = skb_network_header(skb) + nexthdr_offset; >> + >>      hroom = LL_RESERVED_SPACE(rt->dst.dev); >>      if (skb_has_frag_list(skb)) { >>          unsigned int first_len = skb_pagelen(skb); >>