Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yu Zhang" <yuz08559@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: f_printer: fix pnp_string use-after-free on reconfigure
Date: Thu, 15 Oct 2026 09:14:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-172550@kernel.org> (raw)
In-Reply-To: <20261015084658.70918-1-yuz08559@gmail.com>

> f_printer_opts_pnp_string_store() replaces opts->pnp_string with
> kfree(old) + kstrndup(new) under opts->lock only, with no opts->refcnt
> guard, so the IEEE-1284 ID string can be changed while the function is
> bound and the gadget is enumerated.
> 
> printer_func_setup() answers the host GET_DEVICE_ID class request from
> (soft)irq context and reads the string with no lock:
> 
> 	value = strlen(*dev->pnp_string);
> 	...
> 	memcpy(buf + 2, *dev->pnp_string, value);
> 
> dev->pnp_string points at &opts->pnp_string, so a concurrent configfs
> write that frees the old string races the setup read -> use-after-free.
> 
> [ ... ]
> function is not linked into a gadget.
> 
> Fixes: 24b7ba2f88e0 ("usb: gadget: function: fix dangling pnp_string in f_printer.c")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yu Zhang <yuz08559@gmail.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015084658.70918-1-yuz08559@gmail.com?part=1


      reply	other threads:[~2026-10-15  9:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  8:46 [PATCH] usb: gadget: f_printer: fix pnp_string use-after-free on reconfigure Yu Zhang
2026-10-15  9:14 ` sashiko-bot [this message]

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=sashiko-outbox-172550@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yuz08559@gmail.com \
    /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