From: Stefan Hajnoczi <stefanha@redhat.com>
To: Qianchang Zhao <pioooooooooip@gmail.com>
Cc: "Vivek Goyal" <vgoyal@redhat.com>,
"Miklos Szeredi" <miklos@szeredi.hu>,
"Eugenio Pérez" <eperezma@redhat.com>,
virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Zhitong Liu" <liuzhitong1993@gmail.com>,
stable@vger.kernel.org, "Alok Tiwari" <alok.a.tiwari@oracle.com>
Subject: Re: [PATCH] virtiofs: fix NULL dereference in virtio_fs_add_queues_sysfs()
Date: Mon, 15 Dec 2025 09:32:07 -0500 [thread overview]
Message-ID: <20251215143207.GC19970@fedora> (raw)
In-Reply-To: <20251213012829.685605-1-pioooooooooip@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1811 bytes --]
On Sat, Dec 13, 2025 at 10:28:29AM +0900, Qianchang Zhao wrote:
> virtio_fs_add_queues_sysfs() creates per-queue sysfs kobjects via
> kobject_create_and_add(). The current code checks the wrong variable
> after the allocation:
>
> - kobject_create_and_add() may return NULL on failure.
> - The code incorrectly checks fs->mqs_kobj (the parent kobject), which is
> expected to be non-NULL at this point.
> - If kobject_create_and_add() fails, fsvq->kobj is NULL but the code can
> still call sysfs_create_group(fsvq->kobj, ...), leading to a NULL pointer
> dereference and kernel panic (DoS).
>
> Fix by validating fsvq->kobj immediately after kobject_create_and_add()
> and aborting on failure, so sysfs_create_group() is never called with a
> NULL kobject.
>
> Reported-by: Qianchang Zhao <pioooooooooip@gmail.com>
> Reported-by: Zhitong Liu <liuzhitong1993@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Qianchang Zhao <pioooooooooip@gmail.com>
> ---
> fs/fuse/virtio_fs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
This issue was fixed in October. It no longer exists in mainline Linux:
commit c014021253d77cd89b2d8788ce522283d83fbd40
Author: Alok Tiwari <alok.a.tiwari@oracle.com>
Date: Mon Oct 27 03:46:47 2025 -0700
virtio-fs: fix incorrect check for fsvq->kobj
> diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> index 6bc7c97b0..b2f6486fe 100644
> --- a/fs/fuse/virtio_fs.c
> +++ b/fs/fuse/virtio_fs.c
> @@ -373,7 +373,7 @@ static int virtio_fs_add_queues_sysfs(struct virtio_fs *fs)
>
> sprintf(buff, "%d", i);
> fsvq->kobj = kobject_create_and_add(buff, fs->mqs_kobj);
> - if (!fs->mqs_kobj) {
> + if (!fsvq->kobj) {
> ret = -ENOMEM;
> goto out_del;
> }
> --
> 2.34.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2025-12-15 14:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-13 1:28 [PATCH] virtiofs: fix NULL dereference in virtio_fs_add_queues_sysfs() Qianchang Zhao
2025-12-15 14:32 ` Stefan Hajnoczi [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=20251215143207.GC19970@fedora \
--to=stefanha@redhat.com \
--cc=alok.a.tiwari@oracle.com \
--cc=eperezma@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuzhitong1993@gmail.com \
--cc=miklos@szeredi.hu \
--cc=pioooooooooip@gmail.com \
--cc=stable@vger.kernel.org \
--cc=vgoyal@redhat.com \
--cc=virtualization@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).