CD321x USB-C partner identity use-after-return
On an Apple Silicon Mac14,10 running 7.1.13-asahi-fairydust, memory grew to more than 22 GiB of unevictable DRM shared memory, with stuck processes and failed suspend attempts.
Source bug
In drivers/usb/typec/tipd/core.c, cd321x_update_work() copies the controller status into a local variable, struct cd321x_status st, then registers a partner with:
typec_register_partner() retains this pointer in partner->identity; it does not copy the identity. The pointer therefore refers to expired worker-stack storage after cd321x_update_work() returns. A subsequent typec_set_data_role() calls get_pd_product_type(), which dereferences it.
The introducing commit in this kernel's ancestry is 82432bbfb9e8 — usb: typec: tipd: Handle mode transitions for CD321x. Its parent used persistent tps->partner_identity storage. This affects the Apple CD321x path in upstream Linux as well as Asahi/Fairydust.
How it was identified
AI-assisted debugging checked memory counters, kernel logs and blocked-task stacks, then inspected /proc/kcore with drgn. Matching debug types were reconstructed from the kernel checkout using its saved compiler commands; no module was loaded.
The captured evidence was:
- The kernel faulted in
get_pd_product_type()at0xffff8000a20d7d08, fromcd321x_update_work()on CPU 9. - Live
port2-partner->identitycontained exactly that fault address. Persistentcd321x->cur_partner_identitystorage instead occupied0xffff0000107bf308. - CPU 9's normal worker pool retained a worker whose current function was
cd321x_update_work. The pool reportednr_running = 1, with two idle workers and over 1,000 pending jobs, including 1,024 AsahiSubmittedWorkContainercleanup jobs, SRCU processing and LRU drainage. - Live shmem inode enumeration accounted for 22.37 GiB in 13,739
drm mm objectbacking objects; current GPU client handles accounted for only about 1 GiB.
The evidence supports a failure chain in which the USB-C use-after-return causes an Oops, strands the CPU 9 worker pool, and prevents GPU command cleanup, allowing DRM memory to accumulate. The machine subsequently crashed and was rebooted.
Proposed fix
Copy the identity into persistent driver storage before registering the partner:
Remove the redundant identity copy after registration. This fix has not yet been applied or runtime-tested. A fetch and inspection of all 159 Asahi remote branches found the faulty assignment in 51 branch tips and no existing lifetime fix; current upstream master also retained it at the time of inspection.