mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@igalia.com>
To: Hungyu Lin <dennylin0707@gmail.com>, amir73il@gmail.com
Cc: linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	miklos@szeredi.hu
Subject: Re: [PATCH] ovl: reserve space for the casefolded name terminator
Date: Fri, 30 Oct 2026 14:21:35 -0300	[thread overview]
Message-ID: <233c47ca-5d1a-4e16-b0c8-6e0bc8857751@igalia.com> (raw)
In-Reply-To: <20261028195133.86636-1-dennylin0707@gmail.com>

Hi Hungyu, Amir,

Sorry for the delay and thanks for the patch!

Em 28/10/2026 16:51, Hungyu Lin escreveu:
> ovl_casefold() allocates NAME_MAX bytes and passes that capacity to
> utf8_casefold(), which also needs room for a terminating NUL. A valid
> name whose folded form is exactly NAME_MAX bytes therefore fails to
> fold, and ovl_fill_merge() falls back to comparing the original bytes.
> 
> For example, when two casefolded layers contain directories named with
> 255 uppercase and lowercase ASCII letters respectively, readdir lists
> both names even though lookup treats them as the same directory. The
> same names merge correctly at 254 bytes.
> 
> Reserve one additional byte in both the allocation and the folding
> capacity so that NAME_MAX-byte folded names use the canonical merge key.
> 
> Fixes: ee95c5fc86dd ("ovl: Create ovl_casefold() to support casefolded strncmp()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>

Reviewed-by: André Almeida <andrealmeid@igalia.com>

I've tested and confirmed that files with 255 filenames will appear 
duplicated.

> ---
>   fs/overlayfs/readdir.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
> index 7d6f7f6022eb..6113d690f8ad 100644
> --- a/fs/overlayfs/readdir.c
> +++ b/fs/overlayfs/readdir.c
> @@ -81,13 +81,13 @@ static int ovl_casefold(struct ovl_readdir_data *rdd, const char *str, int len,
>   	    name_is_dot_dotdot(str, len))
>   		return 0;
>   
> -	cf_name = kmalloc(NAME_MAX, GFP_KERNEL);
> +	cf_name = kmalloc(NAME_MAX + 1, GFP_KERNEL);
>   	if (!cf_name) {
>   		rdd->err = -ENOMEM;
>   		return -ENOMEM;
>   	}
>   
> -	cf_len = utf8_casefold(rdd->map, &qstr, cf_name, NAME_MAX);
> +	cf_len = utf8_casefold(rdd->map, &qstr, cf_name, NAME_MAX + 1);

I wonder if the other callers for utf8_casefold() also need a fix?

>   	if (cf_len > 0)
>   		*dst = cf_name;
>   	else


      parent reply	other threads:[~2026-10-30 17:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 19:51 Hungyu Lin
2026-10-29 10:55 ` Amir Goldstein
2026-10-30 17:21 ` André Almeida [this message]

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=233c47ca-5d1a-4e16-b0c8-6e0bc8857751@igalia.com \
    --to=andrealmeid@igalia.com \
    --cc=amir73il@gmail.com \
    --cc=dennylin0707@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=stable@vger.kernel.org \
    /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®