diff options
author | Hannes Frederic Sowa <hannes@stressinduktion.org> | 2016-01-18 18:03:48 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-01-18 12:09:45 -0500 |
commit | b064d0d88ae5280c7e878f79d0c9a8e2876a4d14 (patch) | |
tree | f4cbdf604f01fcd3c0bd25fe819aaa0cf8825b40 /net | |
parent | 60a6531bfe49555581ccd65f66a350cc5693fcde (diff) | |
download | linux-stable-b064d0d88ae5280c7e878f79d0c9a8e2876a4d14.tar.gz linux-stable-b064d0d88ae5280c7e878f79d0c9a8e2876a4d14.tar.bz2 linux-stable-b064d0d88ae5280c7e878f79d0c9a8e2876a4d14.zip |
ovs: limit ovs recursions in ovs_execute_actions to not corrupt stack
It was seen that defective configurations of openvswitch could overwrite
the STACK_END_MAGIC and cause a hard crash of the kernel because of too
many recursions within ovs.
This problem arises due to the high stack usage of openvswitch. The rest
of the kernel is fine with the current limit of 10 (RECURSION_LIMIT).
We use the already existing recursion counter in ovs_execute_actions to
implement an upper bound of 5 recursions.
Cc: Pravin Shelar <pshelar@ovn.org>
Cc: Simon Horman <simon.horman@netronome.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/openvswitch/actions.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index c88d0f2d3e01..2d59df521915 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -1160,17 +1160,26 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb, const struct sw_flow_actions *acts, struct sw_flow_key *key) { - int level = this_cpu_read(exec_actions_level); - int err; + static const int ovs_recursion_limit = 5; + int err, level; + + level = __this_cpu_inc_return(exec_actions_level); + if (unlikely(level > ovs_recursion_limit)) { + net_crit_ratelimited("ovs: recursion limit reached on datapath %s, probable configuration error\n", + ovs_dp_name(dp)); + kfree_skb(skb); + err = -ENETDOWN; + goto out; + } - this_cpu_inc(exec_actions_level); err = do_execute_actions(dp, skb, key, acts->actions, acts->actions_len); - if (!level) + if (level == 1) process_deferred_actions(dp); - this_cpu_dec(exec_actions_level); +out: + __this_cpu_dec(exec_actions_level); return err; } |