All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Stephen Hemminger <stephen@networkplumber.org>, netdev@vger.kernel.org
Cc: bluca@debian.org, Robin <imer@imer.cc>
Subject: Re: [PATCH iproute2] iptunnel: detect protocol mismatch on tunnel change
Date: Tue, 11 Apr 2023 09:55:25 -0600	[thread overview]
Message-ID: <ac05b04d-a7ad-3804-39fd-2267904e9f23@kernel.org> (raw)
In-Reply-To: <20230410233509.7616-1-stephen@networkplumber.org>

On 4/10/23 5:35 PM, Stephen Hemminger wrote:
> diff --git a/ip/iptunnel.c b/ip/iptunnel.c
> index 02c3670b469d..b6da145913d6 100644
> --- a/ip/iptunnel.c
> +++ b/ip/iptunnel.c
> @@ -17,6 +17,7 @@
>  #include <net/if_arp.h>
>  #include <linux/ip.h>
>  #include <linux/if_tunnel.h>
> +#include <linux/ip6_tunnel.h>
>  
>  #include "rt_names.h"
>  #include "utils.h"
> @@ -172,11 +173,20 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
>  			if (get_ifname(p->name, *argv))
>  				invarg("\"name\" not a valid ifname", *argv);
>  			if (cmd == SIOCCHGTUNNEL && count == 0) {
> -				struct ip_tunnel_parm old_p = {};
> +				union {
> +					struct ip_tunnel_parm ip_tnl;
> +					struct ip6_tnl_parm2 ip6_tnl;
> +				} old_p = {};'

That addresses the stack smashing, but ....

>  
>  				if (tnl_get_ioctl(*argv, &old_p))
>  					return -1;
> -				*p = old_p;
> +
> +				if (old_p.ip_tnl.iph.version != 4 ||
> +				    old_p.ip_tnl.iph.ihl != 5)

this field overlays laddr in ip6_tnl_parm2 which means there is a
collision in valid addresses.


> +					invarg("\"name\" is not an ip tunnel",
> +					       *argv);
> +
> +				*p = old_p.ip_tnl;
>  			}
>  		}
>  		count++;


  parent reply	other threads:[~2023-04-11 15:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10 23:35 [PATCH iproute2] iptunnel: detect protocol mismatch on tunnel change Stephen Hemminger
2023-04-11 10:09 ` Luca Boccassi
2023-04-11 15:55 ` David Ahern [this message]
2023-04-11 16:49   ` Stephen Hemminger
2023-04-14 20:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac05b04d-a7ad-3804-39fd-2267904e9f23@kernel.org \
    --to=dsahern@kernel.org \
    --cc=bluca@debian.org \
    --cc=imer@imer.cc \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.