CVE: CVE-2025-68174
Published: 2025-12-16
Description: In the Linux kernel, the following vulnerability has been resolved:

amd/amdkfd: enhance kfd process check in switch partition

current switch partition only check if kfd_processes_table is empty.
kfd_prcesses_table entry is deleted in kfd_process_notifier_release, but
kfd_process tear down is in kfd_process_wq_release.

consider two processes:

Process A (workqueue) -> kfd_process_wq_release -> Access kfd_node member
Process B switch partition -> amdgpu_xcp_pre_partition_switch -> amdgpu_amdkfd_device_fini_sw
-> kfd_node tear down.

Process A and B may trigger a race as shown in dmesg log.

This patch is to resolve the race by adding an atomic kfd_process counter
kfd_processes_count, it increment as create kfd process, decrement as
finish kfd_process_wq_release.

v2: Put kfd_processes_count per kfd_dev, move decrement to kfd_process_destroy_pdds
and bug fix. (Philip Yang)

[3[PII_REDACTED]02] divide error: 0000 [#1] SMP NOPTI
[3[PII_REDACTED]18]  i10nm_edac
[3[PII_REDACTED]18] CPU: 124 PID: 38435 Comm: kworker/124:0 Kdump: loaded Tainted
[3[PII_REDACTED]90] Workqueue: kfd_process_wq kfd_process_wq_release [amdgpu]
[3[PII_REDACTED]39]  nfit
[3[PII_REDACTED]57] RIP: 0010:kfd_get_num_sdma_engines+0x17/0x40 [amdgpu]
[3[PII_REDACTED]60] Code: 00 00 e9 ac 81 02 00 66 66 2e 0f 1f 84 00 00 00 00 00 90 0f 1f 44 00 00 48 8b 4f 08 48 8b b7 00 01 00 00 8b 81 58 26 03 00 99 <f7> be b8 01 00 00 80 b9 70 2e 00 00 00 74 0b 83 f8 02 ba 02 00 00
[3[PII_REDACTED]67]  x86_pkg_temp_thermal
[3[PII_REDACTED]29] RSP: 0018:ffffc900a0edfdd8 EFLAGS: 00010246
[3[PII_REDACTED]31] RAX: [PII_REDACTED] RBX: ffff8974e593b800 RCX: ffff[PII_REDACTED]00
[3[PII_REDACTED]31] RDX: [PII_REDACTED] RSI: ffff[PII_REDACTED]00 RDI: ffff888129151c00
[3[PII_REDACTED]32] RBP: ffff8883ad79d400 R08: [PII_REDACTED] R09: ffff8890d2750af4
[3[PII_REDACTED]32] R10: [PII_REDACTED] R11: [PII_REDACTED] R12: [PII_REDACTED]
[3[PII_REDACTED]33] R13: ffff8883ad79d400 R14: ffffe87ff662ba00 R15: ffff8974e593b800
[3[PII_REDACTED]33] FS:  [PII_REDACTED](0000) GS:ffff88fe7f600000(0000) knlGS:[PII_REDACTED]
[3[PII_REDACTED]34] CS:  0010 DS: 0000 ES: 0000 CR0: [PII_REDACTED]
[3[PII_REDACTED]34] CR2:[PII_REDACTED]d71000 CR3: 000000dd0e970004 CR4:[PII_REDACTED]770ee0
[3[PII_REDACTED]35] DR0: [PII_REDACTED] DR1: [PII_REDACTED] DR2: [PII_REDACTED]
[3[PII_REDACTED]35] DR3: [PII_REDACTED] DR6: 00000000fffe07f0 DR7: [PII_REDACTED]
[3[PII_REDACTED]36] PKRU: 55555554
[3[PII_REDACTED]36] Call Trace:
[3[PII_REDACTED]74]  deallocate_sdma_queue+0x38/0xa0 [amdgpu]
[3[PII_REDACTED]62]  process_termination_cpsch+0x1ed/0x480 [amdgpu]
[3[PII_REDACTED]54]  intel_powerclamp
[3[PII_REDACTED]31]  kfd_process_dequeue_from_all_devices+0x5b/0xc0 [amdgpu]
[3[PII_REDACTED]08]  kfd_process_wq_release+0x1a/0x1a0 [amdgpu]
[3[PII_REDACTED]16]  coretemp
[3[PII_REDACTED]16]  process_one_work+0x1ad/0x380
[3[PII_REDACTED]21]  worker_thread+0x49/0x310
[3[PII_REDACTED]63]  kvm_intel
[3[PII_REDACTED]41]  ? process_one_work+0x380/0x380
[3[PII_REDACTED]45]  kthread+0x118/0x140
[3[PII_REDACTED]47]  ? __kthread_bind_mask+0x60/0x60
[3[PII_REDACTED]50]  ret_from_fork+0x1f/0x30
[3[PII_REDACTED]53] Modules linked in: kpatch_20765354(OEK)
[3[PII_REDACTED]10]  kvm
[3[PII_REDACTED]34]  mptcp_diag xsk_diag raw_diag unix_diag af_packet_diag netlink_diag udp_diag act_pedit act_mirred act_vlan cls_flower kpatch_21951273(OEK) kpatch_18424469(OEK) kpatch_19749756(OEK)
[3[PII_REDACTED]62]  idxd_mdev
[3[PII_REDACTED]06]  kpatch_17971294(OEK) sch_ingress xt_conntrack amdgpu(OE) amdxcp(OE) amddrm_buddy(OE) amd_sched(OE) amdttm(OE) amdkcl(OE) intel_ifs iptable_mangle tcm_loop target_core_pscsi tcp_diag target_core_file inet_diag target_core_iblock target_core_user target_core_mod coldpgs kpatch_18383292(OEK) ip6table_nat ip6table_filter ip6_tables ip_set_hash_ipportip ip_set_hash_ipportnet ip_set_hash_ipport ip_set_bitmap_port xt_comment iptable_nat nf_nat iptable_filter ip_tables ip_set ip_vs_sh ip_vs_wrr ip_vs_rr ip_vs nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 sn_core_odd(OE) i40e overlay binfmt_misc tun bonding(OE) aisqos(OE) aisqo
---truncated---
References: https://git.kernel.org/stable/c/45da20e00d5da842e17dfc633072b127504f0d0e; https://git.kernel.org/stable/c/536d80f660ec12058e461f4db387ea42bee9250d