netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] udp: fix a skb extensions leak
@ 2020-03-26  9:06 Xin Long
  2020-03-26  9:28 ` Xin Long
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Xin Long @ 2020-03-26  9:06 UTC (permalink / raw)
  To: network dev; +Cc: davem, Paolo Abeni

On udp rx path udp_rcv_segment() may do segment where the frag skbs
will get the header copied from the head skb in skb_segment_list()
by calling __copy_skb_header(), which could overwrite the frag skbs'
extensions by __skb_ext_copy() and cause a leak.

This issue was found after loading esp_offload where a sec path ext
is set in the skb.

On udp tx gso path, it works well as the frag skbs' extensions are
not set. So this issue should be fixed on udp's rx path only and
release the frag skbs' extensions before going to do segment.

Reported-by: Xiumei Mu <xmu@redhat.com>
Fixes: cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/udp.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/net/udp.h b/include/net/udp.h
index e55d5f7..7bf0ca5 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -486,6 +486,10 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
 	if (skb->pkt_type == PACKET_LOOPBACK)
 		skb->ip_summed = CHECKSUM_PARTIAL;
 
+	if (skb_has_frag_list(skb) && skb_has_extensions(skb))
+		skb_walk_frags(skb, segs)
+			skb_ext_put(segs);
+
 	/* the GSO CB lays after the UDP one, no need to save and restore any
 	 * CB fragment
 	 */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-03-30 16:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26  9:06 [PATCH net] udp: fix a skb extensions leak Xin Long
2020-03-26  9:28 ` Xin Long
2020-03-30  4:54 ` David Miller
2020-03-30  8:29 ` Steffen Klassert
2020-03-30 16:13   ` Xin Long
2020-03-30 16:13     ` Florian Westphal
2020-03-30 13:27 ` Florian Westphal
2020-03-30 13:45   ` Steffen Klassert
2020-03-30 14:11     ` Florian Westphal
2020-03-30 14:39       ` Steffen Klassert
2020-03-30 16:14   ` Xin Long

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).