Message ID | 20180504182857.5194.45504.stgit@localhost.localdomain |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
Series | UDP GSO Segmentation clean-ups | expand |
On 05/04/2018 11:29 AM, Alexander Duyck wrote: > From: Alexander Duyck <alexander.h.duyck@intel.com> > > We should verify that we can pull the UDP header before we attempt to do > so. Otherwise if this fails we have no way of knowing and GSO will not work > correctly. > > Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> > --- Reviewed-by: Eric Dumazet <edumazet@google.com>
On Fri, May 4, 2018 at 8:29 PM, Alexander Duyck <alexander.duyck@gmail.com> wrote: > From: Alexander Duyck <alexander.h.duyck@intel.com> > > We should verify that we can pull the UDP header before we attempt to do > so. Otherwise if this fails we have no way of knowing and GSO will not work > correctly. This already happened in the callers udp[46]_ufo_fragment
On Sat, May 5, 2018 at 1:12 AM, Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote: > On Fri, May 4, 2018 at 8:29 PM, Alexander Duyck > <alexander.duyck@gmail.com> wrote: >> From: Alexander Duyck <alexander.h.duyck@intel.com> >> >> We should verify that we can pull the UDP header before we attempt to do >> so. Otherwise if this fails we have no way of knowing and GSO will not work >> correctly. > > This already happened in the callers udp[46]_ufo_fragment Ah. Okay I didn't see that. I may add a comment somewhere indicating that is the case as it is a bit buried with all the calls. Thanks. - Alex
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index 006257092f06..8303fff42940 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -191,14 +191,17 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, netdev_features_t features, unsigned int mss, __sum16 check) { + struct sk_buff *seg, *segs = ERR_PTR(-EINVAL); struct sock *sk = gso_skb->sk; unsigned int sum_truesize = 0; - struct sk_buff *segs, *seg; unsigned int hdrlen; struct udphdr *uh; if (gso_skb->len <= sizeof(*uh) + mss) - return ERR_PTR(-EINVAL); + goto out; + + if (!pskb_may_pull(gso_skb, sizeof(*uh))) + goto out; hdrlen = gso_skb->data - skb_mac_header(gso_skb); skb_pull(gso_skb, sizeof(*uh)); @@ -230,7 +233,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, } refcount_add(sum_truesize - gso_skb->truesize, &sk->sk_wmem_alloc); - +out: return segs; } EXPORT_SYMBOL_GPL(__udp_gso_segment);