Commit 3b7b514f44bff05d26a6499c4d4fac2a83938e6e

Authored by Cong Wang
Committed by David S. Miller
1 parent e1558a93b6

ipip: fix a regression in ioctl

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 7 additions and 5 deletions Side-by-side Diff

... ... @@ -244,11 +244,13 @@
244 244 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
245 245 return -EFAULT;
246 246  
247   - if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP ||
248   - p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)))
249   - return -EINVAL;
250   - if (p.i_key || p.o_key || p.i_flags || p.o_flags)
251   - return -EINVAL;
  247 + if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
  248 + if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP ||
  249 + p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)))
  250 + return -EINVAL;
  251 + }
  252 +
  253 + p.i_key = p.o_key = p.i_flags = p.o_flags = 0;
252 254 if (p.iph.ttl)
253 255 p.iph.frag_off |= htons(IP_DF);
254 256