Re: [net-next PATCH v2 2/8] udp: Verify that pulling UDP header in GSO segmentation doesn't fail

2018-05-05 Thread Alexander Duyck
On Sat, May 5, 2018 at 1:12 AM, Willem de Bruijn
 wrote:
> On Fri, May 4, 2018 at 8:29 PM, Alexander Duyck
>  wrote:
>> From: Alexander Duyck 
>>
>> 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


Re: [net-next PATCH v2 2/8] udp: Verify that pulling UDP header in GSO segmentation doesn't fail

2018-05-05 Thread Willem de Bruijn
On Fri, May 4, 2018 at 8:29 PM, Alexander Duyck
 wrote:
> From: Alexander Duyck 
>
> 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


Re: [net-next PATCH v2 2/8] udp: Verify that pulling UDP header in GSO segmentation doesn't fail

2018-05-04 Thread Eric Dumazet


On 05/04/2018 11:29 AM, Alexander Duyck wrote:
> From: Alexander Duyck 
> 
> 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 
> ---

Reviewed-by: Eric Dumazet 



[net-next PATCH v2 2/8] udp: Verify that pulling UDP header in GSO segmentation doesn't fail

2018-05-04 Thread Alexander Duyck
From: Alexander Duyck 

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

v2: New break-out patch based on one patch from earlier series

 net/ipv4/udp_offload.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

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