usb: typec: tipd: assign partner identity to persistent memory
Subsystems (3)
PATCH 1/1 usb: typec: tipd: assign partner identity to persistent memory
cd321x_update_work() passes a pointer to a local stack variable (&st.partner_identity) to typec_register_partner(). The Type-C core caches this pointer, leading to a stack-use-after-free and a kernel Oops when accessed later (e.g., via get_pd_product_type()).
Fix this by copying the identity to the heap-allocated cd321x struct and passing a pointer to that persistent memory instead. Move up the assignment to cd321x->cur_partner_identity, so this works.
---
Cc: Nicole Mazzuca <[email protected]>
Cc: [email protected]
--- drivers/usb/typec/tipd/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/usb/typec/tipd/core.c +5 -5
@@ -855,8 +855,10 @@ static void cd321x_update_work(struct work_struct *work) desc.usb_pd = is_pd; desc.accessory =TYPEC_ACCESSORY_NONE ;/* XXX: handle accessories */ -if (desc.usb_pd) - desc.identity = &st.partner_identity; +if (desc.usb_pd) { + cd321x->cur_partner_identity = st.partner_identity; + desc.identity = &cd321x->cur_partner_identity; + } tps->partner =typec_register_partner (tps->port, &desc);if (IS_ERR (tps->partner)) {
@@ -864,10 +866,8 @@ static void cd321x_update_work(struct work_struct *work)return ; } -if (desc.identity) { +if (desc.identity)typec_partner_set_identity (tps->partner); - cd321x->cur_partner_identity = st.partner_identity; - } }/* Update the TypeC MUX/PHY state */
---
base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee
change-id: 20261107-tipd-stack-uaf-fix-d3148059c017
Best regards,
Signature · 1 line
Michael Reeves <[email protected]>
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 11 lines
From: Michael Reeves <[email protected]>
cd321x_update_work()passes a pointer to a local stack variable (&st.partner_identity) totypec_register_partner(). The Type-C core caches this pointer, leading to a stack-use-after-free and a kernel Oops when accessed later (e.g., viaget_pd_product_type()).Fix this by copying the identity to the heap-allocated cd321x struct and passing a pointer to that persistent memory instead. Move up the assignment to
cd321x->cur_partner_identity, so this works.
Quoted 5 lines
Reported-by Nicole Mazzuca <[email protected]>Fixes 82432bbfb9e8 ("usb: typec: tipd: Handle mode transitions for CD321x")Signed-off-by Michael Reeves <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 11 lines · On 11/7/26 11:06, Michael Reeves via B4 Relay wrote:
From: Michael Reeves <[email protected]>
cd321x_update_work()passes a pointer to a local stack variable (&st.partner_identity) totypec_register_partner(). The Type-C core caches this pointer, leading to a stack-use-after-free and a kernel Oops when accessed later (e.g., viaget_pd_product_type()).Fix this by copying the identity to the heap-allocated cd321x struct and passing a pointer to that persistent memory instead. Move up the assignment to
cd321x->cur_partner_identity, so this works.
Quoted 6 lines
Reported-by Nicole Mazzuca <[email protected]>Fixes 82432bbfb9e8 ("usb: typec: tipd: Handle mode transitions for CD321x")Signed-off-by Michael Reeves <[email protected]>---
Thanks,
Sven
Quoted 11 lines · On Sat, Nov 07, 2026 at 10:06:17AM +0000, Michael Reeves via B4 Relay wrote:
From: Michael Reeves <[email protected]>
cd321x_update_work()passes a pointer to a local stack variable (&st.partner_identity) totypec_register_partner(). The Type-C core caches this pointer, leading to a stack-use-after-free and a kernel Oops when accessed later (e.g., viaget_pd_product_type()).Fix this by copying the identity to the heap-allocated cd321x struct and passing a pointer to that persistent memory instead. Move up the assignment to
cd321x->cur_partner_identity, so this works.
Quoted 5 lines
Reported-by Nicole Mazzuca <[email protected]>Fixes 82432bbfb9e8 ("usb: typec: tipd: Handle mode transitions for CD321x")Signed-off-by Michael Reeves <[email protected]>
Quoted 45 lines
---
Cc: Nicole Mazzuca <[email protected]>
Cc: [email protected]--- drivers/usb/typec/tipd/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/usb/typec/tipd/core.c +5
-6@@ -855,8 +855,10 @@ static void cd321x_update_work(struct work_struct *work) desc.usb_pd = is_pd; desc.accessory =TYPEC_ACCESSORY_NONE ;/* XXX: handle accessories */ -if (desc.usb_pd) - desc.identity = &st.partner_identity; +if (desc.usb_pd) { + cd321x->cur_partner_identity = st.partner_identity; + desc.identity = &cd321x->cur_partner_identity; + } tps->partner =typec_register_partner (tps->port, &desc);if (IS_ERR (tps->partner)) {@@ -864,10 +866,8 @@ static void cd321x_update_work(struct work_struct *work)return ; } -if (desc.identity) { +if (desc.identity)typec_partner_set_identity (tps->partner); - cd321x->cur_partner_identity = st.partner_identity; - } }/* Update the TypeC MUX/PHY state */ ---base-commit:
d48723711bae9b8cdc56719c448ba42fef28cbee
change-id: 20261107-tipd-stack-uaf-fix-d3148059c017Best regards,
Signature · 1 line
Michael Reeves <[email protected]>
Signature · 1 line
heikki