All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] vxlan: fix missing options_len update on RX with collect metadata
@ 2016-03-02  1:32 Daniel Borkmann
  2016-03-03  1:21 ` Cong Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Daniel Borkmann @ 2016-03-02  1:32 UTC (permalink / raw)
  To: davem; +Cc: tgraf, pshelar, jesse, netdev, Daniel Borkmann

When signalling to metadata consumers that the metadata_dst entry
carries additional GBP extension data for vxlan (TUNNEL_VXLAN_OPT),
the dst's vxlan_metadata information is populated, but options_len
is left to zero. F.e. in ovs, ovs_flow_key_extract() checks for
options_len before extracting the data through ip_tunnel_info_opts_get().

Geneve uses ip_tunnel_info_opts_set() helper in receive path, which
sets options_len internally, vxlan however uses ip_tunnel_info_opts(),
so when filling vxlan_metadata, we do need to update options_len.

Fixes: 4c22279848c5 ("ip-tunnel: Use API to access tunnel metadata options.")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 drivers/net/vxlan.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index b601139..1c32bd1 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1308,8 +1308,10 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
 		gbp = (struct vxlanhdr_gbp *)vxh;
 		md->gbp = ntohs(gbp->policy_id);
 
-		if (tun_dst)
+		if (tun_dst) {
 			tun_dst->u.tun_info.key.tun_flags |= TUNNEL_VXLAN_OPT;
+			tun_dst->u.tun_info.options_len = sizeof(*md);
+		}
 
 		if (gbp->dont_learn)
 			md->gbp |= VXLAN_GBP_DONT_LEARN;
-- 
1.9.3

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

* Re: [PATCH net] vxlan: fix missing options_len update on RX with collect metadata
  2016-03-02  1:32 [PATCH net] vxlan: fix missing options_len update on RX with collect metadata Daniel Borkmann
@ 2016-03-03  1:21 ` Cong Wang
  2016-03-03  8:58   ` Daniel Borkmann
  2016-03-03 10:33 ` Thomas Graf
  2016-03-03 22:11 ` David Miller
  2 siblings, 1 reply; 7+ messages in thread
From: Cong Wang @ 2016-03-03  1:21 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: David Miller, Thomas Graf, Pravin B Shelar, jesse,
	Linux Kernel Network Developers

On Tue, Mar 1, 2016 at 5:32 PM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> When signalling to metadata consumers that the metadata_dst entry
> carries additional GBP extension data for vxlan (TUNNEL_VXLAN_OPT),
> the dst's vxlan_metadata information is populated, but options_len
> is left to zero. F.e. in ovs, ovs_flow_key_extract() checks for
> options_len before extracting the data through ip_tunnel_info_opts_get().
>
> Geneve uses ip_tunnel_info_opts_set() helper in receive path, which
> sets options_len internally, vxlan however uses ip_tunnel_info_opts(),
> so when filling vxlan_metadata, we do need to update options_len.
>
> Fixes: 4c22279848c5 ("ip-tunnel: Use API to access tunnel metadata options.")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  drivers/net/vxlan.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index b601139..1c32bd1 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -1308,8 +1308,10 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
>                 gbp = (struct vxlanhdr_gbp *)vxh;
>                 md->gbp = ntohs(gbp->policy_id);
>
> -               if (tun_dst)
> +               if (tun_dst) {
>                         tun_dst->u.tun_info.key.tun_flags |= TUNNEL_VXLAN_OPT;
> +                       tun_dst->u.tun_info.options_len = sizeof(*md);
> +               }
>

Why not set it in tun_rx_dst() where it is allocated?

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

* Re: [PATCH net] vxlan: fix missing options_len update on RX with collect metadata
  2016-03-03  1:21 ` Cong Wang
@ 2016-03-03  8:58   ` Daniel Borkmann
  2016-03-04  0:16     ` Cong Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Borkmann @ 2016-03-03  8:58 UTC (permalink / raw)
  To: Cong Wang
  Cc: David Miller, Thomas Graf, Pravin B Shelar, jesse,
	Linux Kernel Network Developers

On 03/03/2016 02:21 AM, Cong Wang wrote:
> On Tue, Mar 1, 2016 at 5:32 PM, Daniel Borkmann <daniel@iogearbox.net> wrote:
>> When signalling to metadata consumers that the metadata_dst entry
>> carries additional GBP extension data for vxlan (TUNNEL_VXLAN_OPT),
>> the dst's vxlan_metadata information is populated, but options_len
>> is left to zero. F.e. in ovs, ovs_flow_key_extract() checks for
>> options_len before extracting the data through ip_tunnel_info_opts_get().
>>
>> Geneve uses ip_tunnel_info_opts_set() helper in receive path, which
>> sets options_len internally, vxlan however uses ip_tunnel_info_opts(),
>> so when filling vxlan_metadata, we do need to update options_len.
>>
>> Fixes: 4c22279848c5 ("ip-tunnel: Use API to access tunnel metadata options.")
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>> ---
>>   drivers/net/vxlan.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
>> index b601139..1c32bd1 100644
>> --- a/drivers/net/vxlan.c
>> +++ b/drivers/net/vxlan.c
>> @@ -1308,8 +1308,10 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
>>                  gbp = (struct vxlanhdr_gbp *)vxh;
>>                  md->gbp = ntohs(gbp->policy_id);
>>
>> -               if (tun_dst)
>> +               if (tun_dst) {
>>                          tun_dst->u.tun_info.key.tun_flags |= TUNNEL_VXLAN_OPT;
>> +                       tun_dst->u.tun_info.options_len = sizeof(*md);
>> +               }
>>
>
> Why not set it in tun_rx_dst() where it is allocated?

Nope, current convention is to only fill options_len when an actual
option was detected on RX, f.e. see ip_tunnel_info_opts_set() in
geneve. Consumers like ovs_flow_key_extract() check for options_len
and not TUNNEL_OPTIONS_PRESENT to copy it via ip_tunnel_info_opts_get()
from there.

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

* Re: [PATCH net] vxlan: fix missing options_len update on RX with collect metadata
  2016-03-02  1:32 [PATCH net] vxlan: fix missing options_len update on RX with collect metadata Daniel Borkmann
  2016-03-03  1:21 ` Cong Wang
@ 2016-03-03 10:33 ` Thomas Graf
  2016-03-03 22:11 ` David Miller
  2 siblings, 0 replies; 7+ messages in thread
From: Thomas Graf @ 2016-03-03 10:33 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: davem, pshelar, jesse, netdev

On 03/02/16 at 02:32am, Daniel Borkmann wrote:
> When signalling to metadata consumers that the metadata_dst entry
> carries additional GBP extension data for vxlan (TUNNEL_VXLAN_OPT),
> the dst's vxlan_metadata information is populated, but options_len
> is left to zero. F.e. in ovs, ovs_flow_key_extract() checks for
> options_len before extracting the data through ip_tunnel_info_opts_get().
> 
> Geneve uses ip_tunnel_info_opts_set() helper in receive path, which
> sets options_len internally, vxlan however uses ip_tunnel_info_opts(),
> so when filling vxlan_metadata, we do need to update options_len.
> 
> Fixes: 4c22279848c5 ("ip-tunnel: Use API to access tunnel metadata options.")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Acked-by: Thomas Graf <tgraf@suug.ch>

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

* Re: [PATCH net] vxlan: fix missing options_len update on RX with collect metadata
  2016-03-02  1:32 [PATCH net] vxlan: fix missing options_len update on RX with collect metadata Daniel Borkmann
  2016-03-03  1:21 ` Cong Wang
  2016-03-03 10:33 ` Thomas Graf
@ 2016-03-03 22:11 ` David Miller
  2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-03-03 22:11 UTC (permalink / raw)
  To: daniel; +Cc: tgraf, pshelar, jesse, netdev

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Wed,  2 Mar 2016 02:32:08 +0100

> When signalling to metadata consumers that the metadata_dst entry
> carries additional GBP extension data for vxlan (TUNNEL_VXLAN_OPT),
> the dst's vxlan_metadata information is populated, but options_len
> is left to zero. F.e. in ovs, ovs_flow_key_extract() checks for
> options_len before extracting the data through ip_tunnel_info_opts_get().
> 
> Geneve uses ip_tunnel_info_opts_set() helper in receive path, which
> sets options_len internally, vxlan however uses ip_tunnel_info_opts(),
> so when filling vxlan_metadata, we do need to update options_len.
> 
> Fixes: 4c22279848c5 ("ip-tunnel: Use API to access tunnel metadata options.")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Applied and queued up for -stable, thanks Daniel.

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

* Re: [PATCH net] vxlan: fix missing options_len update on RX with collect metadata
  2016-03-03  8:58   ` Daniel Borkmann
@ 2016-03-04  0:16     ` Cong Wang
  2016-03-04  2:22       ` Daniel Borkmann
  0 siblings, 1 reply; 7+ messages in thread
From: Cong Wang @ 2016-03-04  0:16 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: David Miller, Thomas Graf, Pravin B Shelar, jesse,
	Linux Kernel Network Developers

On Thu, Mar 3, 2016 at 12:58 AM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 03/03/2016 02:21 AM, Cong Wang wrote:
>>
>> Why not set it in tun_rx_dst() where it is allocated?
>
>
> Nope, current convention is to only fill options_len when an actual
> option was detected on RX, f.e. see ip_tunnel_info_opts_set() in
> geneve. Consumers like ovs_flow_key_extract() check for options_len
> and not TUNNEL_OPTIONS_PRESENT to copy it via ip_tunnel_info_opts_get()
> from there.

But the APIs suck...

You expect to use ip_tunnel_info_opts_{get,set}() to read or write
the tun_info, but actually this is not the case here for vxlan.

Also, ip_tunnel_info_opts_set() could write out of range if the len is
bigger than the allocated length. I know existing callers are fine, but this API
is problematic.

I think this is why we had this bug.

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

* Re: [PATCH net] vxlan: fix missing options_len update on RX with collect metadata
  2016-03-04  0:16     ` Cong Wang
@ 2016-03-04  2:22       ` Daniel Borkmann
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Borkmann @ 2016-03-04  2:22 UTC (permalink / raw)
  To: Cong Wang
  Cc: David Miller, Thomas Graf, Pravin B Shelar, jesse,
	Linux Kernel Network Developers

On 03/04/2016 01:16 AM, Cong Wang wrote:
> On Thu, Mar 3, 2016 at 12:58 AM, Daniel Borkmann <daniel@iogearbox.net> wrote:
>> On 03/03/2016 02:21 AM, Cong Wang wrote:
>>>
>>> Why not set it in tun_rx_dst() where it is allocated?
>>
>> Nope, current convention is to only fill options_len when an actual
>> option was detected on RX, f.e. see ip_tunnel_info_opts_set() in
>> geneve. Consumers like ovs_flow_key_extract() check for options_len
>> and not TUNNEL_OPTIONS_PRESENT to copy it via ip_tunnel_info_opts_get()
>> from there.
>
> But the APIs suck...
>
> You expect to use ip_tunnel_info_opts_{get,set}() to read or write
> the tun_info, but actually this is not the case here for vxlan.

Yep, since depending on the working mode either skb->mark is populated
or the tunnel opts buffer.

> Also, ip_tunnel_info_opts_set() could write out of range if the len is
> bigger than the allocated length. I know existing callers are fine, but this API
> is problematic.

Current call sites are good agree, API could probably be better, yeah.

> I think this is why we had this bug.

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

end of thread, other threads:[~2016-03-04  2:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-02  1:32 [PATCH net] vxlan: fix missing options_len update on RX with collect metadata Daniel Borkmann
2016-03-03  1:21 ` Cong Wang
2016-03-03  8:58   ` Daniel Borkmann
2016-03-04  0:16     ` Cong Wang
2016-03-04  2:22       ` Daniel Borkmann
2016-03-03 10:33 ` Thomas Graf
2016-03-03 22:11 ` David Miller

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.