From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Adriano Cordova <adrianox@gmail.com>
Cc: linux-usb@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>,
syzbot+7bf725ed337e37307001@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] usb: gadget: inode: fix use-after-free of struct ep_data
Date: Fri, 20 Nov 2026 12:18:03 +0100 [thread overview]
Message-ID: <2026112052-mortality-fiddling-7035@gregkh> (raw)
In-Reply-To: <20260905144905.263941-1-adrianox@gmail.com>
On Sat, Sep 05, 2026 at 10:49:05AM -0400, Adriano Cordova wrote:
> gadgetfs_unbind() -> destroy_ep_files() frees each struct ep_data via
> put_ep(), but the inode still points at that ep_data through ->i_private
> with no reference of its own. A concurrent openat() on an endpoint file
> can therefore reach ep_open() and dereference the freed ep_data (the
> mutex fast path), even while the inode outlives it.
>
> Give the inode its own reference: take get_ep() when the endpoint inode
> is created and drop it again from a new gadgetfs_evict_inode(), so an
> ep_data can never be freed while any inode still points at it. This is
> also safe against dcache pruning, since the inode reference keeps the
> count >= 1 until the endpoint is removed from dev->epfiles.
>
> The inode now holds ep_data for its whole lifetime, so an open() racing
> with an unbind never dereferences freed ep_data.
>
> Reported-by: syzbot+7bf725ed337e37307001@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?extid=7bf725ed337e37307001
> Tested-by: syzbot+7bf725ed337e37307001@syzkaller.appspotmail.com
> Signed-off-by: Adriano Cordova <adrianox@gmail.com>
> ---
What commit id does this fix? No cc: stable?
prev parent reply other threads:[~2026-11-20 11:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-05 14:49 [PATCH v2] usb: gadget: inode: fix use-after-free of struct ep_data Adriano Cordova
2026-11-20 11:18 ` 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=2026112052-mortality-fiddling-7035@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=adrianox@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=syzbot+7bf725ed337e37307001@syzkaller.appspotmail.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