From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, git@amd.com,
stable@vger.kernel.org
Subject: Re: [PATCH v2] usb: typec: tipd: fix uninitialized typec_partner_desc on stack
Date: Wed, 12 Aug 2026 11:28:32 +0200 [thread overview]
Message-ID: <anw8wDlUq4Vf4JN6@black.igk.intel.com> (raw)
In-Reply-To: <20260807174659.3720863-1-radhey.shyam.pandey@amd.com>
On Fri, Aug 07, 2026 at 11:16:58PM +0530, Radhey Shyam Pandey wrote:
> tps6598x_connect() and cd321x_update_work() pass a stack-allocated
> typec_partner_desc to typec_register_partner() after initializing only
> usb_pd, accessory and identity.
>
> typec_register_partner() copies attach and deattach from the descriptor
> into the partner. With those fields left unset, garbage function pointers
> may be stored and later invoked from typec_partner_link_device() when a USB
> device is linked to the port. Uninitialized pd_revision and usb_capability
> similarly leak stack data through partner sysfs.
>
> Zero-initialize the descriptor so optional callbacks remain NULL and the
> remaining fields are zero.
>
> Assisted-by: claude-mythos-preview-high
> Fixes: 82432bbfb9e8 ("usb: typec: tipd: Handle mode transitions for CD321x")
> Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> Changes for v2:
> - Add Assisted-by tag.
> - Remove explicit indentity=NULL
>
> AI code scanning identified this issue; the possible call graph is shown below.
>
> USB-C plug event (IRQ)
> tps6598x_interrupt()
> tps6598x_handle_plug_event()
> tps6598x_connect()
> struct typec_partner_desc desc; /* bug: attach/deattach unset */
> desc.usb_pd / .accessory / .identity = ...
> typec_register_partner(port, &desc) /* class.c */
> partner->attach = desc->attach; /* copy stack garbage */
> partner->deattach = desc->deattach;
> [if port->usb2_dev || port->usb3_dev already set]
> typec_partner_link_device(partner, dev)
> if (partner->attach)
> partner->attach(partner, dev) /* indirect call via bad ptr */
> ---
> drivers/usb/typec/tipd/core.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 522f56742aa9..d99a55063e34 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -344,7 +344,7 @@ static void tps6598x_set_data_role(struct tps6598x *tps,
>
> static int tps6598x_connect(struct tps6598x *tps, u32 status)
> {
> - struct typec_partner_desc desc;
> + struct typec_partner_desc desc = { };
> enum typec_pwr_opmode mode;
> int ret;
>
> @@ -355,7 +355,6 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status)
>
> desc.usb_pd = mode == TYPEC_PWR_MODE_PD;
> desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
> - desc.identity = NULL;
>
> if (desc.usb_pd) {
> ret = tps6598x_read_partner_identity(tps);
> @@ -841,11 +840,10 @@ static void cd321x_update_work(struct work_struct *work)
>
> /* Set up partner if we were previously disconnected (or changed). */
> if (!tps->partner) {
> - struct typec_partner_desc desc;
> + struct typec_partner_desc desc = { };
>
> desc.usb_pd = is_pd;
> desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
> - desc.identity = NULL;
>
> if (desc.usb_pd)
> desc.identity = &st.partner_identity;
>
> base-commit: ea2bff00da89d7767d677bb68470130ba96f4928
> --
> 2.44.4
--
heikki
next prev parent reply other threads:[~2026-08-12 9:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 17:46 Radhey Shyam Pandey
2026-08-08 7:11 ` Greg KH
2026-08-08 11:38 ` Pandey, Radhey Shyam
2026-08-12 9:28 ` Heikki Krogerus [this message]
2026-08-12 16:24 ` Pandey, Radhey Shyam
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=anw8wDlUq4Vf4JN6@black.igk.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=git@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=radhey.shyam.pandey@amd.com \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®