Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp462701yba; Wed, 15 May 2019 04:32:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqijJLh0oOmdaqSlp6SGQGH7FDc6C/moA0K+RT81qcx7q+LJpFusR9jCQ3bxT20sLmI8pr X-Received: by 2002:aa7:9289:: with SMTP id j9mr1709655pfa.251.1557919974845; Wed, 15 May 2019 04:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557919974; cv=none; d=google.com; s=arc-20160816; b=KY2U4TIAUOK4KM/LsH5i4AZdO5Ru+OZHu4AlyiYTCylPLTp42XjXfYJom4MxQGjs3U 9zoXH490AkD5cA56d1vZ3ZkCBMX/ySgR+Pq9QBwS5Gda3qIwOzxLNPHSs5XCwky83n/X XRqSO+lp9UJGeeoIWeaEGUjvsOKEInI1jBlrug77l6heT15nia6fy3qNVoDl67I1eoLO LWGyeLiYy17CxMccR2U1jCLWsBxwUJforNSzs6v8zbkXWhzKKu3gjEx9t/0zalicFmCR 3kr0AETZeIByMoVOKYh7Z0Ix7/p5xjQ4cZIWcR4Z6tts7wNkwjFKYLy8riXFn9PfvhC5 DCZw== 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=10U4AU+CrhcgzC1BaQY5yp41O7pqixSQgUUk2FgX7r4=; b=GCbyAfuKvJdMswIjncaehofPGpPPrKlOz7fMaG2Lak0HzacBAJBj+kPsUVQfpsEBgM cZmEf9912vn8q0MPKzHN7mruIJmYnGDUfbeKh6q6ZxqJIc5XpwMkcd4EMKzgVDEnmVrb AAmxNNe2Kkzc/4DJnEi5BXleo+vkadsQtuVAWqH7hXAWWpR+Tj/UrmFU1emMqSkGcsTN Q13yUZ9U3LPLEruU+WWrR/+f72DRm25biWtborWCn02VpJCGPGTt7MvcCwMMwbgqhPXl CGtHhdtHivZa8mnwq57UNeoIMU4wfomCgaWVZZ/y6+oNW/RQ6TX+4SzJnbcJFgaB5b/a lH8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aw1dyJjv; 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 q3si1901975pfc.89.2019.05.15.04.32.40; Wed, 15 May 2019 04:32:54 -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=aw1dyJjv; 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 S1732662AbfEOLaD (ORCPT + 99 others); Wed, 15 May 2019 07:30:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:41326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732166AbfEOL35 (ORCPT ); Wed, 15 May 2019 07:29:57 -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 763FB20881; Wed, 15 May 2019 11:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919796; bh=ZXfI5rOLK+JAyxi0GMFDARkhQbo+4KCbdDkLOuPMubI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aw1dyJjv57zo79um3izrNAt5cqdy+vvDE8x8lW45zfU/dHVAOOAzoTMpJwGBdTf2K qjl2vUOMSjDJnN8IfBDbVuqk8QUZ8QjidjFM9iCAXiC/5Ixc61y49rBksJNA5TjJT6 LyfyCI1UKXhxPn85xLdoleQIB9cFMxshxweJjwj0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Willem de Bruijn , Yonghong Song , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.0 097/137] bpf: only test gso type on gso packets Date: Wed, 15 May 2019 12:56:18 +0200 Message-Id: <20190515090700.580924077@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090651.633556783@linuxfoundation.org> References: <20190515090651.633556783@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 [ Upstream commit 4c3024debf62de4c6ac6d3cb4c0063be21d4f652 ] BPF can adjust gso only for tcp bytestreams. Fail on other gso types. But only on gso packets. It does not touch this field if !gso_size. Fixes: b90efd225874 ("bpf: only adjust gso_size on bytestream protocols") Signed-off-by: Willem de Bruijn Acked-by: Yonghong Song Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- include/linux/skbuff.h | 4 ++-- net/core/filter.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index bdb9563c64a01..b8679dcba96f8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4212,10 +4212,10 @@ static inline bool skb_is_gso_sctp(const struct sk_buff *skb) return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP; } +/* Note: Should be called only if skb_is_gso(skb) is true */ static inline bool skb_is_gso_tcp(const struct sk_buff *skb) { - return skb_is_gso(skb) && - skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6); + return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6); } static inline void skb_gso_reset(struct sk_buff *skb) diff --git a/net/core/filter.c b/net/core/filter.c index f7d0004fc1609..ff07996515f2d 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2789,7 +2789,7 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb) u32 off = skb_mac_header_len(skb); int ret; - if (!skb_is_gso_tcp(skb)) + if (skb_is_gso(skb) && !skb_is_gso_tcp(skb)) return -ENOTSUPP; ret = skb_cow(skb, len_diff); @@ -2830,7 +2830,7 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb) u32 off = skb_mac_header_len(skb); int ret; - if (!skb_is_gso_tcp(skb)) + if (skb_is_gso(skb) && !skb_is_gso_tcp(skb)) return -ENOTSUPP; ret = skb_unclone(skb, GFP_ATOMIC); @@ -2955,7 +2955,7 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 len_diff) u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb); int ret; - if (!skb_is_gso_tcp(skb)) + if (skb_is_gso(skb) && !skb_is_gso_tcp(skb)) return -ENOTSUPP; ret = skb_cow(skb, len_diff); @@ -2984,7 +2984,7 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff) u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb); int ret; - if (!skb_is_gso_tcp(skb)) + if (skb_is_gso(skb) && !skb_is_gso_tcp(skb)) return -ENOTSUPP; ret = skb_unclone(skb, GFP_ATOMIC); -- 2.20.1