From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Hyeontae Lee <wonju345@naver.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: f_midi: hold transmit_lock while freeing IN requests
Date: Thu, 29 Oct 2026 10:44:21 +0100 [thread overview]
Message-ID: <2026102905-manhandle-disparate-1379@gregkh> (raw)
In-Reply-To: <20260815052929.146901-1-wonju345@naver.com>
On Sat, Aug 15, 2026 at 02:29:29PM +0900, Hyeontae Lee wrote:
> f_midi_disable() drains in_req_fifo and frees the requests without taking
> transmit_lock. f_midi_transmit() holds that lock across the whole of
> f_midi_do_transmit(), which peeks a request off the fifo without removing
> it and then keeps using it. kfifo_peek() does not advance the read index,
> so the drain frees exactly the request the transmit path is still using.
>
> No hostile host is needed: __composite_disconnect() calls f->disable() as
> well, so a bus reset or a cable pull while a MIDI client is writing is
> enough.
>
> BUG: KASAN: slab-use-after-free in f_midi_in_work+0x126c/0x18c0
> Read of size 4 at addr ffff888104818e20 by task kworker/2:2H/164
> Freed by task 158:
> kfree+0x121/0x380
> f_midi_disable+0x20e/0x430
> reset_config+0x9d/0x200
> __composite_disconnect+0xa7/0x140
>
> Take the lock around the drain, the way hidg_disable() does.
>
> Fixes: e1e3d7ec5da3 ("usb: gadget: f_midi: pre-allocate IN requests")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-4.8
> Signed-off-by: Hyeontae Lee <wonju345@naver.com>
> ---
> drivers/usb/gadget/function/f_midi.c | 3 +++
> 1 file changed, 3 insertions(+)
This version:
https://lore.kernel.org/r/20261028074821.579450-1-sonalipradhan@google.com
turns out to be a bit better, thanks.
greg k-h
prev parent reply other threads:[~2026-10-29 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 5:29 Hyeontae Lee
2026-10-29 9:44 ` Greg Kroah-Hartman [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=2026102905-manhandle-disparate-1379@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wonju345@naver.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®