From: Guanglei Zhu <zhugl3@xiaopeng.com>
To: Miklos Szeredi <miklos@szeredi.hu>, Amir Goldstein <amir73il@gmail.com>
Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org,
liuwb@xiaopeng.com
Subject: [PATCH v2] ovl: reject lowerdir ending with unescaped backslash
Date: Mon, 12 Oct 2026 17:55:38 +0800 [thread overview]
Message-ID: <20261012095538.938789-1-zhugl3@xiaopeng.com> (raw)
In-Reply-To: <20261012060847.836027-1-zhugl3@xiaopeng.com>
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
next prev parent reply other threads:[~2026-10-12 9:55 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 ` Guanglei Zhu [this message]
2026-10-12 10:11 ` [PATCH v2] " Amir Goldstein
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=20261012095538.938789-1-zhugl3@xiaopeng.com \
--to=zhugl3@xiaopeng.com \
--cc=amir73il@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=liuwb@xiaopeng.com \
--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 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®