From: Michael Reeves via B4 Relay <devnull+michael.reeves077.gmail.com@kernel.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Janne Grunau <j@jannau.net>, Sven Peter <sven@kernel.org>,
Hector Martin <marcan@marcan.st>
Cc: Neal Gompa <neal@gompa.dev>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicole Mazzuca <nicole@streganil.no>,
stable@vger.kernel.org,
Michael Reeves <michael.reeves077@gmail.com>,
asahi@lists.linux.dev
Subject: [PATCH] usb: typec: tipd: assign partner identity to persistent memory
Date: Sat, 07 Nov 2026 10:06:17 +0000 [thread overview]
Message-ID: <20261107-tipd-stack-uaf-fix-v1-1-efcb517924ec@gmail.com> (raw)
From: Michael Reeves <michael.reeves077@gmail.com>
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.
Reported-by: Nicole Mazzuca <nicole@streganil.no>
Closes: https://github.com/AsahiLinux/linux/issues/668
Fixes: 82432bbfb9e8 ("usb: typec: tipd: Handle mode transitions for CD321x")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Reeves <michael.reeves077@gmail.com>
---
Cc: Nicole Mazzuca <nicole@streganil.no>
Cc: asahi@lists.linux.dev
---
drivers/usb/typec/tipd/core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 02539378ffed..dce0aa8be5e0 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -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,
--
Michael Reeves <michael.reeves077@gmail.com>
WARNING: multiple messages have this Message-ID (diff)
From: Michael Reeves <michael.reeves077@gmail.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Janne Grunau <j@jannau.net>, Sven Peter <sven@kernel.org>,
Hector Martin <marcan@marcan.st>
Cc: Neal Gompa <neal@gompa.dev>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicole Mazzuca <nicole@streganil.no>,
stable@vger.kernel.org,
Michael Reeves <michael.reeves077@gmail.com>,
asahi@lists.linux.dev
Subject: [PATCH] usb: typec: tipd: assign partner identity to persistent memory
Date: Sat, 07 Nov 2026 10:06:17 +0000 [thread overview]
Message-ID: <20261107-tipd-stack-uaf-fix-v1-1-efcb517924ec@gmail.com> (raw)
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.
Reported-by: Nicole Mazzuca <nicole@streganil.no>
Closes: https://github.com/AsahiLinux/linux/issues/668
Fixes: 82432bbfb9e8 ("usb: typec: tipd: Handle mode transitions for CD321x")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Reeves <michael.reeves077@gmail.com>
---
Cc: Nicole Mazzuca <nicole@streganil.no>
Cc: asahi@lists.linux.dev
---
drivers/usb/typec/tipd/core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 02539378ffed..dce0aa8be5e0 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -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,
--
Michael Reeves <michael.reeves077@gmail.com>
next reply other threads:[~2026-11-07 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 10:06 Michael Reeves via B4 Relay [this message]
2026-11-07 10:06 ` [PATCH] usb: typec: tipd: assign partner identity to persistent memory Michael Reeves
2026-11-07 10:13 ` sashiko-bot
2026-11-07 20:12 ` Sven Peter
2026-11-11 14:27 ` Heikki Krogerus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261107-tipd-stack-uaf-fix-v1-1-efcb517924ec@gmail.com \
--to=devnull+michael.reeves077.gmail.com@kernel.org \
--cc=asahi@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=j@jannau.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=michael.reeves077@gmail.com \
--cc=neal@gompa.dev \
--cc=nicole@streganil.no \
--cc=stable@vger.kernel.org \
--cc=sven@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.