All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets
@ 2017-11-25 19:14 Gustavo A. R. Silva
  2017-11-25 21:15   ` Willem de Bruijn
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-25 19:14 UTC (permalink / raw)
  To: Pravin Shelar, David S. Miller, Willem de Bruijn
  Cc: netdev, dev, linux-kernel, Gustavo A. R. Silva

gso_type is being used in binary AND operations together with SKB_GSO_UDP.
The issue is that variable gso_type is of type unsigned short and
SKB_GSO_UDP expands to more than 16 bits:

SKB_GSO_UDP = 1 << 16

this makes any binary AND operation between gso_type and SKB_GSO_UDP to
be always zero, hence making some code unreachable and likely causing
undesired behavior.

Fix this by changing the data type of variable gso_type to unsigned int.

Addresses-Coverity-ID: 1462223
Fixes: 0c19f846d582 ("net: accept UFO datagrams from tuntap and packet")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 net/openvswitch/datapath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 99cfafc..ef38e5a 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -308,7 +308,7 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
 			     const struct dp_upcall_info *upcall_info,
 				 uint32_t cutlen)
 {
-	unsigned short gso_type = skb_shinfo(skb)->gso_type;
+	unsigned int gso_type = skb_shinfo(skb)->gso_type;
 	struct sw_flow_key later_key;
 	struct sk_buff *segs, *nskb;
 	int err;
-- 
2.7.4

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

* Re: [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets
@ 2017-11-25 21:15   ` Willem de Bruijn
  0 siblings, 0 replies; 7+ messages in thread
From: Willem de Bruijn @ 2017-11-25 21:15 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Pravin Shelar, David S. Miller, Willem de Bruijn,
	Network Development, dev, LKML, steffen.klassert

On Sat, Nov 25, 2017 at 2:14 PM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> gso_type is being used in binary AND operations together with SKB_GSO_UDP.
> The issue is that variable gso_type is of type unsigned short and
> SKB_GSO_UDP expands to more than 16 bits:
>
> SKB_GSO_UDP = 1 << 16
>
> this makes any binary AND operation between gso_type and SKB_GSO_UDP to
> be always zero, hence making some code unreachable and likely causing
> undesired behavior.
>
> Fix this by changing the data type of variable gso_type to unsigned int.
>
> Addresses-Coverity-ID: 1462223
> Fixes: 0c19f846d582 ("net: accept UFO datagrams from tuntap and packet")
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Acked-by: Willem de Bruijn <willemb@google.com>

Good catch, thanks!

The issue here is that I brought back SKB_GSO_UDP at the end of the
list at 1 << 16 to avoid renaming of all that used to follow, while it used
to be defined as 1 << 1.

The skb_shinfo(skb)->gso_type field itself has been expanded as of v4.12
in commit 7f564528a480 ("skbuff: Extend gso_type to unsigned int.").

A quick scan shows a few nic drivers that also still cast to unsigned
short: bnxt, atl1c and qede. Since UFO hardware offload no longer
exists, this is safe wrt this patch. And it is fine for older kernels as
no driver supported the previous entry at 1 << 16, SKB_GSO_ESP.
But it is fragile wrt follow-on offloads. Probably a net-next patch.

The only other likely issue I spotted with the longer gso_type is
in trace events. net_dev_start_xmit and net_dev_rx_verbose_template
both export as u16.

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

* Re: [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets
@ 2017-11-25 21:15   ` Willem de Bruijn
  0 siblings, 0 replies; 7+ messages in thread
From: Willem de Bruijn @ 2017-11-25 21:15 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: dev-yBygre7rU0TnMu66kgdUjQ,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ, Willem de Bruijn,
	Network Development, LKML, Pravin Shelar, David S. Miller

On Sat, Nov 25, 2017 at 2:14 PM, Gustavo A. R. Silva
<garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org> wrote:
> gso_type is being used in binary AND operations together with SKB_GSO_UDP.
> The issue is that variable gso_type is of type unsigned short and
> SKB_GSO_UDP expands to more than 16 bits:
>
> SKB_GSO_UDP = 1 << 16
>
> this makes any binary AND operation between gso_type and SKB_GSO_UDP to
> be always zero, hence making some code unreachable and likely causing
> undesired behavior.
>
> Fix this by changing the data type of variable gso_type to unsigned int.
>
> Addresses-Coverity-ID: 1462223
> Fixes: 0c19f846d582 ("net: accept UFO datagrams from tuntap and packet")
> Signed-off-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>

Acked-by: Willem de Bruijn <willemb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>

Good catch, thanks!

The issue here is that I brought back SKB_GSO_UDP at the end of the
list at 1 << 16 to avoid renaming of all that used to follow, while it used
to be defined as 1 << 1.

The skb_shinfo(skb)->gso_type field itself has been expanded as of v4.12
in commit 7f564528a480 ("skbuff: Extend gso_type to unsigned int.").

A quick scan shows a few nic drivers that also still cast to unsigned
short: bnxt, atl1c and qede. Since UFO hardware offload no longer
exists, this is safe wrt this patch. And it is fine for older kernels as
no driver supported the previous entry at 1 << 16, SKB_GSO_ESP.
But it is fragile wrt follow-on offloads. Probably a net-next patch.

The only other likely issue I spotted with the longer gso_type is
in trace events. net_dev_start_xmit and net_dev_rx_verbose_template
both export as u16.

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

* Re: [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets
@ 2017-11-26 17:16     ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-11-26 17:16 UTC (permalink / raw)
  To: willemdebruijn.kernel
  Cc: garsilva, pshelar, willemb, netdev, dev, linux-kernel, steffen.klassert

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Sat, 25 Nov 2017 16:15:01 -0500

> On Sat, Nov 25, 2017 at 2:14 PM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>> gso_type is being used in binary AND operations together with SKB_GSO_UDP.
>> The issue is that variable gso_type is of type unsigned short and
>> SKB_GSO_UDP expands to more than 16 bits:
>>
>> SKB_GSO_UDP = 1 << 16
>>
>> this makes any binary AND operation between gso_type and SKB_GSO_UDP to
>> be always zero, hence making some code unreachable and likely causing
>> undesired behavior.
>>
>> Fix this by changing the data type of variable gso_type to unsigned int.
>>
>> Addresses-Coverity-ID: 1462223
>> Fixes: 0c19f846d582 ("net: accept UFO datagrams from tuntap and packet")
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> 
> Acked-by: Willem de Bruijn <willemb@google.com>

Applied and I'll queued this up with Willem's changes for -stable.

Thanks!

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

* Re: [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets
@ 2017-11-26 17:16     ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-11-26 17:16 UTC (permalink / raw)
  To: willemdebruijn.kernel-Re5JQEeQqe8AvxtiuMwx3w
  Cc: dev-yBygre7rU0TnMu66kgdUjQ,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ,
	willemb-hpIqsD4AKlfQT0dZR+AlfA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	pshelar-l0M0P4e3n4LQT0dZR+AlfA, garsilva-L1vi/lXTdts+Va1GwOuvDg

From: Willem de Bruijn <willemdebruijn.kernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Sat, 25 Nov 2017 16:15:01 -0500

> On Sat, Nov 25, 2017 at 2:14 PM, Gustavo A. R. Silva
> <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org> wrote:
>> gso_type is being used in binary AND operations together with SKB_GSO_UDP.
>> The issue is that variable gso_type is of type unsigned short and
>> SKB_GSO_UDP expands to more than 16 bits:
>>
>> SKB_GSO_UDP = 1 << 16
>>
>> this makes any binary AND operation between gso_type and SKB_GSO_UDP to
>> be always zero, hence making some code unreachable and likely causing
>> undesired behavior.
>>
>> Fix this by changing the data type of variable gso_type to unsigned int.
>>
>> Addresses-Coverity-ID: 1462223
>> Fixes: 0c19f846d582 ("net: accept UFO datagrams from tuntap and packet")
>> Signed-off-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
> 
> Acked-by: Willem de Bruijn <willemb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>

Applied and I'll queued this up with Willem's changes for -stable.

Thanks!

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

* Re: [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets
  2017-11-26 17:16     ` David Miller
@ 2017-11-27 14:40       ` Gustavo A. R. Silva
  -1 siblings, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-27 14:40 UTC (permalink / raw)
  To: David Miller
  Cc: willemdebruijn.kernel, pshelar, willemb, netdev, dev,
	linux-kernel, steffen.klassert


Quoting David Miller <davem@davemloft.net>:

> From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Date: Sat, 25 Nov 2017 16:15:01 -0500
>
>> On Sat, Nov 25, 2017 at 2:14 PM, Gustavo A. R. Silva
>> <garsilva@embeddedor.com> wrote:
>>> gso_type is being used in binary AND operations together with SKB_GSO_UDP.
>>> The issue is that variable gso_type is of type unsigned short and
>>> SKB_GSO_UDP expands to more than 16 bits:
>>>
>>> SKB_GSO_UDP = 1 << 16
>>>
>>> this makes any binary AND operation between gso_type and SKB_GSO_UDP to
>>> be always zero, hence making some code unreachable and likely causing
>>> undesired behavior.
>>>
>>> Fix this by changing the data type of variable gso_type to unsigned int.
>>>
>>> Addresses-Coverity-ID: 1462223
>>> Fixes: 0c19f846d582 ("net: accept UFO datagrams from tuntap and packet")
>>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>>
>> Acked-by: Willem de Bruijn <willemb@google.com>
>
> Applied and I'll queued this up with Willem's changes for -stable.
>
> Thanks!

Glad to help :)

Thanks
--
Gustavo A. R. Silva

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

* Re: [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets
@ 2017-11-27 14:40       ` Gustavo A. R. Silva
  0 siblings, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-27 14:40 UTC (permalink / raw)
  To: David Miller
  Cc: willemdebruijn.kernel, pshelar, willemb, netdev, dev,
	linux-kernel, steffen.klassert


Quoting David Miller <davem@davemloft.net>:

> From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Date: Sat, 25 Nov 2017 16:15:01 -0500
>
>> On Sat, Nov 25, 2017 at 2:14 PM, Gustavo A. R. Silva
>> <garsilva@embeddedor.com> wrote:
>>> gso_type is being used in binary AND operations together with SKB_GSO_UDP.
>>> The issue is that variable gso_type is of type unsigned short and
>>> SKB_GSO_UDP expands to more than 16 bits:
>>>
>>> SKB_GSO_UDP = 1 << 16
>>>
>>> this makes any binary AND operation between gso_type and SKB_GSO_UDP to
>>> be always zero, hence making some code unreachable and likely causing
>>> undesired behavior.
>>>
>>> Fix this by changing the data type of variable gso_type to unsigned int.
>>>
>>> Addresses-Coverity-ID: 1462223
>>> Fixes: 0c19f846d582 ("net: accept UFO datagrams from tuntap and packet")
>>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>>
>> Acked-by: Willem de Bruijn <willemb@google.com>
>
> Applied and I'll queued this up with Willem's changes for -stable.
>
> Thanks!

Glad to help :)

Thanks

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

end of thread, other threads:[~2017-11-27 15:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-25 19:14 [PATCH] net: openvswitch: datapath: fix data type in queue_gso_packets Gustavo A. R. Silva
2017-11-25 21:15 ` Willem de Bruijn
2017-11-25 21:15   ` Willem de Bruijn
2017-11-26 17:16   ` David Miller
2017-11-26 17:16     ` David Miller
2017-11-27 14:40     ` Gustavo A. R. Silva
2017-11-27 14:40       ` Gustavo A. R. Silva

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.