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

From: Eric W. Biederman
Date: Fri Apr 08 2016 - 15:04:44 EST


Al Viro <viro@xxxxxxxxxxxxxxxxxx> writes:

> 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.

Given that I can think of no other reason than this special case to ever
want to use this code. I figured having something incredibily special
case and obviously so was the way to go. Then at least no one would
mistake it for a general purpose facility.

Eric