Re: [PATCH v2] ovl: Fix uninit-value in ovl_fill_real

From: Qing Wang

Date: Tue Jan 27 2026 - 21:42:56 EST


On Tue, 27 Jan 2026 at 19:19, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
> diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
> index 160960bb0ad0..9ea3cd11dd93 100644
> --- a/fs/overlayfs/readdir.c
> +++ b/fs/overlayfs/readdir.c
> @@ -755,7 +755,7 @@ static bool ovl_fill_real(struct dir_context *ctx, const char *name,
> struct dir_context *orig_ctx = rdt->orig_ctx;
> bool res;
>
> - if (rdt->parent_ino && strcmp(name, "..") == 0) {
> + if (rdt->parent_ino && namelen == 2 && !strncmp(name, "..", namelen)) {
>
> Yeah, and also the str... functions only make sense on null terminated
> strings, so that needs to be memcmp.

Thanks for your idea, but I think strncmp is same as memncmp in this case.
strncmp dons't use null terminated.

```
int strncmp(const char *cs, const char *ct, size_t count)
{
unsigned char c1, c2;

while (count) {
c1 = *cs++;
c2 = *ct++;
if (c1 != c2)
return c1 < c2 ? -1 : 1;
if (!c1)
break;
count--;
}
return 0;
}
```

What do you think?

--
Best Regards,
Qing