lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-id: <164872323977.25542.8403385264176230518@noble.neil.brown.name>
Date:   Thu, 31 Mar 2022 21:40:39 +1100
From:   "NeilBrown" <neilb@...e.de>
To:     "David Disseldorp" <ddiss@...e.de>
Cc:     "Al Viro" <viro@...iv.linux.org.uk>, linux-nfs@...r.kernel.org,
        linux-fsdevel@...r.kernel.org,
        "LKML" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] VFS: filename_create(): fix incorrect intent.

On Thu, 31 Mar 2022, David Disseldorp wrote:
> On Thu, 31 Mar 2022 09:59:48 +1100, NeilBrown wrote:
> 
> > On Wed, 30 Mar 2022, David Disseldorp wrote:
> > > Hi Neil,
> > > 
> > > I gave this a spin and was wondering why xfstests wouldn't start with
> > > this change...
> > > 
> > > On Mon, 28 Mar 2022 11:56:48 +1100, NeilBrown wrote:
> > > ...  
> > > > 
> > > > diff --git a/fs/namei.c b/fs/namei.c
> > > > index 3f1829b3ab5b..3ffb42e56a8e 100644
> > > > --- a/fs/namei.c
> > > > +++ b/fs/namei.c
> > > > @@ -3676,7 +3676,6 @@ static struct dentry *filename_create(int dfd, struct filename *name,
> > > >  	int type;
> > > >  	int err2;
> > > >  	int error;
> > > > -	bool is_dir = (lookup_flags & LOOKUP_DIRECTORY);
> > > >  
> > > >  	/*
> > > >  	 * Note that only LOOKUP_REVAL and LOOKUP_DIRECTORY matter here. Any
> > > > @@ -3698,9 +3697,11 @@ static struct dentry *filename_create(int dfd, struct filename *name,
> > > >  	/* don't fail immediately if it's r/o, at least try to report other errors */
> > > >  	err2 = mnt_want_write(path->mnt);
> > > >  	/*
> > > > -	 * Do the final lookup.
> > > > +	 * Do the final lookup.  Request 'create' only if there is no trailing
> > > > +	 * '/', or if directory is requested.
> > > >  	 */
> > > > -	lookup_flags |= LOOKUP_CREATE | LOOKUP_EXCL;
> > > > +	if (!last.name[last.len] || (lookup_flags & LOOKUP_DIRECTORY))
> > > > +		lookup_flags |= LOOKUP_CREATE | LOOKUP_EXCL;  
> > > 
> > > This doesn't look right, as any LOOKUP_DIRECTORY flag gets dropped via
> > > the prior "lookup_flags &= LOOKUP_REVAL;".  
> > 
> > Arg.. thanks for testing - I clearly should have tested more broadly.
> > 
> > I could leave the "is_dir" variable there I guess.
> > Or maybe the masking statement should be 
> >     lookup_flags &= LOOKUP_REVAL | LOOKUP_DIRECTORY;
> > as that is a better match for the comment.
> 
> Modifying "lookup_flags" results in changed filename_parentat() and
> __lookup_hash() parameters, which isn't an intended consequence IIUC. I
> think retaining "is_dir" would make sense.

I think retaining is_dir is ugly.
Given that LOOKUP_DIRECTORY is meaningful, why mask it off?

The only flag *ever* passed to filename_parentat() is LOOKUP_REVAL, so
maybe it would make sense to change the parameter to be called "reval"
to make the meaning more obvious.

The only other use of lookup_flags is to pass it to ->lookup().
I guess LOOKUP_DIRECTORY isn't really meaningful there .. though it does
say "this lookup is never for a non-directory"... might that be helpful?

Maybe I'll have another look in the morning.

Thanks,
NeilBrown

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ