Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753549AbcDIO4j (ORCPT ); Sat, 9 Apr 2016 10:56:39 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:56900 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552AbcDIO4h (ORCPT ); Sat, 9 Apr 2016 10:56:37 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: "H. Peter Anvin" Cc: One Thousand Gnomes , Linus Torvalds , Peter Hurley , Greg KH , Jiri Slaby , Aurelien Jarno , Andy Lutomirski , Florian Weimer , Al Viro , Serge Hallyn , Jann Horn , "security\@kernel.org" , "security\@ubuntu.com \>\> security" , security@debian.org, Willy Tarreau , Linux Kernel Mailing List References: <878u0s3orx.fsf_-_@x220.int.ebiederm.org> <1459819769-30387-1-git-send-email-ebiederm@xmission.com> <87twjcorwg.fsf@x220.int.ebiederm.org> <20160409140909.42315e6d@lxorguk.ukuu.org.uk> <83FE8CD2-C0A2-4ADB-AEBD-8DD89AD4F88A@zytor.com> Date: Sat, 09 Apr 2016 09:45:46 -0500 In-Reply-To: <83FE8CD2-C0A2-4ADB-AEBD-8DD89AD4F88A@zytor.com> (H. Peter Anvin's message of "Sat, 09 Apr 2016 07:10:04 -0700") Message-ID: <87bn5ij0x1.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX1/L87334O5zOZPpR2mY+XvyNGl1SkM83fk= X-SA-Exim-Connect-IP: 67.3.249.252 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * 0.1 XMSolicitRefs_0 Weightloss drug X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;"H. Peter Anvin" X-Spam-Relay-Country: X-Spam-Timing: total 1288 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.0 (0.3%), b_tie_ro: 2.8 (0.2%), parse: 1.28 (0.1%), extract_message_metadata: 31 (2.4%), get_uri_detail_list: 2.8 (0.2%), tests_pri_-1000: 12 (1.0%), tests_pri_-950: 2.1 (0.2%), tests_pri_-900: 1.69 (0.1%), tests_pri_-400: 39 (3.0%), check_bayes: 37 (2.9%), b_tokenize: 15 (1.2%), b_tok_get_all: 10 (0.7%), b_comp_prob: 5 (0.4%), b_tok_touch_all: 3.0 (0.2%), b_finish: 0.82 (0.1%), tests_pri_0: 1060 (82.3%), check_dkim_signature: 0.83 (0.1%), check_dkim_adsp: 4.8 (0.4%), tests_pri_500: 132 (10.2%), poll_dns_idle: 122 (9.5%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1878 Lines: 49 "H. Peter Anvin" writes: > On April 9, 2016 6:09:09 AM PDT, One Thousand Gnomes wrote: >> >>> If anyone has a better idea on how userspace should connect the >>master >>> pty file descriptor the slave file descriptor, I would be willing to >>> implement that instead. >> >>If we are willing to go away from the existing mess of a tty interface >>inflicted on us by BSD and then mashed up by POSIX then a syscall of >> >> int err = ptypair(int fd[2], int perms, int flags); >> >>[where flags is the O_ ones we usually need to cover (CLOEXEC etc) and >>maybe even some kind of "private" flag to say don't even expose it via >>devpts). >> >>would do remarkably sane things to the majoirty of use cases as it >>breaks >>the dependence on grantpt and also the historic screwup that pty pairs >>aren't allocated atomically with both file handles returned as pipe() >>does. >> >>Alan > > We don't even need to do that if we'd be willing to change the user > space interface... if we could rely on the POSIX interface then > posix_openpt() could simply open /dev/pts/ptmx and everything would > just work. At a quick skim it does look like userspace uses posix_openpt for the most part. Certainly portable apps that can run on FreeBSD do. And just grepping through binaries all of the ones I have checked so far are calling posix_openpt. Peter if you or someone could start updating the userspace version of posix_openpt to use /dev/pts/ptmx when available over /dev/ptmx in parallel to the kernel work to always allow mount of devpts to give distinct instances that would be great. > The trick here is how to make it work in the presence of some > extremely bad practices in existing userspace. Yeah. I am going to look and see if I can move this controversial bit to a separate patch so we can discuss it more conviniently. Eric