[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87k2jtc5dk.fsf@x220.int.ebiederm.org>
Date: Tue, 19 Apr 2016 22:43:03 -0500
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Al Viro <viro@...IV.linux.org.uk>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...capital.net>, security@...ian.org,
"security\@kernel.org" <security@...nel.org>,
"security\@ubuntu.com \>\> security" <security@...ntu.com>,
Peter Hurley <peter@...leysoftware.com>,
Serge Hallyn <serge.hallyn@...ntu.com>,
Willy Tarreau <w@....eu>,
Aurelien Jarno <aurelien@...el32.net>,
One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>,
Jann Horn <jann@...jh.net>, Greg KH <greg@...ah.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Jiri Slaby <jslaby@...e.com>, Florian Weimer <fw@...eb.enyo.de>
Subject: Re: [PATCH] devpts: Make each mount of devpts an independent filesystem.
Al Viro <viro@...IV.linux.org.uk> writes:
> On Tue, Apr 19, 2016 at 10:04:20PM -0500, Eric W. Biederman wrote:
>> +#ifdef CONFIG_UNIX98_PTYS
>> +int path_pts(struct path *path)
>> +{
>> + /* Find "pts" in the same directory as the input path */
>> + struct dentry *child, *parent;
>> + struct qstr this;
>> + int ret;
>> +
>> + ret = path_parent_directory(path);
>> + if (ret)
>> + return ret;
>> +
>> + parent = path->dentry;
>> + if (!d_can_lookup(parent))
>> + return -ENOENT;
>
> And how, pray tell, would a parent of anything fail to be a directory?
It is to make that function be visually distinct from path_parentat
which does something rather different.
>> + this.name = "pts";
>> + this.len = 3;
>> + this.hash = full_name_hash(this.name, this.len);
>> + if (parent->d_flags & DCACHE_OP_HASH) {
>> + int err = parent->d_op->d_hash(parent, &this);
>> + if (err < 0)
>> + return err;
>> + }
>> + inode_lock(parent->d_inode);
>
> What the hell for? What does that lock on parent change for the
> dcache lookup you are doing here?
Good point. That is overkill. As we know the dentry is a mount point and
must be in the dcache, the customary lock for performing a lookup from
the disk is not necessary.
>> + child = d_lookup(parent, &this);
>> + inode_unlock(parent->d_inode);
>> + if (!child)
>> + return -ENOENT;
>
> Take a look at d_hash_and_lookup(), BTW...
Yes. That does look like a reasonable simplification.
Eric
Powered by blists - more mailing lists