From: Amir Goldstein <amir73il@gmail.com>
To: Guanglei Zhu <zhugl3@xiaopeng.com>,
Christian Brauner <brauner@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org,
liuwb@xiaopeng.com
Subject: Re: [PATCH v2] ovl: reject lowerdir ending with unescaped backslash
Date: Mon, 12 Oct 2026 12:11:10 +0200 [thread overview]
Message-ID: <CAOQ4uxgLZWGFhSHfHWiGFau7ZOXmNWsd8M5iVTOf+4_hO2KgGA@mail.gmail.com> (raw)
In-Reply-To: <20261012095538.938789-1-zhugl3@xiaopeng.com>
On Mon, Oct 12, 2026 at 11:55 AM Guanglei Zhu <zhugl3@xiaopeng.com> wrote:
>
> In ovl_parse_param_split_lowerdirs() a backslash consumes the
> character that follows it. When the backslash is the last character
> of the lowerdir value, it consumes the NUL terminator: the loop exits
> normally and the backslash is kept in the output, so the lowerdir is
> passed downstream with a trailing backslash and the mount fails later
> with a confusing ENOENT from path lookup.
>
> A trailing unescaped backslash escapes nothing, so reject it with
> EINVAL.
>
> Signed-off-by: Guanglei Zhu <zhugl3@xiaopeng.com>
> ---
> v2: fix the commit message. v1 wrongly claimed that the loop
> scans heap memory past the allocation; there is no out-of-bounds
> access, the backslash merely consumes the NUL terminator. Thanks
> to Amir Goldstein and Sashiko for catching this.
>
> Verified with an ASAN build of a user-space replica of the loop:
> no out-of-bounds access, the output retains the trailing backslash.
> With this patch fsconfig(lowerdir="...\") returns -EINVAL instead
> of -ENOENT.
>
> fs/overlayfs/params.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c
> index c93fcaa45..5a15e5478 100644
> --- a/fs/overlayfs/params.c
> +++ b/fs/overlayfs/params.c
> @@ -216,6 +216,9 @@ static ssize_t ovl_parse_param_split_lowerdirs(char *str)
> if (*s == '\\') {
> /* keep esc chars in split lowerdir */
> *d++ = *s++;
> + /* A trailing backslash escapes nothing. */
> + if (!*s)
> + return -EINVAL;
> } else if (*s == ':') {
> bool next_colon = (*(s + 1) == ':');
>
> --
> 2.43.0
>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Christian,
Could you pick this up via vfs.fixes?
Thanks,
Amir.
next prev parent reply other threads:[~2026-10-12 10:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 6:08 [PATCH] " Guanglei Zhu
2026-10-12 9:47 ` Amir Goldstein
2026-10-12 9:55 ` [PATCH v2] " Guanglei Zhu
2026-10-12 10:11 ` Amir Goldstein [this message]
2026-10-12 10:45 ` Christian Brauner
2026-10-12 10:44 ` 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=CAOQ4uxgLZWGFhSHfHWiGFau7ZOXmNWsd8M5iVTOf+4_hO2KgGA@mail.gmail.com \
--to=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=liuwb@xiaopeng.com \
--cc=miklos@szeredi.hu \
--cc=zhugl3@xiaopeng.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®