netfilter: xt_cpu: prefer raw_smp_processor_id
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: xt_cpu: prefer raw_smp_processor_id
With PREEMPT_RCU we get splat:
BUG: using smp_processor_id() in preemptible [..] caller is cpu_mt+0x53/0xd0 net/netfilter/xt_cpu.c:37 CPU: 1 .. Comm: syz.3.1377 #0 PREEMPT(full) Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 check_preemption_disabled+0xd3/0xe0 lib/smp_processor_id.c:47 cpu_mt+0x53/0xd0 net/netfilter/xt_cpu.c:37 [..]
Similar to 14d14a5d2957 ("netfilter: nft_meta: use raw_smp_processor_id()").
--- net/netfilter/xt_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_cpu.c +1 -1
@@ -34,7 +34,7 @@ static bool cpu_mt(const struct sk_buff *skb, struct xt_action_param *par) {const struct xt_cpu_info *info = par->matchinfo; -return (info->cpu ==smp_processor_id ()) ^ info->invert; +return (info->cpu ==raw_smp_processor_id ()) ^ info->invert; }static struct xt_match cpu_mt_reg__read_mostly = {
Signature · 1 line
2.53.0
Quoted 26 lines · Florian Westphal
With
PREEMPT_RCUwe get splat:BUG: using smp_processor_id() in preemptible [..] caller is cpu_mt+0x53/0xd0 net/netfilter/xt_cpu.c:37 CPU: 1 .. Comm: syz.3.1377 #0 PREEMPT(full) Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 check_preemption_disabled+0xd3/0xe0 lib/smp_processor_id.c:47 cpu_mt+0x53/0xd0 net/netfilter/xt_cpu.c:37 [..]Similar to
14d14a5d2957("netfilter:nft_meta: useraw_smp_processor_id()").Fixes 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables")Reported-by [email protected]Signed-off-by Florian Westphal <[email protected]>--- net/netfilter/xt_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/netfilter/xt_cpu.c +0
-0
net/netfilter/xt_cpu.c static bool cpu_mt(const struct sk_buff *skb, struct xt_action_param *par) · line 40
Quoted 8 lines
net/netfilter/xt_cpu.c +1
-1@@ -34,7 +34,7 @@ static bool cpu_mt(const struct sk_buff *skb, struct xt_action_param *par) {const struct xt_cpu_info *info = par->matchinfo; -return (info->cpu ==smp_processor_id ()) ^ info->invert; +return (info->cpu ==raw_smp_processor_id ()) ^ info->invert; }static struct xt_match cpu_mt_reg__read_mostly = {
Hi Florian,
I agree with the fix but the same should be needed for xt_NFQUEUE no?
I see I can use the compat layer to configure NFQUEUE target see:
# Warning: table ip filter is managed by iptables-nft, do not touch!
table ip filter {
chain FORWARD {
type filter hook forward priority filter; policy accept;
tcp dport 80 counter packets 0 bytes 0 xt target "NFQUEUE"
}
}I would suggest this too:
net/netfilter/xt_NFQUEUE.c +1 -1
@@ -91,7 +91,7 @@ nfqueue_tg_v3(struct sk_buff *skb, const struct xt_action_param *par)if (info->queues_total >1 ) {if (info->flags &NFQ_FLAG_CPU_FANOUT ) { -int cpu =smp_processor_id (); +int cpu =raw_smp_processor_id (); queue = info->queuenum + cpu % info->queues_total; }else {
Thanks,
Fernando.
Florian Westphal
maintainerQuoted 8 lines · Fernando Fernandez Mancera
I see I can use the compat layer to configure NFQUEUE target see:
# Warning: table ip filter is managed by iptables-nft, do not touch!
table ip filter { chain FORWARD { type filter hook forward priority filter; policy accept; tcp dport 80 counter packets 0 bytes 0 xt target "NFQUEUE" }
Please send a patch.
Quoted 11 lines · Florian Westphal
Quoted 8 lines · Fernando Fernandez Mancera
I see I can use the compat layer to configure NFQUEUE target see:
# Warning: table ip filter is managed by iptables-nft, do not touch!
table ip filter { chain FORWARD { type filter hook forward priority filter; policy accept; tcp dport 80 counter packets 0 bytes 0 xt target "NFQUEUE" }Please send a patch.
Sure!
Thanks Florian!