mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	ipip: fix a regression in ioctl
This is a regression introduced by
commit fd58156e45 (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>
			
			
This commit is contained in:
		
							parent
							
								
									e1558a93b6
								
							
						
					
					
						commit
						3b7b514f44
					
				
					 1 changed files with 7 additions and 5 deletions
				
			
		| 
						 | 
					@ -244,11 +244,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)))
 | 
						if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
 | 
				
			||||||
		return -EFAULT;
 | 
							return -EFAULT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP ||
 | 
						if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
 | 
				
			||||||
			p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)))
 | 
							if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP ||
 | 
				
			||||||
		return -EINVAL;
 | 
							    p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)))
 | 
				
			||||||
	if (p.i_key || p.o_key || p.i_flags || p.o_flags)
 | 
								return -EINVAL;
 | 
				
			||||||
		return -EINVAL;
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						p.i_key = p.o_key = p.i_flags = p.o_flags = 0;
 | 
				
			||||||
	if (p.iph.ttl)
 | 
						if (p.iph.ttl)
 | 
				
			||||||
		p.iph.frag_off |= htons(IP_DF);
 | 
							p.iph.frag_off |= htons(IP_DF);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue