ipip: fix a regression in ioctl
Subsystems (3)
PATCH 1/1 ipip: fix a regression in ioctl
From: Cong Wang <[email protected]>
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.
---
net/ipv4/ipip.c +5 -5
@@ -244,11 +244,11 @@ 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 ; + }if (p.iph.ttl) p.iph.frag_off |=htons (IP_DF );
Quoted 25 lines · Cong Wang
From: Cong Wang <[email protected]>
This is a regression introduced by
commitfd58156e456d9f68fe0448(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_keyetc. is suspicious too, which did not exist before.Cc Pravin B Shelar <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Cong Wang <[email protected]>---
net/ipv4/ipip.c +0
-0@@ -244,11 +244,11 @@ ipip_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)if (copy_from_user (&p, ifr->ifr_ifru.ifru_data,sizeof (p)))
net/ipv4/ipip.c ipip_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · line 249
Quoted 10 lines
net/ipv4/ipip.c +3
-5return -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 )))
Maybe it's time to put spaces around & to make code formatting more
consistent here too?
WBR, Sergei
Quoted 5 lines · Cong Wang
From: Cong Wang <[email protected]>
This is a regression introduced by
commitfd58156e456d9f68fe0448(IPIP: Use ip-tunneling code.)
Quoted 9 lines
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_keyetc. is suspicious too, which did not exist before.
This check is sanity check since ipip is not suppose to have these parameters set, generic layer do allow all parameters.
Earlier ipip was not using generic layer, therefore that check was not present.
Quoted 26 lines
Cc Pravin B Shelar <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Cong Wang <[email protected]>---
net/ipv4/ipip.c +5
-5@@ -244,11 +244,11 @@ 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 ; + }if (p.iph.ttl) p.iph.frag_off |=htons (IP_DF );
Quoted 10 lines · Pravin Shelar
Quoted 9 lines · Cong Wang
From: Cong Wang <[email protected]>
This is a regression introduced by
commitfd58156e456d9f68fe0448(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.
Quoted 8 lines
Quoted 5 lines
So, just check for SIOCADDTUNNEL and SIOCCHGTUNNEL.
Also, the check for
i_key,o_keyetc. is suspicious too, which did not exist before.This check is sanity check since ipip is not suppose to have these parameters set, generic layer do allow all parameters.
Earlier ipip was not using generic layer, therefore that check was not present.
So, if old code doesn't reject this case with EINVAL, then your change _does_ break user-space applications... no matter whether ipip is supposed to have these parameters.
Quoted 16 lines · Cong Wang
Quoted 15 lines · Pravin Shelar
Quoted 14 lines · Cong Wang
From: Cong Wang <[email protected]>
This is a regression introduced by
commitfd58156e456d9f68fe0448(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_keyetc. is suspicious too, which did not exist before.
Quoted 8 lines
Quoted 3 lines
This check is sanity check since ipip is not suppose to have these parameters set, generic layer do allow all parameters.
Earlier ipip was not using generic layer, therefore that check was not present.So, if old code doesn't reject this case with EINVAL, then your change _does_ break user-space applications... no matter whether ipip is supposed to have these parameters.
ok, Then we shld reset these fields before passing them to ip_tunnels layer.
Quoted 1 line
David Miller
maintainerFrom: Pravin Shelar <[email protected]>
Date: Mon, 1 Jul 2013 08:03:33 -0700
Quoted 21 lines · Cong Wang
Quoted 20 lines · Pravin Shelar
Quoted 18 lines · Cong Wang
Quoted 5 lines
From: Cong Wang <[email protected]>
This is a regression introduced by
commitfd58156e456d9f68fe0448(IPIP: Use ip-tunneling code.)Quoted 9 lines
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_keyetc. is suspicious too, which did not exist before.This check is sanity check since ipip is not suppose to have these parameters set, generic layer do allow all parameters.
Earlier ipip was not using generic layer, therefore that check was not present.
Quoted 5 lines
Quoted 4 lines
So, if old code doesn't reject this case with EINVAL, then your change _does_ break user-space applications... no matter whether ipip is supposed to have these parameters.
ok, Then we shld reset these fields before passing them to
ip_tunnelslayer.
Someone please respin this to clear the fields instead, thanks!
Quoted 5 lines · David Miller
From: Pravin Shelar <[email protected]>
Quoted 2 lines
Quoted 1 line
ok, Then we shld reset these fields before passing them to
ip_tunnelslayer.Someone please respin this to clear the fields instead, thanks!
I will send v2.
Thanks!