From: Christian Brauner <brauner@kernel.org>
To: Hongbo Li <lihongbo22@huawei.com>
Cc: viro@zeniv.linux.org.uk, jack@suse.cz, tytso@mit.edu,
adilger.kernel@dilger.ca, lczerner@redhat.com,
cmaiolino@redhat.com, linux-fsdevel@vger.kernel.org,
linux-doc@vger.kernel.org, yi.zhang@huawei.com
Subject: Re: [PATCH v2 2/4] fs: add path parser for filesystem mount option.
Date: Mon, 27 May 2024 16:32:00 +0200 [thread overview]
Message-ID: <20240527-groll-mythisch-8580c32ab296@brauner> (raw)
In-Reply-To: <20240527075854.1260981-3-lihongbo22@huawei.com>
On Mon, May 27, 2024 at 03:58:52PM +0800, Hongbo Li wrote:
> `fsparam_path` uses `fs_param_is_path` to parse the option, but it
> is currently empty. The new mount api has considered this option in
> `fsconfig`(that is FSCONFIG_SET_PATH). Here we add general path parser
> in filesystem layer. Currently, no filesystem uses this function to
> parse parameters, we add `void *ptr` in `fs_parse_result` to point to
> the target structure(such as `struct inode *`).
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> fs/fs_parser.c | 18 ++++++++++++++++++
> include/linux/fs_parser.h | 1 +
> 2 files changed, 19 insertions(+)
>
> diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> index 2aa208cf2027..5d0adcc514d8 100644
> --- a/fs/fs_parser.c
> +++ b/fs/fs_parser.c
> @@ -367,6 +367,24 @@ EXPORT_SYMBOL(fs_param_is_blockdev);
> int fs_param_is_path(struct p_log *log, const struct fs_parameter_spec *p,
> struct fs_parameter *param, struct fs_parse_result *result)
> {
> + int ret;
> + struct filename *f;
> + struct path path;
> +
> + if (param->type != fs_value_is_filename)
> + return fs_param_bad_value(log, param);
> + if (!*param->string && (p->flags & fs_param_can_be_empty))
> + return 0;
> +
> + f = param->name;
> + ret = filename_lookup(param->dirfd, f, LOOKUP_FOLLOW, &path, NULL);
> + if (ret < 0) {
> + error_plog(log, "%s: Lookup failure for '%s'", param->key, f->name);
> + return fs_param_bad_value(log, param);
> + }
> + result->ptr = d_backing_inode(path.dentry);
> + path_put(&path);
That smells like a UAF:
dfd = open("/bla");
fsconfig(FSCONFIG_SET_PATH, dfd, "blub", 0);
close(dfd);
umount("/bla");
and that result->ptr now has a dangling pointer which will be triggered by:
fsconfig(FSCONFIG_CMD_CREATE);
next prev parent reply other threads:[~2024-05-27 14:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 7:58 [PATCH v2 0/4] enhance the path resolution capability in fs_parser Hongbo Li
2024-05-27 7:58 ` [PATCH v2 1/4] fs: add blockdev parser for filesystem mount option Hongbo Li
2024-05-27 7:58 ` [PATCH v2 2/4] fs: add path " Hongbo Li
2024-05-27 14:32 ` Christian Brauner [this message]
2024-05-27 16:26 ` Christoph Hellwig
2024-05-27 7:58 ` [PATCH v2 3/4] fs: ext4: support relative path for `journal_path` in " Hongbo Li
2024-05-27 15:39 ` Christian Brauner
2024-05-27 7:58 ` [PATCH v2 4/4] fs: remove fs_lookup_param and its description Hongbo Li
2024-05-27 15:08 ` [PATCH v2 0/4] enhance the path resolution capability in fs_parser Christian Brauner
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=20240527-groll-mythisch-8580c32ab296@brauner \
--to=brauner@kernel.org \
--cc=adilger.kernel@dilger.ca \
--cc=cmaiolino@redhat.com \
--cc=jack@suse.cz \
--cc=lczerner@redhat.com \
--cc=lihongbo22@huawei.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=yi.zhang@huawei.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;
as well as URLs for NNTP newsgroup(s).