Skip to content

Commit e006858

Browse files
idoschkuba-moo
authored andcommittedMar 12, 2024
nexthop: Fix splat with CONFIG_DEBUG_PREEMPT=y
Locally generated packets can increment the new nexthop statistics from process context, resulting in the following splat [1] due to preemption being enabled. Fix by using get_cpu_ptr() / put_cpu_ptr() which will which take care of disabling / enabling preemption. BUG: using smp_processor_id() in preemptible [00000000] code: ping/949 caller is nexthop_select_path+0xcf8/0x1e30 CPU: 12 PID: 949 Comm: ping Not tainted 6.8.0-rc7-custom-gcb450f605fae #11 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc38 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0xbd/0xe0 check_preemption_disabled+0xce/0xe0 nexthop_select_path+0xcf8/0x1e30 fib_select_multipath+0x865/0x18b0 fib_select_path+0x311/0x1160 ip_route_output_key_hash_rcu+0xe54/0x2720 ip_route_output_key_hash+0x193/0x380 ip_route_output_flow+0x25/0x130 raw_sendmsg+0xbab/0x34a0 inet_sendmsg+0xa2/0xe0 __sys_sendto+0x2ad/0x430 __x64_sys_sendto+0xe5/0x1c0 do_syscall_64+0xc5/0x1d0 entry_SYSCALL_64_after_hwframe+0x63/0x6b [...] Fixes: f4676ea ("net: nexthop: Add nexthop group entry stats") Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d8a2107 commit e006858

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎net/ipv4/nexthop.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,11 @@ static void nh_grp_entry_stats_inc(struct nh_grp_entry *nhge)
674674
{
675675
struct nh_grp_entry_stats *cpu_stats;
676676

677-
cpu_stats = this_cpu_ptr(nhge->stats);
677+
cpu_stats = get_cpu_ptr(nhge->stats);
678678
u64_stats_update_begin(&cpu_stats->syncp);
679679
u64_stats_inc(&cpu_stats->packets);
680680
u64_stats_update_end(&cpu_stats->syncp);
681+
put_cpu_ptr(cpu_stats);
681682
}
682683

683684
static void nh_grp_entry_stats_read(struct nh_grp_entry *nhge,

0 commit comments

Comments
 (0)
Please sign in to comment.