[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4f7b2b71-8b2a-3aea-637d-52b148af1802@iogearbox.net>
Date: Mon, 6 Jul 2020 22:01:58 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Toke Høiland-Jørgensen <toke@...hat.com>,
davem@...emloft.net
Cc: netdev@...r.kernel.org, cake@...ts.bufferbloat.net,
Davide Caratti <dcaratti@...hat.com>,
Jiri Pirko <jiri@...nulli.us>,
Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Toshiaki Makita <toshiaki.makita1@...il.com>
Subject: Re: [PATCH net] vlan: consolidate VLAN parsing code and limit max
parsing depth
On 7/6/20 2:29 PM, Toke Høiland-Jørgensen wrote:
> Toshiaki pointed out that we now have two very similar functions to extract
> the L3 protocol number in the presence of VLAN tags. And Daniel pointed out
> that the unbounded parsing loop makes it possible for maliciously crafted
> packets to loop through potentially hundreds of tags.
>
> Fix both of these issues by consolidating the two parsing functions and
> limiting the VLAN tag parsing to an arbitrarily-chosen, but hopefully
> conservative, max depth of 32 tags. As part of this, switch over
> __vlan_get_protocol() to use skb_header_pointer() instead of
> pskb_may_pull(), to avoid the possible side effects of the latter and keep
> the skb pointer 'const' through all the parsing functions.
>
> Reported-by: Toshiaki Makita <toshiaki.makita1@...il.com>
> Reported-by: Daniel Borkmann <daniel@...earbox.net>
> Fixes: d7bf2ebebc2b ("sched: consistently handle layer3 header accesses in the presence of VLANs")
> Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
> ---
> include/linux/if_vlan.h | 57 ++++++++++++++++-------------------------
> 1 file changed, 22 insertions(+), 35 deletions(-)
>
> diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
> index 427a5b8597c2..855d16192e6a 100644
> --- a/include/linux/if_vlan.h
> +++ b/include/linux/if_vlan.h
> @@ -25,6 +25,8 @@
> #define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */
> #define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */
>
> +#define VLAN_MAX_DEPTH 32 /* Max. number of nested VLAN tags parsed */
> +
Any insight on limits of nesting wrt QinQ, maybe from spec side? Why not 8 as max, for
example (I'd probably even consider a depth like this as utterly broken setup ..)?
Thanks,
Daniel
Powered by blists - more mailing lists