ip_tunnel: Don't allow to add the same tunnel multiple times.
Subsystems (3)
PATCH 1/1 ip_tunnel: Don't allow to add the same tunnel multiple times.
When we try to add an already existing tunnel, we don't return an error. Instead we continue and call ip_tunnel_update(). This means that we can change existing tunnels by adding the same tunnel multiple times. It is even possible to change the tunnel endpoints of the fallback device.
We fix this by returning an error if we try to add an existing tunnel.
---
I was not able to find a commit that introduced this bug. Looks like ipip and ip_gre had similar bugs already with the initial git commit.
net/ipv4/ip_tunnel.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
net/ipv4/ip_tunnel.c +8 -3
@@ -764,9 +764,14 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) t =ip_tunnel_find (itn, p, itn->fb_tunnel_dev->type); -if (!t && (cmd ==SIOCADDTUNNEL )) { - t =ip_tunnel_create (net, itn, p); - err =PTR_ERR_OR_ZERO (t); +if (cmd ==SIOCADDTUNNEL ) { +if (!t) { + t =ip_tunnel_create (net, itn, p); + err =PTR_ERR_OR_ZERO (t); +break ; + } + + err = -EEXIST ;break ; }if (dev != itn->fb_tunnel_dev && cmd ==SIOCCHGTUNNEL ) {
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Steffen Klassert <[email protected]>
Date: Mon, 22 Sep 2014 09:11:08 +0200
Quoted 9 lines
When we try to add an already existing tunnel, we don't return an error. Instead we continue and call
ip_tunnel_update(). This means that we can change existing tunnels by adding the same tunnel multiple times. It is even possible to change the tunnel endpoints of the fallback device.We fix this by returning an error if we try to add an existing tunnel.
Quoted 6 lines
Signed-off-by Steffen Klassert <[email protected]>---
I was not able to find a commit that introduced this bug. Looks like ipip and
ip_grehad similar bugs already with the initial git commit.
I'm not so sure about this, perhaps the behavior of being able to change a configuration using an ADD call is intentional?
Quoted 15 lines · David Miller
From: Steffen Klassert <[email protected]>
Date: Mon, 22 Sep 2014 09:11:08 +0200Quoted 12 lines
When we try to add an already existing tunnel, we don't return an error. Instead we continue and call
ip_tunnel_update(). This means that we can change existing tunnels by adding the same tunnel multiple times. It is even possible to change the tunnel endpoints of the fallback device.We fix this by returning an error if we try to add an existing tunnel.
Signed-off-by Steffen Klassert <[email protected]>---
Quoted 6 lines
Quoted 3 lines
I was not able to find a commit that introduced this bug. Looks like ipip and
ip_grehad similar bugs already with the initial git commit.I'm not so sure about this, perhaps the behavior of being able to change a configuration using an ADD call is intentional?
Hm, I don't think so. Initially it was the same like with ipv6. It was possible to add the same tunnel muliple times without getting an error, no config change was made. The possibilty to change the configuration by adding the same tunnel a second time came with the tunnel code unification.
I think we should return an error if a tunnel configuration is added a second time. Otherwise we can do something like:
ip tunnel add name tunl1 mode ipip local 0.0.0.0 remote 0.0.0.0 ip tunnel add name tunl2 mode ipip local 0.0.0.0 remote 0.0.0.0 ip tunnel add name tunl3 mode ipip local 0.0.0.0 remote 0.0.0.0
None of these tunnels is created because the configuration matches the fallback tunnel, but we don't notify the user about that.
David Miller
maintainerFrom: Steffen Klassert <[email protected]>
Date: Tue, 23 Sep 2014 13:30:51 +0200
Quoted 20 lines · David Miller
Quoted 19 lines
From: Steffen Klassert <[email protected]>
Date: Mon, 22 Sep 2014 09:11:08 +0200Quoted 15 lines
When we try to add an already existing tunnel, we don't return an error. Instead we continue and call
ip_tunnel_update(). This means that we can change existing tunnels by adding the same tunnel multiple times. It is even possible to change the tunnel endpoints of the fallback device.We fix this by returning an error if we try to add an existing tunnel.
Signed-off-by Steffen Klassert <[email protected]>---
I was not able to find a commit that introduced this bug. Looks like ipip and
ip_grehad similar bugs already with the initial git commit.
Quoted 8 lines
Quoted 2 lines
I'm not so sure about this, perhaps the behavior of being able to change a configuration using an ADD call is intentional?
Hm, I don't think so. Initially it was the same like with ipv6. It was possible to add the same tunnel muliple times without getting an error, no config change was made. The possibilty to change the configuration by adding the same tunnel a second time came with the tunnel code unification.
Ok, makes sense. Applied, thanks Steffen.
If I had a euro for every regression introduced by that tunnel unification patch set I'd be a rich man indeed :-/