From: David Carlier <devnexen@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org, David Carlier <devnexen@gmail.com>
Subject: [PATCH] fuse: add missing NULL check for fget() in fuse_parse_param()
Date: Wed, 18 Mar 2026 18:27:01 +0000 [thread overview]
Message-ID: <20260318182701.21697-1-devnexen@gmail.com> (raw)
In the OPT_FD case of fuse_parse_param(), when using the old mount API,
fget() is called on the user-supplied file descriptor but its return
value is not checked for NULL before being passed to fuse_opt_fd().
fuse_opt_fd() unconditionally dereferences file->f_op, causing a kernel
NULL pointer dereference.
This is user-triggerable via: mount -t fuse -o fd=99999 dummy /mnt
where fd 99999 is not open.
The new mount API path (FSCONFIG_SET_FD) is not affected because
fsopen.c validates the fd with fget_raw() + NULL check before setting
param->file.
Add a NULL check after fget() and return an error via invalfc() when
the fd is invalid.
Fixes: 3f2496deff35 ("fuse: don't require /dev/fuse fd to be kept open during mount")
Signed-off-by: David Carlier <devnexen@gmail.com>
---
fs/fuse/inode.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index af8ad96829fd..39b635651165 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -862,6 +862,8 @@ static int fuse_parse_param(struct fs_context *fsc, struct fs_parameter *param)
return fuse_opt_fd(fsc, param->file);
} else {
struct file *file __free(fput) = fget(result.uint_32);
+ if (!file)
+ return invalfc(fsc, "Invalid fuse fd");
return fuse_opt_fd(fsc, file);
}
--
2.53.0
next reply other threads:[~2026-03-18 18:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 18:27 David Carlier [this message]
2026-03-18 21:31 ` [PATCH] fuse: add missing NULL check for fget() in fuse_parse_param() Joanne Koong
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=20260318182701.21697-1-devnexen@gmail.com \
--to=devnexen@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.