ip_tunnel fixes
Subsystems (3)
cover ip_tunnel fixes
Thomas Graf (2):
ip_tunnel: Add sanity checks to ip_tunnel_encap_add_ops()
ip_tunnel: Add missing validation of encap type to
ip_tunnel_encap_setup()
net/ipv4/ip_tunnel.c | 9 +++++++++ 1 file changed, 9 insertions(+)
Signature · 1 line
1.9.3
PATCH 1/2 ip_tunnel: Add sanity checks to ip_tunnel_encap_add_ops()
The symbols are exported and could be used by external modules.
--- net/ipv4/ip_tunnel.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/ip_tunnel.c +6 -0
@@ -514,6 +514,9 @@ const struct ip_tunnel_encap_ops __rcu *int ip_tunnel_encap_add_ops (const struct ip_tunnel_encap_ops *ops,unsigned int num) { +if (num >=MAX_IPTUN_ENCAP_OPS ) +return -ERANGE ; +return !cmpxchg ((const struct ip_tunnel_encap_ops **) &iptun_encaps[num],NULL , ops) ?0 :-1 ;
@@ -525,6 +528,9 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *ops, {int ret; +if (num >=MAX_IPTUN_ENCAP_OPS ) +return -ERANGE ; + ret = (cmpxchg ((const struct ip_tunnel_encap_ops **) &iptun_encaps[num], ops,NULL ) == ops) ?0 :-1 ;
Signature · 1 line
1.9.3
PATCH 2/2 ip_tunnel: Add missing validation of encap type to ip_tunnel_encap_setup()
In reply to Thomas GrafThe encap->type comes straight from Netlink. Validate it against max supported encap types just like ip_encap_hlen() already does.
--- net/ipv4/ip_tunnel.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/ip_tunnel.c +3 -0
@@ -573,6 +573,9 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,if (t->encap.type ==TUNNEL_ENCAP_NONE )return 0 ; +if (t->encap.type >=MAX_IPTUN_ENCAP_OPS ) +return -EINVAL ; +rcu_read_lock (); ops =rcu_dereference (iptun_encaps[t->encap.type]);if (likely (ops && ops->build_header))
Signature · 1 line
1.9.3
Re: [PATCH 2/2] ip_tunnel: Add missing validation of encap type to ip_tunnel_encap_setup()
Quoted 14 lines · Thomas Graf
The
encap->typecomes straight from Netlink. Validate it against max supported encap types just likeip_encap_hlen()already does.Fixes a8c5f9 ("ip_tunnel: Ops registration for secondary encap (fou, gue)")Signed-off-by Thomas Graf <[email protected]>--- net/ipv4/ip_tunnel.c | 3 +++ 1 file changed, 3 insertions(+)net/ipv4/ip_tunnel.c +0
-0
net/ipv4/ip_tunnel.c int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, · line 578
Quoted 6 lines
net/ipv4/ip_tunnel.c +3
-0@@ -573,6 +573,9 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,if (t->encap.type ==TUNNEL_ENCAP_NONE )return 0 ; +if (t->encap.type >=MAX_IPTUN_ENCAP_OPS ) +return -EINVAL ; +
I don't think this is technically needed, we should have already verified the type when setting up the tunnel (ip_encap_hlen).
Quoted 6 lines
net/ipv4/ip_tunnel.c +0
-1rcu_read_lock (); ops =rcu_dereference (iptun_encaps[t->encap.type]);if (likely (ops && ops->build_header)) --1.9.3
Re: [PATCH 2/2] ip_tunnel: Add missing validation of encap type to ip_tunnel_encap_setup()
Quoted 18 lines · Tom Herbert
Quoted 17 lines · Thomas Graf
The
encap->typecomes straight from Netlink. Validate it against max supported encap types just likeip_encap_hlen()already does.Fixes a8c5f9 ("ip_tunnel: Ops registration for secondary encap (fou, gue)")Signed-off-by Thomas Graf <[email protected]>--- net/ipv4/ip_tunnel.c | 3 +++ 1 file changed, 3 insertions(+)net/ipv4/ip_tunnel.c +0
-0@@ -573,6 +573,9 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,if (t->encap.type ==TUNNEL_ENCAP_NONE )return 0 ;
Quoted 6 lines
net/ipv4/ip_tunnel.c int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, · line 578
Quoted 3 lines
net/ipv4/ip_tunnel.c +3
-0+if (t->encap.type >=MAX_IPTUN_ENCAP_OPS ) +return -EINVAL ; +I don't think this is technically needed, we should have already verified the type when setting up the tunnel (
ip_encap_hlen).
Right, assuming that every API user always calls ip_tunnel_encap_setup() on changelink. It's currently the case but since this is a exported API I figured we better be safe than sorry, in particular as ip_tunnel_encap() is called before ip_encap_hlen() on xmit.
David Miller
maintainerFrom: Thomas Graf <[email protected]>
Date: Tue, 16 Dec 2014 21:05:19 +0100
Quoted 4 lines
Thomas Graf (2):
ip_tunnel: Add sanity checks toip_tunnel_encap_add_ops()
ip_tunnel: Add missing validation of encap type to
ip_tunnel_encap_setup()
Both applied, thanks Thomas.