[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxhvnqg-_rB+1ch_nvZmP_s9a3RGxpaLP-9=UKTc9PWy7Q@mail.gmail.com>
Date: Wed, 28 Jan 2026 11:19:51 +0100
From: Amir Goldstein <amir73il@...il.com>
To: Qing Wang <wangqing7171@...il.com>
Cc: miklos@...redi.hu, linux-kernel@...r.kernel.org,
linux-unionfs@...r.kernel.org,
syzbot+d130f98b2c265fae5297@...kaller.appspotmail.com
Subject: Re: [PATCH v2] ovl: Fix uninit-value in ovl_fill_real
On Wed, Jan 28, 2026 at 3:42 AM Qing Wang <wangqing7171@...il.com> wrote:
>
> On Tue, 27 Jan 2026 at 19:19, Miklos Szeredi <miklos@...redi.hu> 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?
I think this discussion is not worth spending our time.
After namelen == 2, it really does not matter if we use strncmp or memcmp
IMO. I will post a followup patch to add name_is_dotdot() helper and use
those helpers in overlayfs readdir code instead of all the many open coded
variants that it has now, which may be safe, but still ugly.
In the meanwhile I'd rather apply v2 as is so it could be picked by stable.
Thanks,
Amir.
Powered by blists - more mailing lists