]> git.ipfire.org Git - thirdparty/iproute2.git/commit
iptunnel: detect protocol mismatch on tunnel change
authorStephen Hemminger <stephen@networkplumber.org>
Mon, 10 Apr 2023 23:22:51 +0000 (16:22 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 11 Apr 2023 16:21:50 +0000 (09:21 -0700)
commit8cc2eac60d5f1f5ec2c40d02c0003731c8b610dc
tree98c2b08972186586dd9c94fd8b8c0c3dcb79090f
parent009739adb92cfaab54e9e3f31ecdd7dcf4082e0c
iptunnel: detect protocol mismatch on tunnel change

If attempt is made to change an IPv6 tunnel by using IPv4
parameters, a stack overflow would happen and garbage request
would be passed to kernel.

Example:
ip tunnel add gre1 mode ip6gre local 2001:db8::1 remote 2001:db8::2 ttl 255
ip tunnel change gre1 mode gre local 192.168.0.0 remote 192.168.0.1 ttl 255

The second command should fail because it attempting set IPv4 addresses
on a GRE tunnel that is IPv6.

Do best effort detection of this mismatch by giving a bigger buffer to get
tunnel request, and checking that the IP header is IPv4. It is still possible
but unlikely that byte would match in IPv6 tunnel paramater, but good enough
to catch the obvious cases.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1032642
Tested-by: Luca Boccassi <bluca@debian.org>
Reported-by: Robin <imer@imer.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iptunnel.c