Skip to content

Commit c0aba80

Browse files
committed
dmaengine: idxd: Fix oops during rmmod on single-CPU platforms
jira LE-3201 cve CVE-2024-35989 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 commit-author Fenghua Yu <[email protected]> commit f221033 During the removal of the idxd driver, registered offline callback is invoked as part of the clean up process. However, on systems with only one CPU online, no valid target is available to migrate the perf context, resulting in a kernel oops: BUG: unable to handle page fault for address: 000000000002a2b8 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 1470e1067 P4D 0 Oops: 0002 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 20 Comm: cpuhp/0 Not tainted 6.8.0-rc6-dsa+ #57 Hardware name: Intel Corporation AvenueCity/AvenueCity, BIOS BHSDCRB1.86B.2492.D03.2307181620 07/18/2023 RIP: 0010:mutex_lock+0x2e/0x50 ... Call Trace: <TASK> __die+0x24/0x70 page_fault_oops+0x82/0x160 do_user_addr_fault+0x65/0x6b0 __pfx___rdmsr_safe_on_cpu+0x10/0x10 exc_page_fault+0x7d/0x170 asm_exc_page_fault+0x26/0x30 mutex_lock+0x2e/0x50 mutex_lock+0x1e/0x50 perf_pmu_migrate_context+0x87/0x1f0 perf_event_cpu_offline+0x76/0x90 [idxd] cpuhp_invoke_callback+0xa2/0x4f0 __pfx_perf_event_cpu_offline+0x10/0x10 [idxd] cpuhp_thread_fun+0x98/0x150 smpboot_thread_fn+0x27/0x260 smpboot_thread_fn+0x1af/0x260 __pfx_smpboot_thread_fn+0x10/0x10 kthread+0x103/0x140 __pfx_kthread+0x10/0x10 ret_from_fork+0x31/0x50 __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 <TASK> Fix the issue by preventing the migration of the perf context to an invalid target. Fixes: 81dd4d4 ("dmaengine: idxd: Add IDXD performance monitor support") Reported-by: Terrence Xu <[email protected]> Tested-by: Terrence Xu <[email protected]> Signed-off-by: Fenghua Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> (cherry picked from commit f221033) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 72173a6 commit c0aba80

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/dma/idxd/perfmon.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,11 @@ static int perf_event_cpu_offline(unsigned int cpu, struct hlist_node *node)
529529
return 0;
530530

531531
target = cpumask_any_but(cpu_online_mask, cpu);
532-
533532
/* migrate events if there is a valid target */
534-
if (target < nr_cpu_ids)
533+
if (target < nr_cpu_ids) {
535534
cpumask_set_cpu(target, &perfmon_dsa_cpu_mask);
536-
else
537-
target = -1;
538-
539-
perf_pmu_migrate_context(&idxd_pmu->pmu, cpu, target);
535+
perf_pmu_migrate_context(&idxd_pmu->pmu, cpu, target);
536+
}
540537

541538
return 0;
542539
}

0 commit comments

Comments
 (0)