public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch net v2] ipip: fix a regression in ioctl
@ 2013-07-02  6:49 Cong Wang
  2013-07-02  8:13 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2013-07-02  6:49 UTC (permalink / raw)
  To: netdev; +Cc: Pravin B Shelar, David S. Miller, Cong Wang

From: Cong Wang <amwang@redhat.com>

This is a regression introduced by 
commit fd58156e456d9f68fe0448 (IPIP: Use ip-tunneling code.)

Similar to GRE tunnel, previously we only check the parameters
for SIOCADDTUNNEL and SIOCCHGTUNNEL, after that commit, the
check is moved for all commands.

So, just check for SIOCADDTUNNEL and SIOCCHGTUNNEL.

Also, the check for i_key, o_key etc. is suspicious too,
which did not exist before, reset them before passing
to ip_tunnel_ioctl().

Cc: Pravin B Shelar <pshelar@nicira.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
---
v2: reset *_key and *_flags before passing them to ip_tunnel_ioctl

 net/ipv4/ipip.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 77bfcce..7cfc456 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -240,11 +240,13 @@ ipip_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
 		return -EFAULT;
 
-	if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP ||
-			p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)))
-		return -EINVAL;
-	if (p.i_key || p.o_key || p.i_flags || p.o_flags)
-		return -EINVAL;
+	if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
+		if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP ||
+		    p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)))
+			return -EINVAL;
+	}
+
+	p.i_key = p.o_key = p.i_flags = p.o_flags = 0;
 	if (p.iph.ttl)
 		p.iph.frag_off |= htons(IP_DF);
 

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

* Re: [Patch net v2] ipip: fix a regression in ioctl
  2013-07-02  6:49 [Patch net v2] ipip: fix a regression in ioctl Cong Wang
@ 2013-07-02  8:13 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-07-02  8:13 UTC (permalink / raw)
  To: amwang; +Cc: netdev, pshelar

From: Cong Wang <amwang@redhat.com>
Date: Tue,  2 Jul 2013 14:49:34 +0800

> From: Cong Wang <amwang@redhat.com>
> 
> This is a regression introduced by 
> commit fd58156e456d9f68fe0448 (IPIP: Use ip-tunneling code.)
> 
> Similar to GRE tunnel, previously we only check the parameters
> for SIOCADDTUNNEL and SIOCCHGTUNNEL, after that commit, the
> check is moved for all commands.
> 
> So, just check for SIOCADDTUNNEL and SIOCCHGTUNNEL.
> 
> Also, the check for i_key, o_key etc. is suspicious too,
> which did not exist before, reset them before passing
> to ip_tunnel_ioctl().
> 
> Cc: Pravin B Shelar <pshelar@nicira.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>

Applied and queued up for -stable, thanks!

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

end of thread, other threads:[~2013-07-02  8:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-02  6:49 [Patch net v2] ipip: fix a regression in ioctl Cong Wang
2013-07-02  8:13 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox