Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753806AbcDTBsq (ORCPT ); Tue, 19 Apr 2016 21:48:46 -0400 Received: from h2.hallyn.com ([78.46.35.8]:34620 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752758AbcDTBsp (ORCPT ); Tue, 19 Apr 2016 21:48:45 -0400 Date: Tue, 19 Apr 2016 20:48:41 -0500 From: "Serge E. Hallyn" To: "H. Peter Anvin" Cc: Linus Torvalds , "Eric W. Biederman" , Andy Lutomirski , security@debian.org, "security@kernel.org" , Al Viro , "security@ubuntu.com >> security" , Peter Hurley , Serge Hallyn , Willy Tarreau , Aurelien Jarno , One Thousand Gnomes , Jann Horn , Greg KH , Linux Kernel Mailing List , Jiri Slaby , Florian Weimer Subject: Re: Does anyone care about a race free ptsname? Message-ID: <20160420014840.GA3926@mail.hallyn.com> References: <570D4781.3070600@zytor.com> <877ffyzy1j.fsf_-_@x220.int.ebiederm.org> <87inzdmo9z.fsf_-_@x220.int.ebiederm.org> <5716C19B.1030500@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5716C19B.1030500@zytor.com> 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: 1554 Lines: 42 On Tue, Apr 19, 2016 at 04:39:07PM -0700, H. Peter Anvin wrote: > On 04/19/2016 04:23 PM, Linus Torvalds wrote: > > On Tue, Apr 19, 2016 at 11:44 AM, Eric W. Biederman > > wrote: > >> > >> I will take a look in a minute. Before I do that I want to mention > >> why I care about /dev/pts/ptmx. > >> > >> There is a posix function that is widely used called ptsname. It's > >> function is to take a master file descriptor and returns the path to the > >> slave. > >> > >> All we have in the kernel to support ptsname is an ioctl TIOCGPTN that > >> returns the pty number in the appropriate instance of devpts. > > > > Don't bother with that completely mis-designed interface.It's crap. > > > > So we'll keep it working for legacy models, but the whole "return an > > integer index" is just pure shit. It's not worth worrying about. > > > > We can (and probably should) just introduce a new ioctl or even a > > system call that just does the sane thing and returns the pathname > > from the kernel. > > > > What do you think of the idea of TIOCPTSOPEN (or whatever) to get a file > descriptor for the slave device given the master device? Then we can That's what i was thinking, since as I said many users just want blah = ptsname(fd); slavefd = open(blah, ...); so they really just want an open fd. > use realpath() or a readlink on /proc/self/fd/# to get the pathname if > needed. > > (Incidentally, we added getcwd() as a system call. Should we add > [f]realpath() as a system call too?) > > -hpa