Commit 04d55b25 authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller

udp: Do not copy destructor if one is not present

This patch makes it so that if a destructor is not present we avoid trying
to update the skb socket or any reference counting that would be associated
with the NULL socket and/or descriptor. By doing this we can support
traffic coming from another namespace without any issues.
Acked-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6053d0f1
...@@ -195,6 +195,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, ...@@ -195,6 +195,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
struct sk_buff *segs, *seg; struct sk_buff *segs, *seg;
struct udphdr *uh; struct udphdr *uh;
unsigned int mss; unsigned int mss;
bool copy_dtor;
__sum16 check; __sum16 check;
__be16 newlen; __be16 newlen;
...@@ -205,12 +206,14 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, ...@@ -205,12 +206,14 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
skb_pull(gso_skb, sizeof(*uh)); skb_pull(gso_skb, sizeof(*uh));
/* clear destructor to avoid skb_segment assigning it to tail */ /* clear destructor to avoid skb_segment assigning it to tail */
WARN_ON_ONCE(gso_skb->destructor != sock_wfree); copy_dtor = gso_skb->destructor == sock_wfree;
gso_skb->destructor = NULL; if (copy_dtor)
gso_skb->destructor = NULL;
segs = skb_segment(gso_skb, features); segs = skb_segment(gso_skb, features);
if (unlikely(IS_ERR_OR_NULL(segs))) { if (unlikely(IS_ERR_OR_NULL(segs))) {
gso_skb->destructor = sock_wfree; if (copy_dtor)
gso_skb->destructor = sock_wfree;
return segs; return segs;
} }
...@@ -229,9 +232,11 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, ...@@ -229,9 +232,11 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
check = csum16_add(csum16_sub(uh->check, uh->len), newlen); check = csum16_add(csum16_sub(uh->check, uh->len), newlen);
for (;;) { for (;;) {
seg->destructor = sock_wfree; if (copy_dtor) {
seg->sk = sk; seg->destructor = sock_wfree;
sum_truesize += seg->truesize; seg->sk = sk;
sum_truesize += seg->truesize;
}
if (!seg->next) if (!seg->next)
break; break;
...@@ -263,8 +268,9 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, ...@@ -263,8 +268,9 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
uh->check = gso_make_checksum(seg, ~check) ? : CSUM_MANGLED_0; uh->check = gso_make_checksum(seg, ~check) ? : CSUM_MANGLED_0;
/* update refcount for the packet */ /* update refcount for the packet */
refcount_add(sum_truesize - gso_skb->truesize, &sk->sk_wmem_alloc); if (copy_dtor)
refcount_add(sum_truesize - gso_skb->truesize,
&sk->sk_wmem_alloc);
return segs; return segs;
} }
EXPORT_SYMBOL_GPL(__udp_gso_segment); EXPORT_SYMBOL_GPL(__udp_gso_segment);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment