From: Dominique Martinet <asmadeus@codewreck.org>
To: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Cc: v9fs@lists.linux.dev, Eric Van Hensbergen <ericvh@kernel.org>,
Latchesar Ionkov <lucho@ionkov.net>,
Christian Schoenebeck <linux_oss@crudebyte.com>,
linux-kernel@vger.kernel.org,
Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>,
Ao Wang <wangao@seu.edu.cn>, Xuewei Feng <fengxw06@126.com>,
Qi Li <qli01@tsinghua.edu.cn>, Ke Xu <xuke@tsinghua.edu.cn>
Subject: Re: [PATCH] net/9p/usbg: Fix use-after-free in usb9pfs_free_func
Date: Sun, 13 Sep 2026 17:29:14 +0900 [thread overview]
Message-ID: <aqZe2nP84d5WYecJ@codewreck.org> (raw)
In-Reply-To: <20260529081817.77898-1-zhaoyz24@mails.tsinghua.edu.cn>
Yizhou Zhao wrote on Fri, May 29, 2026 at 04:18:16PM +0800:
> In usb9pfs_free_func, kfree(usb9pfs) frees the entire f_usb9pfs
> structure which contains the embedded usb_function member that the
> parameter 'f' points to. After the kfree, the code accesses f->fi
> via container_of(f->fi, struct f_usb9pfs_opts, func_inst) and later
> calls usb_free_all_descriptors(f), both of which dereference the
> freed memory. Since f is &usb9pfs->function, all post-kfree accesses
> through f constitute use-after-free on the already-freed usb9pfs
> allocation.
>
> Move kfree(usb9pfs) to the end of the function so that all accesses
> through f complete before the memory is freed.
>
> Fixes: a3be076dc174 ("net/9p/usbg: Add new usb gadget function transport")
> Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
> Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
> Reported-by: Ao Wang <wangao@seu.edu.cn>
> Reported-by: Xuewei Feng <fengxw06@126.com>
> Reported-by: Qi Li <qli01@tsinghua.edu.cn>
> Reported-by: Ke Xu <xuke@tsinghua.edu.cn>
> Assisted-by: GLM:GLM-5.1
> Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Thanks/sorry for the delay, I've picked this up for 7.4
There actually have been a duplicate of this commit a bit later with a
better commit message, so I've kept you as author as you were first, but
swapped the other's commit message in and added them as Co-developed-by
other mail
https://lore.kernel.org/r/20260731150414.3135662-1-nicoyip.dev@gmail.com
commit as of now
https://github.com/martinetd/linux/commit/0955472fff1e9f9e410a0300136924ebc8bd7a16
(look in https://github.com/martinetd/linux/commits/9p-test if commit is
gone on rebase)
--
Dominique Martinet | Asmadeus
prev parent reply other threads:[~2026-09-13 8:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 8:18 Yizhou Zhao
2026-09-13 8:29 ` Dominique Martinet [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=aqZe2nP84d5WYecJ@codewreck.org \
--to=asmadeus@codewreck.org \
--cc=ericvh@kernel.org \
--cc=fengxw06@126.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=qli01@tsinghua.edu.cn \
--cc=v9fs@lists.linux.dev \
--cc=wangao@seu.edu.cn \
--cc=xuke@tsinghua.edu.cn \
--cc=yangyx22@mails.tsinghua.edu.cn \
--cc=zhaoyz24@mails.tsinghua.edu.cn \
/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®