Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp217373imm; Thu, 13 Sep 2018 19:17:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ3BT/c3Dv3tYYXQVz2x34sgCAUzAzZBDB/Pxw3p7EKx2RJ35Aso+xU9OQXQ00/2tBQhHza X-Received: by 2002:a63:4d21:: with SMTP id a33-v6mr9523990pgb.408.1536891468525; Thu, 13 Sep 2018 19:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536891468; cv=none; d=google.com; s=arc-20160816; b=ec92OOYVMd/k8mstCrX0fMrUTi1SHJZknenZ8OkRYdonMD7CYhzJr9LNVsKaSY6gaa av5vz9rTN15UaEFywYZaJEoxjvOEdQQ7yR38DppmLXPljBiygZrPVtSxMEJae7ssKb6P q/M/wRVajEkl/nC0oHS4043uzNtkVUqw8Fjlc9+8K36jDgagfTzbMvvFLO/Btn+2iS72 cKMQOHphqcrc5HW0GIf2E+0yDEW4GZLnNMNOzJoIh+6cM38D6wQBEjKR8LYR7back6Hm c8w7hmYNaLyuCHPILJo6EoJvPg3XMoVx+fqPGClxaW9xIfe9Hrc8lm1K3YEORhVQ2R5m N30w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=JgTpSDkgMF/A9piDVpw4tHijoUM7Reahvjg2fXkuzBY=; b=fzw533QQPUgTzlJOYHPGXt+Ia6CEgNYNFyABHBDpLzDtvFjgJO/00Xd4lS+m+kbp2w CrMzQAyFqOzJMJqIfvGlE7KA0VxVTFRzOb5Zfmcr8GQPvxAfLxyXfUJ/9PafFc+KDRnn Goy9P9HyLmINENMd7zguFP9cUokZqUKvM1cY0SO2DFzn4b3mDSm3y2xXu1NuNyYF8bmI j7bArkqsmoh+gJnmL531HJ8JUARASPJzmeAcuqPo3QNmQIbqhF4vASeFuP5v/HtvoDbR fx/GT8s+tgS1fGX/oCarAisJL+QuEuIocnV8Bk+SNefqG7oqv7v8zGYCTn7pa3oIO7ZC P85A== 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 q65-v6si5889380pfb.9.2018.09.13.19.17.22; Thu, 13 Sep 2018 19:17:48 -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 S1728007AbeINHWH convert rfc822-to-8bit (ORCPT + 99 others); Fri, 14 Sep 2018 03:22:07 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:22699 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbeINHWH (ORCPT ); Fri, 14 Sep 2018 03:22:07 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.3]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee75b9b186fb8e-b9c77; Fri, 14 Sep 2018 10:09:51 +0800 (CST) X-RM-TRANSID: 2ee75b9b186fb8e-b9c77 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from [172.16.200.163] (unknown[112.25.154.149]) by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee25b9b186e53a-d75d4; Fri, 14 Sep 2018 10:09:51 +0800 (CST) X-RM-TRANSID: 2ee25b9b186e53a-d75d4 Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH v2,net-next 1/2] ip_gre: fix parsing gre header in ipgre_err From: Haishuang Yan In-Reply-To: <20180913.105840.140151724801067072.davem@davemloft.net> Date: Fri, 14 Sep 2018 10:09:51 +0800 Cc: kuznet@ms2.inr.ac.ru, jbenc@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <1536744082-3568-1-git-send-email-yanhaishuang@cmss.chinamobile.com> <20180913.105840.140151724801067072.davem@davemloft.net> To: David Miller X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 2018??9??14??, at ????1:58, David Miller wrote: > > From: Haishuang Yan > Date: Wed, 12 Sep 2018 17:21:21 +0800 > >> @@ -86,7 +86,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, >> >> options = (__be32 *)(greh + 1); >> if (greh->flags & GRE_CSUM) { >> - if (skb_checksum_simple_validate(skb)) { >> + if (csum_err && skb_checksum_simple_validate(skb)) { >> *csum_err = true; >> return -EINVAL; >> } > > You want to ignore csum errors, but you do not want to elide the side > effects of the skb_checksum_simple_validate() call which are to set > skb->csum_valid and skb->csum. > > Therefore, the skb_checksum_simple_validate() call still needs to be > performed. We just wont return -EINVAL in the NULL csum_err case. > > How about doing like this: --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c @@ -86,13 +86,14 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, options = (__be32 *)(greh + 1); if (greh->flags & GRE_CSUM) { - if (skb_checksum_simple_validate(skb)) { + if (!skb_checksum_simple_validate(skb)) { + skb_checksum_try_convert(skb, IPPROTO_GRE, 0, + null_compute_pseudo); + } else if (csum_err) { *csum_err = true; return -EINVAL; } - skb_checksum_try_convert(skb, IPPROTO_GRE, 0, - null_compute_pseudo); Thanks for reviewing.