提交 dcebd315 编写于 作者: F Florian Westphal 提交者: Pablo Neira Ayuso

netfilter: add and use jump label for xt_tee

Don't bother testing if we need to switch to alternate stack
unless TEE target is used.
Suggested-by: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NFlorian Westphal <fw@strlen.de>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
上级 7814b6ec
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/static_key.h>
#include <uapi/linux/netfilter/x_tables.h> #include <uapi/linux/netfilter/x_tables.h>
/** /**
...@@ -280,6 +281,12 @@ void xt_free_table_info(struct xt_table_info *info); ...@@ -280,6 +281,12 @@ void xt_free_table_info(struct xt_table_info *info);
*/ */
DECLARE_PER_CPU(seqcount_t, xt_recseq); DECLARE_PER_CPU(seqcount_t, xt_recseq);
/* xt_tee_enabled - true if x_tables needs to handle reentrancy
*
* Enabled if current ip(6)tables ruleset has at least one -j TEE rule.
*/
extern struct static_key xt_tee_enabled;
/** /**
* xt_write_recseq_begin - start of a write section * xt_write_recseq_begin - start of a write section
* *
......
...@@ -340,6 +340,7 @@ ipt_do_table(struct sk_buff *skb, ...@@ -340,6 +340,7 @@ ipt_do_table(struct sk_buff *skb,
* For recursion via REJECT or SYNPROXY the stack will be clobbered * For recursion via REJECT or SYNPROXY the stack will be clobbered
* but it is no problem since absolute verdict is issued by these. * but it is no problem since absolute verdict is issued by these.
*/ */
if (static_key_false(&xt_tee_enabled))
jumpstack += private->stacksize * __this_cpu_read(nf_skb_duplicated); jumpstack += private->stacksize * __this_cpu_read(nf_skb_duplicated);
e = get_entry(table_base, private->hook_entry[hook]); e = get_entry(table_base, private->hook_entry[hook]);
......
...@@ -366,6 +366,7 @@ ip6t_do_table(struct sk_buff *skb, ...@@ -366,6 +366,7 @@ ip6t_do_table(struct sk_buff *skb,
* For recursion via REJECT or SYNPROXY the stack will be clobbered * For recursion via REJECT or SYNPROXY the stack will be clobbered
* but it is no problem since absolute verdict is issued by these. * but it is no problem since absolute verdict is issued by these.
*/ */
if (static_key_false(&xt_tee_enabled))
jumpstack += private->stacksize * __this_cpu_read(nf_skb_duplicated); jumpstack += private->stacksize * __this_cpu_read(nf_skb_duplicated);
e = get_entry(table_base, private->hook_entry[hook]); e = get_entry(table_base, private->hook_entry[hook]);
......
...@@ -727,6 +727,9 @@ EXPORT_SYMBOL_GPL(xt_compat_unlock); ...@@ -727,6 +727,9 @@ EXPORT_SYMBOL_GPL(xt_compat_unlock);
DEFINE_PER_CPU(seqcount_t, xt_recseq); DEFINE_PER_CPU(seqcount_t, xt_recseq);
EXPORT_PER_CPU_SYMBOL_GPL(xt_recseq); EXPORT_PER_CPU_SYMBOL_GPL(xt_recseq);
struct static_key xt_tee_enabled __read_mostly;
EXPORT_SYMBOL_GPL(xt_tee_enabled);
static int xt_jumpstack_alloc(struct xt_table_info *i) static int xt_jumpstack_alloc(struct xt_table_info *i)
{ {
unsigned int size; unsigned int size;
......
...@@ -251,6 +251,7 @@ static int tee_tg_check(const struct xt_tgchk_param *par) ...@@ -251,6 +251,7 @@ static int tee_tg_check(const struct xt_tgchk_param *par)
} else } else
info->priv = NULL; info->priv = NULL;
static_key_slow_inc(&xt_tee_enabled);
return 0; return 0;
} }
...@@ -262,6 +263,7 @@ static void tee_tg_destroy(const struct xt_tgdtor_param *par) ...@@ -262,6 +263,7 @@ static void tee_tg_destroy(const struct xt_tgdtor_param *par)
unregister_netdevice_notifier(&info->priv->notifier); unregister_netdevice_notifier(&info->priv->notifier);
kfree(info->priv); kfree(info->priv);
} }
static_key_slow_dec(&xt_tee_enabled);
} }
static struct xt_target tee_tg_reg[] __read_mostly = { static struct xt_target tee_tg_reg[] __read_mostly = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册