All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Sabrina Dubroca <sd@queasysnail.net>,
	Stefano Brivio <sbrivio@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.17 017/101] net: fix use-after-free in GRO with ESP
Date: Fri, 20 Jul 2018 14:13:23 +0200	[thread overview]
Message-ID: <20180720121423.681819617@linuxfoundation.org> (raw)
In-Reply-To: <20180720121422.837870592@linuxfoundation.org>

4.17-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sabrina Dubroca <sd@queasysnail.net>

[ Upstream commit 603d4cf8fe095b1ee78f423d514427be507fb513 ]

Since the addition of GRO for ESP, gro_receive can consume the skb and
return -EINPROGRESS. In that case, the lower layer GRO handler cannot
touch the skb anymore.

Commit 5f114163f2f5 ("net: Add a skb_gro_flush_final helper.") converted
some of the gro_receive handlers that can lead to ESP's gro_receive so
that they wouldn't access the skb when -EINPROGRESS is returned, but
missed other spots, mainly in tunneling protocols.

This patch finishes the conversion to using skb_gro_flush_final(), and
adds a new helper, skb_gro_flush_final_remcsum(), used in VXLAN and
GUE.

Fixes: 5f114163f2f5 ("net: Add a skb_gro_flush_final helper.")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/geneve.c      |    2 +-
 drivers/net/vxlan.c       |    4 +---
 include/linux/netdevice.h |   20 ++++++++++++++++++++
 net/8021q/vlan.c          |    2 +-
 net/ipv4/fou.c            |    4 +---
 net/ipv4/gre_offload.c    |    2 +-
 net/ipv4/udp_offload.c    |    2 +-
 7 files changed, 26 insertions(+), 10 deletions(-)

--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -474,7 +474,7 @@ static struct sk_buff **geneve_gro_recei
 out_unlock:
 	rcu_read_unlock();
 out:
-	NAPI_GRO_CB(skb)->flush |= flush;
+	skb_gro_flush_final(skb, pp, flush);
 
 	return pp;
 }
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -623,9 +623,7 @@ static struct sk_buff **vxlan_gro_receiv
 	flush = 0;
 
 out:
-	skb_gro_remcsum_cleanup(skb, &grc);
-	skb->remcsum_offload = 0;
-	NAPI_GRO_CB(skb)->flush |= flush;
+	skb_gro_flush_final_remcsum(skb, pp, flush, &grc);
 
 	return pp;
 }
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2735,11 +2735,31 @@ static inline void skb_gro_flush_final(s
 	if (PTR_ERR(pp) != -EINPROGRESS)
 		NAPI_GRO_CB(skb)->flush |= flush;
 }
+static inline void skb_gro_flush_final_remcsum(struct sk_buff *skb,
+					       struct sk_buff **pp,
+					       int flush,
+					       struct gro_remcsum *grc)
+{
+	if (PTR_ERR(pp) != -EINPROGRESS) {
+		NAPI_GRO_CB(skb)->flush |= flush;
+		skb_gro_remcsum_cleanup(skb, grc);
+		skb->remcsum_offload = 0;
+	}
+}
 #else
 static inline void skb_gro_flush_final(struct sk_buff *skb, struct sk_buff **pp, int flush)
 {
 	NAPI_GRO_CB(skb)->flush |= flush;
 }
+static inline void skb_gro_flush_final_remcsum(struct sk_buff *skb,
+					       struct sk_buff **pp,
+					       int flush,
+					       struct gro_remcsum *grc)
+{
+	NAPI_GRO_CB(skb)->flush |= flush;
+	skb_gro_remcsum_cleanup(skb, grc);
+	skb->remcsum_offload = 0;
+}
 #endif
 
 static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -688,7 +688,7 @@ static struct sk_buff **vlan_gro_receive
 out_unlock:
 	rcu_read_unlock();
 out:
-	NAPI_GRO_CB(skb)->flush |= flush;
+	skb_gro_flush_final(skb, pp, flush);
 
 	return pp;
 }
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -448,9 +448,7 @@ next_proto:
 out_unlock:
 	rcu_read_unlock();
 out:
-	NAPI_GRO_CB(skb)->flush |= flush;
-	skb_gro_remcsum_cleanup(skb, &grc);
-	skb->remcsum_offload = 0;
+	skb_gro_flush_final_remcsum(skb, pp, flush, &grc);
 
 	return pp;
 }
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -223,7 +223,7 @@ static struct sk_buff **gre_gro_receive(
 out_unlock:
 	rcu_read_unlock();
 out:
-	NAPI_GRO_CB(skb)->flush |= flush;
+	skb_gro_flush_final(skb, pp, flush);
 
 	return pp;
 }
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -295,7 +295,7 @@ unflush:
 out_unlock:
 	rcu_read_unlock();
 out:
-	NAPI_GRO_CB(skb)->flush |= flush;
+	skb_gro_flush_final(skb, pp, flush);
 	return pp;
 }
 EXPORT_SYMBOL(udp_gro_receive);



  parent reply	other threads:[~2018-07-20 12:40 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 12:13 [PATCH 4.17 000/101] 4.17.9-stable review Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 001/101] compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 002/101] x86/asm: Add _ASM_ARG* constants for argument registers to <asm/asm.h> Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 003/101] x86/paravirt: Make native_save_fl() extern inline Greg Kroah-Hartman
2018-07-20 12:13 ` Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 005/101] pinctrl: mt7622: fix error path on failing at groups building Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 006/101] pinctrl: mt7622: stop using the deprecated pinctrl_add_gpio_range Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 007/101] pinctrl: mt7622: fix a kernel panic when gpio-hog is being applied Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 008/101] alx: take rtnl before calling __alx_open from resume Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 010/101] atm: zatm: Fix potential Spectre v1 Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 011/101] hv_netvsc: split sub-channel setup into async and sync Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 012/101] ipv6: sr: fix passing wrong flags to crypto_alloc_shash() Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 013/101] ipvlan: fix IFLA_MTU ignored on NEWLINK Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 014/101] ixgbe: split XDP_TX tail and XDP_REDIRECT map flushing Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 015/101] net: dccp: avoid crash in ccid3_hc_rx_send_feedback() Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 016/101] net: dccp: switch rx_tstamp_last_feedback to monotonic clock Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` Greg Kroah-Hartman [this message]
2018-07-20 12:13 ` [PATCH 4.17 018/101] net: macb: Fix ptp time adjustment for large negative delta Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 019/101] net/mlx5e: Avoid dealing with vport representors if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 020/101] net/mlx5e: Dont attempt to dereference the ppriv struct if not being eswitch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 021/101] net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 022/101] net/mlx5: Fix command interface race in polling mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 023/101] net/mlx5: Fix incorrect raw command length parsing Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 024/101] net/mlx5: Fix required capability for manipulating MPFS Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 025/101] net/mlx5: Fix wrong size allocation for QoS ETC TC regitster Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 026/101] net: mvneta: fix the Rx desc DMA address in the Rx path Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 027/101] net/packet: fix use-after-free Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 028/101] net/sched: act_ife: fix recursive lock and idr leak Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 029/101] net/sched: act_ife: preserve the action control in case of error Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 030/101] net_sched: blackhole: tell upper qdisc about dropped packets Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 031/101] net: sungem: fix rx checksum support Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 032/101] net/tcp: Fix socket lookups with SO_BINDTODEVICE Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 033/101] qede: Adverstise software timestamp caps when PHC is not available Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 034/101] qed: Fix setting of incorrect eswitch mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 035/101] qed: Fix use of incorrect size in memcpy call Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 036/101] qed: Limit msix vectors in kdump kernel to the minimum required count Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 038/101] r8152: napi hangup fix after disconnect Greg Kroah-Hartman
2018-07-20 12:13   ` [4.17,038/101] " Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 039/101] s390/qeth: dont clobber buffer on async TX completion Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 040/101] stmmac: fix DMA channel hang in half-duplex mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 041/101] strparser: Remove early eaten to fix full tcp receive buffer stall Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 042/101] tcp: fix Fast Open key endianness Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 044/101] vhost_net: validate sock before trying to put its fd Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 045/101] VSOCK: fix loopback on big-endian systems Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 046/101] hinic: reset irq affinity before freeing irq Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 047/101] nfp: flower: fix mpls ether type detection Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 048/101] net: macb: initialize bp->queues[0].bp for at91rm9200 Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 049/101] net: use dev_change_tx_queue_len() for SIOCSIFTXQLEN Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 050/101] nfp: reject binding to shared blocks Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 051/101] xen-netfront: Fix mismatched rtnl_unlock Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 052/101] xen-netfront: Update features after registering netdev Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 053/101] enic: do not overwrite error code Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 055/101] IB/mlx5: Avoid dealing with vport representors if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 056/101] Revert "s390/qeth: use Read device to query hypervisor for MAC" Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 057/101] s390/qeth: avoid using is_multicast_ether_addr_64bits on (u8 *)[6] Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 058/101] s390/qeth: fix race when setting MAC address Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 059/101] sfc: correctly initialise filter rwsem for farch Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 060/101] virtio_net: split XDP_TX kick and XDP_REDIRECT map flushing Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 061/101] x86/kvm/Kconfig: Ensure CRYPTO_DEV_CCP_DD state at minimum matches KVM_AMD Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 062/101] net: cxgb3_main: fix potential Spectre v1 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 063/101] rtlwifi: Fix kernel Oops "Fw download fail!!" Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 064/101] rtlwifi: rtl8821ae: fix firmware is not ready to run Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 065/101] net: lan78xx: Fix race in tx pending skb size calculation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 066/101] crypto: af_alg - Initialize sg_num_bytes in error code path Greg Kroah-Hartman
2018-07-20 13:08   ` KMSAN: uninit-value in af_alg_free_areq_sgls syzbot
2018-07-20 12:14 ` [PATCH 4.17 067/101] PCI: hv: Disable/enable IRQs rather than BH in hv_compose_msi_msg() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 068/101] netfilter: ebtables: reject non-bridge targets Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 069/101] reiserfs: fix buffer overflow with long warning messages Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 070/101] KEYS: DNS: fix parsing multiple options Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 071/101] tls: Stricter error checking in zerocopy sendmsg path Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 072/101] autofs: fix slab out of bounds read in getname_kernel() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 073/101] nsh: set mac len based on inner packet Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 074/101] netfilter: ipv6: nf_defrag: drop skb dst before queueing Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 075/101] bdi: Fix another oops in wb_workfn() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 076/101] bpf: reject any prog that failed read-only lock Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 077/101] rds: avoid unenecessary cong_update in loop transport Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 078/101] block: dont use blocking queue entered for recursive bio submits Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 079/101] bpf: sockmap, fix crash when ipv6 sock is added Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 080/101] bpf: sockmap, consume_skb in close path Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 081/101] bpf: dont leave partial mangled prog in jit_subprogs error path Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 082/101] net/nfc: Avoid stalls when nfc_alloc_send_skb() returned NULL Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 083/101] ipvs: initialize tbl->entries after allocation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 084/101] ipvs: initialize tbl->entries in ip_vs_lblc_init_svc() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 085/101] arm/arm64: smccc: Add SMCCC-specific return codes Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 086/101] arm64: Call ARCH_WORKAROUND_2 on transitions between EL0 and EL1 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 087/101] arm64: Add per-cpu infrastructure to call ARCH_WORKAROUND_2 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 088/101] arm64: Add ARCH_WORKAROUND_2 probing Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 089/101] arm64: Add ssbd command-line option Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 090/101] arm64: ssbd: Add global mitigation state accessor Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 091/101] arm64: ssbd: Skip apply_ssbd if not using dynamic mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 092/101] arm64: ssbd: Restore mitigation status on CPU resume Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 093/101] arm64: ssbd: Introduce thread flag to control userspace mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 094/101] arm64: ssbd: Add prctl interface for per-thread mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 095/101] arm64: KVM: Add HYP per-cpu accessors Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 096/101] arm64: KVM: Add ARCH_WORKAROUND_2 support for guests Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 097/101] arm64: KVM: Handle guests ARCH_WORKAROUND_2 requests Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 098/101] arm64: KVM: Add ARCH_WORKAROUND_2 discovery through ARCH_FEATURES_FUNC_ID Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 099/101] bpf: enforce correct alignment for instructions Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 100/101] bpf, arm32: fix to use bpf_jit_binary_lock_ro api Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 101/101] bpf: undo prog rejection on read-only lock failure Greg Kroah-Hartman
2018-07-21  7:54 ` [PATCH 4.17 000/101] 4.17.9-stable review Naresh Kamboju
2018-07-22 11:42   ` Greg Kroah-Hartman
2018-07-21 13:42 ` Guenter Roeck

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=20180720121423.681819617@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sbrivio@redhat.com \
    --cc=sd@queasysnail.net \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.