From: Sonali Pradhan <sonalipradhan@google.com>
To: Takashi Iwai <tiwai@suse.de>, Sonali Pradhan <sonalipradhan@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Neill Kapron <nkapron@google.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Fan Wu <fanwu01@zju.edu.cn>,
Victor Krawiec <victor.krawiec@arturia.com>,
Felipe Balbi <balbi@ti.com>,
"Felipe F. Tonello" <eu@felipetonello.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH RESEND] usb: gadget: f_midi: fix UAF race during IN request handling
Date: Thu, 22 Oct 2026 21:12:11 +0530 [thread overview]
Message-ID: <CALeehfmiOoJS4cwPCzHcAgi5dGpCiS0sTd9FQZo6VWXwVth-dw@mail.gmail.com> (raw)
In-Reply-To: <87a4o8ivv2.wl-tiwai@suse.de>
On Tue, 20 Oct 2026 11:06:57 +0200,
Takashi Iwai wrote:
>
> On Mon, 19 Oct 2026 15:57:01 +0200,
> Sonali Pradhan wrote:
> >
> > diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
> > index 63fb6ee70a3d..c26d04eb9209 100644
> > --- a/drivers/usb/gadget/function/f_midi.c
> > +++ b/drivers/usb/gadget/function/f_midi.c
> > @@ -280,9 +280,18 @@ f_midi_complete(struct usb_ep *ep, struct usb_request *req)
> > /* We received stuff. req is queued again, below */
> > f_midi_handle_out_data(ep, req);
> > } else if (ep == midi->in_ep) {
> > + unsigned long flags;
> > +
> > /* Our transmit completed. See if there's more to go.
> > * f_midi_transmit eats req, don't queue it again. */
> > + spin_lock_irqsave(&midi->transmit_lock, flags);
> > + if (!ep->enabled) {
> > + spin_unlock_irqrestore(&midi->transmit_lock, flags);
> > + return;
> > + }
> > req->length = 0;
> > + spin_unlock_irqrestore(&midi->transmit_lock, flags);
> > +
>
> Does this transmit_lock help here? As far as I see, the ep
> enable/disable itself is done outside the lock.
>
> > @@ -678,10 +690,11 @@ static void f_midi_transmit(struct f_midi *midi)
> > unsigned long flags;
> >
> > /* We only care about USB requests if IN endpoint is enabled */
> > - if (!ep || !ep->enabled)
> > - goto drop_out;
> > -
> > spin_lock_irqsave(&midi->transmit_lock, flags);
> > + if (!ep || !ep->enabled) {
> > + spin_unlock_irqrestore(&midi->transmit_lock, flags);
> > + goto drop_out;
> > + }
>
> Ditto.
You are right about this. I'll rework the patch along with the issues
noted in Sashiko's review and send a v2.
Thanks,
Sonali
prev parent reply other threads:[~2026-10-22 15:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 13:57 Sonali Pradhan
2026-10-20 9:06 ` Takashi Iwai
2026-10-22 15:42 ` Sonali Pradhan [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=CALeehfmiOoJS4cwPCzHcAgi5dGpCiS0sTd9FQZo6VWXwVth-dw@mail.gmail.com \
--to=sonalipradhan@google.com \
--cc=balbi@ti.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=eu@felipetonello.com \
--cc=fanwu01@zju.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.com \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=victor.krawiec@arturia.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
all inboxes | Powered by JetHome®