]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfilter: xt_cpu: prefer raw_smp_processor_id
authorFlorian Westphal <fw@strlen.de>
Tue, 19 May 2026 18:10:08 +0000 (20:10 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 22 May 2026 10:28:46 +0000 (12:28 +0200)
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
 [..]

Just use raw version instead.
This is similar to 14d14a5d2957 ("netfilter: nft_meta: use raw_smp_processor_id()").

Fixes: 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables")
Reported-by: syzbot+690d3e3ffa7335ac10eb@syzkaller.appspotmail.com
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/xt_cpu.c

index 3bdc302a0f913796688b3e095eb5fb1be3e8bee4..9cb259902a586bd83136a611ca0ad1af745cd9e7 100644 (file)
@@ -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 = {