Commit bb1553c8 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

ip_tunnel: Add sanity checks to ip_tunnel_encap_add_ops()

The symbols are exported and could be used by external modules.

Fixes: a8c5f9 ("ip_tunnel: Ops registration for secondary encap (fou, gue)")
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c9f2c3d3
...@@ -514,6 +514,9 @@ const struct ip_tunnel_encap_ops __rcu * ...@@ -514,6 +514,9 @@ const struct ip_tunnel_encap_ops __rcu *
int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *ops, int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *ops,
unsigned int num) unsigned int num)
{ {
if (num >= MAX_IPTUN_ENCAP_OPS)
return -ERANGE;
return !cmpxchg((const struct ip_tunnel_encap_ops **) return !cmpxchg((const struct ip_tunnel_encap_ops **)
&iptun_encaps[num], &iptun_encaps[num],
NULL, ops) ? 0 : -1; NULL, ops) ? 0 : -1;
...@@ -525,6 +528,9 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *ops, ...@@ -525,6 +528,9 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *ops,
{ {
int ret; int ret;
if (num >= MAX_IPTUN_ENCAP_OPS)
return -ERANGE;
ret = (cmpxchg((const struct ip_tunnel_encap_ops **) ret = (cmpxchg((const struct ip_tunnel_encap_ops **)
&iptun_encaps[num], &iptun_encaps[num],
ops, NULL) == ops) ? 0 : -1; ops, NULL) == ops) ? 0 : -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment