ovl: reject lowerdir ending with unescaped backslash

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 <[email protected]>
Link: https://patch.msgid.link/[email protected]
Reviewed-by: Amir Goldstein <[email protected]>
Signed-off-by: Christian Brauner (Amutable) <[email protected]>
This commit is contained in:
Guanglei Zhu authored and Christian Brauner committed 2026-10-14 22:08:05 +02:00
1 parent 36ebddca56
commit 99ae7dc439
1 file changed
+3
+3
View File
@@ -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) == ':');