linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Willem de Bruijn <willemb@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.20 07/60] bpf: only adjust gso_size on bytestream protocols
Date: Wed, 13 Mar 2019 15:09:28 -0400	[thread overview]
Message-ID: <20190313191021.158171-7-sashal@kernel.org> (raw)
In-Reply-To: <20190313191021.158171-1-sashal@kernel.org>

From: Willem de Bruijn <willemb@google.com>

[ Upstream commit b90efd2258749e04e1b3f71ef0d716f2ac2337e0 ]

bpf_skb_change_proto and bpf_skb_adjust_room change skb header length.
For GSO packets they adjust gso_size to maintain the same MTU.

The gso size can only be safely adjusted on bytestream protocols.
Commit d02f51cbcf12 ("bpf: fix bpf_skb_adjust_net/bpf_skb_proto_xlat
to deal with gso sctp skbs") excluded SKB_GSO_SCTP.

Since then type SKB_GSO_UDP_L4 has been added, whose contents are one
gso_size unit per datagram. Also exclude these.

Move from a blacklist to a whitelist check to future proof against
additional such new GSO types, e.g., for fraglist based GRO.

Fixes: bec1f6f69736 ("udp: generate gso with UDP_SEGMENT")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/skbuff.h |  6 ++++++
 net/core/filter.c      | 12 ++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 8e63c166765e..875f56cbb756 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -4118,6 +4118,12 @@ static inline bool skb_is_gso_sctp(const struct sk_buff *skb)
 	return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP;
 }
 
+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);
+}
+
 static inline void skb_gso_reset(struct sk_buff *skb)
 {
 	skb_shinfo(skb)->gso_size = 0;
diff --git a/net/core/filter.c b/net/core/filter.c
index 16350f8c8815..6e37c639519e 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2624,8 +2624,7 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb)
 	u32 off = skb_mac_header_len(skb);
 	int ret;
 
-	/* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */
-	if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb)))
+	if (!skb_is_gso_tcp(skb))
 		return -ENOTSUPP;
 
 	ret = skb_cow(skb, len_diff);
@@ -2666,8 +2665,7 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb)
 	u32 off = skb_mac_header_len(skb);
 	int ret;
 
-	/* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */
-	if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb)))
+	if (!skb_is_gso_tcp(skb))
 		return -ENOTSUPP;
 
 	ret = skb_unclone(skb, GFP_ATOMIC);
@@ -2792,8 +2790,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;
 
-	/* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */
-	if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb)))
+	if (!skb_is_gso_tcp(skb))
 		return -ENOTSUPP;
 
 	ret = skb_cow(skb, len_diff);
@@ -2822,8 +2819,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;
 
-	/* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */
-	if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb)))
+	if (!skb_is_gso_tcp(skb))
 		return -ENOTSUPP;
 
 	ret = skb_unclone(skb, GFP_ATOMIC);
-- 
2.19.1


  parent reply	other threads:[~2019-03-13 19:34 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 19:09 [PATCH AUTOSEL 4.20 01/60] clk: sunxi-ng: v3s: Fix TCON reset de-assert bit Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 02/60] kallsyms: Handle too long symbols in kallsyms.c Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 03/60] clk: sunxi: A31: Fix wrong AHB gate number Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 04/60] esp: Skip TX bytes accounting when sending from a request socket Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 05/60] ARM: 8824/1: fix a migrating irq bug when hotplug cpu Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 06/60] bpf: Fix narrow load on a bpf_sock returned from sk_lookup() Sasha Levin
2019-03-13 19:09 ` Sasha Levin [this message]
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 08/60] bpf: fix lockdep false positive in stackmap Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 09/60] af_key: unconditionally clone on broadcast Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 10/60] ARM: 8835/1: dma-mapping: Clear DMA ops on teardown Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 11/60] sh: fix build error for invisible CONFIG_BUILTIN_DTB_SOURCE Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 12/60] assoc_array: Fix shortcut creation Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 13/60] keys: Fix dependency loop between construction record and auth key Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 14/60] scsi: libiscsi: Fix race between iscsi_xmit_task and iscsi_complete_task Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 15/60] net: systemport: Fix reception of BPDUs Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 16/60] net: dsa: bcm_sf2: Do not assume DSA master supports WoL Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 17/60] pinctrl: meson: meson8b: fix the sdxc_a data 1..3 pins Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 18/60] qmi_wwan: apply SET_DTR quirk to Sierra WP7607 Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 19/60] net: mv643xx_eth: disable clk on error path in mv643xx_eth_shared_probe() Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 20/60] xfrm: Fix inbound traffic via XFRM interfaces across network namespaces Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 21/60] arm64: fix SSBS sanitization Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 22/60] mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush timeout issue Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 23/60] ASoC: topology: free created components in tplg load error Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 24/60] bpf/test_run: fix unkillable BPF_PROG_TEST_RUN Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 25/60] qed: Fix iWARP buffer size provided for syn packet processing Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 26/60] qed: Fix iWARP syn packet mac address validation Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 27/60] ARM: dts: armada-xp: fix Armada XP boards NAND description Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 28/60] ARM: dts: am335x-evmsk: Fix PHY mode for ethernet Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 29/60] ARM: dts: am335x-evm: " Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 30/60] arm64: Relax GIC version check during early boot Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 31/60] ARM: tegra: Restore DT ABI on Tegra124 Chromebooks Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 32/60] drm/amd/display: Fix negative cursor pos programming Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 33/60] net: marvell: mvneta: fix DMA debug warning Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 34/60] kasan, slub: move kasan_poison_slab hook before page_address Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 35/60] mm: handle lru_add_drain_all for UP properly Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 36/60] psi: avoid divide-by-zero crash inside virtual machines Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 37/60] tmpfs: fix link accounting when a tmpfile is linked in Sasha Levin
2019-03-13 19:58   ` Hugh Dickins
2019-03-19 20:07     ` Sasha Levin
2019-03-13 19:09 ` [PATCH AUTOSEL 4.20 38/60] kasan, slab: fix conflicts with CONFIG_HARDENED_USERCOPY Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 39/60] kasan, slab: make freelist stored without tags Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 40/60] ixgbe: fix older devices that do not support IXGBE_MRQC_L3L4TXSWEN Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 41/60] i40e: fix potential RX buffer starvation for AF_XDP Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 42/60] ixgbe: " Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 43/60] ARCv2: lib: memcpy: fix doing prefetchw outside of buffer Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 44/60] ARC: uacces: remove lp_start, lp_end from clobber list Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 45/60] ARCv2: support manual regfile save on interrupts Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 46/60] i40e: fix XDP_REDIRECT/XDP xmit ring cleanup race Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 47/60] ixgbe: don't do any AF_XDP zero-copy transmit if netif is not OK Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 48/60] ARCv2: don't assume core 0x54 has dual issue Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 49/60] phonet: fix building with clang Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 50/60] mac80211_hwsim: propagate genlmsg_reply return code Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 51/60] bpf, lpm: fix lookup bug in map_delete_elem Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 52/60] net: thunderx: make CFG_DONE message to run through generic send-ack sequence Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 53/60] net: thunderx: add nicvf_send_msg_to_pf result check for set_rx_mode_task Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 54/60] nfp: bpf: fix code-gen bug on BPF_ALU | BPF_XOR | BPF_K Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 55/60] nfp: bpf: fix ALU32 high bits clearance bug Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 56/60] bnxt_en: Fix typo in firmware message timeout logic Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 57/60] bnxt_en: Wait longer for the firmware message response to complete Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 58/60] mdio_bus: Fix use-after-free on device_register fails Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 59/60] net: set static variable an initial value in atl2_probe() Sasha Levin
2019-03-13 19:10 ` [PATCH AUTOSEL 4.20 60/60] selftests: fib_tests: sleep after changing carrier. again Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190313191021.158171-7-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=ast@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).