Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup

From: Al Viro
Date: Mon Apr 04 2016 - 23:04:41 EST


On Tue, Apr 05, 2016 at 03:54:25AM +0100, Al Viro wrote:

> That, I take it, is a lookup for .. and buggering off if it fails *or* if
> we had been in caller's root or something that overmount it? Not that the
> latter had been possible - root is a directory and can be overmounted only
> by another such, and we are called from ->open() of a device node.
>
> > + /* Remember the result of this permission check for later */
> > + ret = inode_permission(path.dentry->d_inode, MAY_EXEC);
> > + if (path_pts(&path))
> > + goto fail;
>
> Egads, man - you've just introduced a special function for looking up
> something named "pts" in a given directory!
>
> The reason not to use kern_path() would be what, the fact that it doesn't
> allow starting at given location? So let's make a variant that would - and
> rather than bothering with RCU, just go for something like (completely
> untested)

Ah... Right, that would demand exec permissions on the starting point.
Still, this is incredibly ugly ;-/ I'll try to come up with something
more tolerable, but this "path_pts" thing is too ugly to live. Seriously.