Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754036AbcDEDEi (ORCPT ); Mon, 4 Apr 2016 23:04:38 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:58430 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751433AbcDEDEh (ORCPT ); Mon, 4 Apr 2016 23:04:37 -0400 Date: Tue, 5 Apr 2016 04:03:33 +0100 From: Al Viro To: "Eric W. Biederman" Cc: Linus Torvalds , "H. Peter Anvin" , Peter Hurley , Greg KH , Jiri Slaby , Aurelien Jarno , Andy Lutomirski , Florian Weimer , Serge Hallyn , Jann Horn , "security@kernel.org" , security@ubuntu.com, security@debian.org, Willy Tarreau , Linux Kernel Mailing List Subject: Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Message-ID: <20160405030333.GL17997@ZenIV.linux.org.uk> References: <878u0s3orx.fsf_-_@x220.int.ebiederm.org> <1459819769-30387-1-git-send-email-ebiederm@xmission.com> <20160405025425.GK17997@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160405025425.GK17997@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1116 Lines: 23 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.