Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp638803img; Fri, 22 Mar 2019 05:41:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjz/ZdjqA5kToA2AnBiETS7hjnhAQ8x4hkUxE0FhJTf2XzP6gkRziAFCmdR7R+/H/OF4Wx X-Received: by 2002:aa7:8615:: with SMTP id p21mr8802445pfn.98.1553258482977; Fri, 22 Mar 2019 05:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553258482; cv=none; d=google.com; s=arc-20160816; b=TPsHHqY25wuaym7eNt8pg1WvWsh8e26v4Y/hrRJ6EJJSUMIu1xnEYNfZse32hizbI1 lC28GWu7wbcgwZoRXxHotUDMuaigAvKB7aFfSUjoG1tMOuZU+1+dWaCbrmy3kuWeeqyI CV8iQJFC6z1cgnVWRi4s7ynLU/L9cAidUxJdH99vnvrayhslz29+OzJAKoTHAXN0wzK+ Gwa+kxhEedO4FaJz2m5Bu72bs55fN4nAcGdsiVzCp+lhhpnHNW3kMi91e6tgDQ4heVxD iFiBoxl6hZOizVHg01mrP3isV44BEZJZIbp4s69pllV7DEB2VlJObPnfy96u4cYMDw9a JYZg== 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=zqiVRUuSTccmmfnqAuDg5uKdzlTJHMsrQ6O2c5SuKS0=; b=xglR2t7uOaTDICDNVp/5c7muIk8ZAzj7maEj5umKDZubsZDIza8xb/56UFkHVutdy5 AucdARoIgnLe0y/Xn5DSgeiFkuVF0gaTZfLZBGlRqueYjVjgNJQe5w8ztKe/jvjazFHW ocKr/yt1xlbouDQ18IZjEJT6MPyMOq4Ui44jMgxIOw16uyXK3iP99aKTsGoogmFR4fSg PkMz8kHGbRgW/WlUombkShO/psVb7K7kmawHX767hzxCeCOtTG6MmuaGbz9bzjorZx7R eB8tv4QX9/u6uco2sxHoEo9gZKvgdMN7JfVmALd8o2T3C19o/GuLCBksfhy+W9W9d2Hp b+yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d87cfwGB; 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 y33si6538911pga.134.2019.03.22.05.41.04; Fri, 22 Mar 2019 05:41:22 -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=d87cfwGB; 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 S1732262AbfCVMi7 (ORCPT + 99 others); Fri, 22 Mar 2019 08:38:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:46664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388090AbfCVMIT (ORCPT ); Fri, 22 Mar 2019 08:08:19 -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 BB15E2082C; Fri, 22 Mar 2019 12:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256498; bh=yAfiYDjR2ddQY8tQpHwSJHtznzRFCjryNCHfQF0rifc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d87cfwGBbD/9pNLeT8A/bGNikQw/zfrPoa+HbSnboikLZ0HlzwPlXJB53sUrTbpck K7SSMtxtDIyU7V5KM23v4AWfhBsX2mv99WOsgp8JittqJui7QEQaqAuD8Rvx3YN8iI yuaitmRxrdvtTXI2CM+0LUJna5nHWCeZ8Mr2bvhA= 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 4.19 212/280] bpf: only test gso type on gso packets Date: Fri, 22 Mar 2019 12:16:05 +0100 Message-Id: <20190322111333.030538897@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 3b0a25bb7c6f..820903ceac4f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4086,10 +4086,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 b1369edce113..eb81e9db4093 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2614,7 +2614,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); @@ -2655,7 +2655,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); @@ -2780,7 +2780,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); @@ -2809,7 +2809,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.19.1