Skip to content

Commit

Permalink
ipip: fix a regression in ioctl
Browse files Browse the repository at this point in the history
[ Upstream commit 3b7b514 ]

This is a regression introduced by
commit fd58156 (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().

Signed-off-by: Cong Wang <[email protected]>
Cc: Pravin B Shelar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Cong Wang authored and gregkh committed Jul 28, 2013
1 parent ed7f614 commit 0e7eade
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions net/ipv4/ipip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0e7eade

Please sign in to comment.