From: Greg KH <gregkh@linuxfoundation.org>
To: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+098999e05b6b877c01b3@syzkaller.appspotmail.com
Subject: Re: [PATCH v3] usb: gadget: f_phonet: fix use-after-free in pn_bind
Date: Thu, 10 Sep 2026 18:38:59 +0200 [thread overview]
Message-ID: <2026091047-cover-resolute-5d4a@gregkh> (raw)
In-Reply-To: <20260805041319.3197126-1-khiemtranzo532001@gmail.com>
On Wed, Aug 05, 2026 at 12:13:19PM +0800, Nguyen Quang Le Kien wrote:
> pn_bind() and phonet_free_inst() race on opts->bound and opts->net.
> If configfs removes the function instance while pn_bind() is between
> the !bound check and setting bound = true, free_inst() frees opts->net
> and pn_bind() then writes to net->dev.parent via gphonet_set_gadget().
>
> The old "no race condition" comment was wrong - configfs_rmdir() can
> run in parallel with the composite bind path.
>
> Add a mutex to f_phonet_opts, use scoped_guard(mutex) in both paths,
> add kernel-doc on the struct, and destroy the mutex before freeing
> opts.
>
> Fixes: 00a2430ff07d ("usb: gadget: Gadget directory cleanup - group usb functions")
> Reported-by: syzbot+098999e05b6b877c01b3@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=098999e05b6b877c01b3
> Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com>
> ---
> v3: drop the redundant #include <linux/mutex.h> in f_phonet.c -
> u_phonet.h already includes it.
>
> v2: scoped_guard(mutex) instead of open-coded lock/unlock; kernel-doc
> on the struct; mutex_destroy(); remove the wrong comment.
You did not use the Assisted-by: tag as you should have :(
prev parent reply other threads:[~2026-09-10 16:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 3:33 [PATCH] " Nguyen Quang Le Kien
2026-08-04 6:30 ` Greg KH
2026-08-04 7:44 ` [PATCH v2] " Nguyen Quang Le Kien
2026-08-04 7:52 ` Greg KH
2026-08-04 8:18 ` Nguyen Quang Le Kien
2026-08-04 8:21 ` Greg KH
2026-08-05 4:08 ` Nguyen Quang Le Kien
2026-08-05 4:57 ` Greg KH
2026-08-05 6:57 ` [PATCH v3] " Nguyen Quang Le Kien
2026-08-05 7:51 ` Greg KH
2026-08-05 8:24 ` Nguyen Quang Le Kien
2026-08-05 8:37 ` Greg KH
2026-08-05 9:23 ` Nguyen Quang Le Kien
2026-08-04 8:25 ` [PATCH v2] " Nguyen Quang Le Kien
2026-08-04 8:25 ` syzbot
2026-08-05 4:13 ` [PATCH v3] " Nguyen Quang Le Kien
2026-09-10 16:38 ` Greg KH [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=2026091047-cover-resolute-5d4a@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=khiemtranzo532001@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+098999e05b6b877c01b3@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
all inboxes | Powered by JetHome®