CVE: CVE-2025-38268
Published: 2025-07-10
Description: In the Linux kernel, the following vulnerability has been resolved:

usb: typec: tcpm: move tcpm_queue_vdm_unlocked to asynchronous work

A state check was previously added to tcpm_queue_vdm_unlocked to
prevent a deadlock where the DisplayPort Alt Mode driver would be
executing work and attempting to grab the tcpm_lock while the TCPM
was holding the lock and attempting to unregister the altmode, blocking
on the altmode driver's cancel_work_sync call.

Because the state check isn't protected, there is a small window
where the Alt Mode driver could determine that the TCPM is
in a ready state and attempt to grab the lock while the
TCPM grabs the lock and changes the TCPM state to one that
causes the deadlock. The callstack is provided below:

[[PII_REDACTED]92][    C7] Call trace:
[[PII_REDACTED]96][    C7]  __switch_to+0x174/0x338
[[PII_REDACTED]06][    C7]  __schedule+0x608/0x9f0
[[PII_REDACTED]14][    C7]  schedule+0x7c/0xe8
[[PII_REDACTED]23][    C7]  kernfs_drain+0xb0/0x114
[[PII_REDACTED]31][    C7]  __kernfs_remove+0x16c/0x20c
[[PII_REDACTED]36][    C7]  kernfs_remove_by_name_ns+0x74/0xe8
[[PII_REDACTED]42][    C7]  sysfs_remove_group+0x84/0xe8
[[PII_REDACTED]50][    C7]  sysfs_remove_groups+0x34/0x58
[[PII_REDACTED]58][    C7]  device_remove_groups+0x10/0x20
[[PII_REDACTED]64][    C7]  device_release_driver_internal+0x164/0x2e4
[[PII_REDACTED]75][    C7]  device_release_driver+0x18/0x28
[[PII_REDACTED]84][    C7]  bus_remove_device+0xec/0x118
[[PII_REDACTED]91][    C7]  device_del+0x1e8/0x4ac
[[PII_REDACTED]98][    C7]  device_unregister+0x18/0x38
[[PII_REDACTED]04][    C7]  typec_unregister_altmode+0x30/0x44
[[PII_REDACTED]15][    C7]  tcpm_reset_port+0xac/0x370
[[PII_REDACTED]23][    C7]  tcpm_snk_detach+0x84/0xb8
[[PII_REDACTED]29][    C7]  run_state_machine+0x4c0/0x1b68
[[PII_REDACTED]36][    C7]  tcpm_state_machine_work+0x94/0xe4
[[PII_REDACTED]44][    C7]  kthread_worker_fn+0x10c/0x244
[[PII_REDACTED]52][    C7]  kthread+0x104/0x1d4
[[PII_REDACTED]57][    C7]  ret_from_fork+0x10/0x20

[[PII_REDACTED]89][    C7] Workqueue: events dp_altmode_work
[[PII_REDACTED]97][    C7] Call trace:
[[PII_REDACTED]01][    C7]  __switch_to+0x174/0x338
[[PII_REDACTED]10][    C7]  __schedule+0x608/0x9f0
[[PII_REDACTED]17][    C7]  schedule+0x7c/0xe8
[[PII_REDACTED]25][    C7]  schedule_preempt_disabled+0x24/0x40
[[PII_REDACTED]33][    C7]  __mutex_lock+0x408/0xdac
[[PII_REDACTED]41][    C7]  __mutex_lock_slowpath+0x14/0x24
[[PII_REDACTED]48][    C7]  mutex_lock+0x40/0xec
[[PII_REDACTED]57][    C7]  tcpm_altmode_enter+0x78/0xb4
[[PII_REDACTED]64][    C7]  typec_altmode_enter+0xdc/0x10c
[[PII_REDACTED]69][    C7]  dp_altmode_work+0x68/0x164
[[PII_REDACTED]75][    C7]  process_one_work+0x1e4/0x43c
[[PII_REDACTED]83][    C7]  worker_thread+0x25c/0x430
[[PII_REDACTED]89][    C7]  kthread+0x104/0x1d4
[[PII_REDACTED]94][    C7]  ret_from_fork+0x10/0x20

Change tcpm_queue_vdm_unlocked to queue for tcpm_queue_vdm_work,
which can perform the state check while holding the TCPM lock
while the Alt Mode lock is no longer held. This requires a new
struct to hold the vdm data, altmode_vdm_event.
CVSS Score: 5.5 (MEDIUM)
CWE: CWE-667
References: https://git.kernel.org/stable/c/1970d34b48cbeceb0c765984c9a6bb204c77f16a; https://git.kernel.org/stable/c/324d45e53f1a36c88bc649dc39e0c8300a41be0a; https://git.kernel.org/stable/c/7bdd712abefbec79176ab412d8c623e755c5d0ba