From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11896 Path: news.gmane.org!.POSTED!not-for-mail From: Christian Brauner Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 0/1] openpty: use TIOCGPTPEER to open slave side fd Date: Fri, 1 Sep 2017 17:35:57 +0200 Message-ID: <20170901153558.29715-1-christian.brauner@ubuntu.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1504280210 18676 195.159.176.226 (1 Sep 2017 15:36:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 1 Sep 2017 15:36:50 +0000 (UTC) Cc: Christian Brauner To: musl@lists.openwall.com Original-X-From: musl-return-11909-gllmg-musl=m.gmane.org@lists.openwall.com Fri Sep 01 17:36:36 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dnnza-0003eN-Ru for gllmg-musl@m.gmane.org; Fri, 01 Sep 2017 17:36:22 +0200 Original-Received: (qmail 32281 invoked by uid 550); 1 Sep 2017 15:36:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 32234 invoked from network); 1 Sep 2017 15:36:27 -0000 X-Virus-Scanned: amavisd-new at heinlein-support.de Xref: news.gmane.org gmane.linux.lib.musl.general:11896 Archived-At: Hi, Newer kernels expose the ioctl TIOCGPTPEER [1] call to userspace which allows to safely allocate a file descriptor for a pty slave based solely on the master file descriptor. This allows us to avoid path-based operations and makes this function a lot safer in the face of devpts mounts in different mount namespaces. [1]: https://patchwork.kernel.org/patch/9760743/ The way I wrote this patch it doesn't use the snprintf() and open() routine as a fallback in case the ioctl() call fails. If this is a compatibility issue for non-Linux systems I can rewrite. But the musl documentation gave me the impression that this is not really a concern. If possible, please Cc me on this since I'm not subscribed to the mailing list (yet). Thanks! Christian Christian Brauner (1): openpty: use TIOCGPTPEER to open slave side fd src/misc/openpty.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) -- 2.14.1