Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757062AbcDEBlA (ORCPT ); Mon, 4 Apr 2016 21:41:00 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:58195 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756509AbcDEBk6 (ORCPT ); Mon, 4 Apr 2016 21:40:58 -0400 From: "Eric W. Biederman" To: Linus Torvalds Cc: "H. Peter Anvin" , 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@debian.org, Willy Tarreau , Linux Kernel Mailing List , "Eric W. Biederman" Date: Mon, 4 Apr 2016 20:29:22 -0500 Message-Id: <1459819769-30387-6-git-send-email-ebiederm@xmission.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1459819769-30387-1-git-send-email-ebiederm@xmission.com> References: <878u0s3orx.fsf_-_@x220.int.ebiederm.org> <1459819769-30387-1-git-send-email-ebiederm@xmission.com> X-XM-AID: U2FsdGVkX1/BUu1gR+Dp6ALZggBCWaOZPeBpQArRgpY= 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 * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 773 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.4 (0.4%), b_tie_ro: 2.4 (0.3%), parse: 3.6 (0.5%), extract_message_metadata: 16 (2.1%), get_uri_detail_list: 2.9 (0.4%), tests_pri_-1000: 7 (0.9%), tests_pri_-950: 1.34 (0.2%), tests_pri_-900: 1.12 (0.1%), tests_pri_-400: 32 (4.1%), check_bayes: 30 (3.9%), b_tokenize: 13 (1.7%), b_tok_get_all: 8 (1.0%), b_comp_prob: 3.2 (0.4%), b_tok_touch_all: 3.5 (0.5%), b_finish: 0.73 (0.1%), tests_pri_0: 699 (90.4%), check_dkim_signature: 0.52 (0.1%), check_dkim_adsp: 3.0 (0.4%), tests_pri_500: 6 (0.7%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 06/13] devpts: Use the same default mode for both /dev/ptmx and dev/pts/ptmx 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 in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2510 Lines: 77 The default mode is 0666 on /dev/ptmx so we really don't gain anything except a bunch of hassle by not having the default mode on /dev/pts/ptmx also being 0666. Leave the default of ptmxmode at 0000 on the system mount of devpts to avoid the off chance that it would open an security hole on existing setups that change the permissions of devpts. Signed-off-by: "Eric W. Biederman" --- drivers/tty/tty_io.c | 5 +++-- fs/devpts/inode.c | 11 +++-------- include/linux/devpts_fs.h | 3 +++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 8d26ed79bb4c..438b2209ea41 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3597,9 +3597,10 @@ static char *tty_devnode(struct device *dev, umode_t *mode) { if (!mode) return NULL; - if (dev->devt == MKDEV(TTYAUX_MAJOR, 0) || - dev->devt == MKDEV(TTYAUX_MAJOR, 2)) + if (dev->devt == MKDEV(TTYAUX_MAJOR, 0)) *mode = 0666; + if (dev->devt == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)) + *mode = DEVPTS_DEFAULT_PTMX_MODE; return NULL; } diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index cb0cc4e33c3f..80c78bb472a9 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -30,14 +30,6 @@ #include #define DEVPTS_DEFAULT_MODE 0600 -/* - * ptmx is a new node in /dev/pts and will be unused in legacy (single- - * instance) mode. To prevent surprises in user space, set permissions of - * ptmx to 0. Use 'chmod' or remount with '-o ptmxmode' to set meaningful - * permissions. - */ -#define DEVPTS_DEFAULT_PTMX_MODE 0000 -#define PTMX_MINOR 2 /* * sysctl support for setting limits on the number of Unix98 ptys allocated. @@ -260,6 +252,9 @@ static int parse_mount_options(char *data, struct pts_mount_opts *opts) opts->mode = DEVPTS_DEFAULT_MODE; opts->ptmxmode = DEVPTS_DEFAULT_PTMX_MODE; opts->max = NR_UNIX98_PTY_MAX; + if (!devpts_mnt || + (&DEVPTS_SB(devpts_mnt->mnt_sb)->mount_opts == opts)) + opts->ptmxmode = 0; while ((p = strsep(&data, ",")) != NULL) { substring_t args[MAX_OPT_ARGS]; diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h index 260190690674..80908db52667 100644 --- a/include/linux/devpts_fs.h +++ b/include/linux/devpts_fs.h @@ -15,6 +15,9 @@ #include +#define DEVPTS_DEFAULT_PTMX_MODE 0666 +#define PTMX_MINOR 2 + #ifdef CONFIG_UNIX98_PTYS struct inode *devpts_ptmx(struct inode *inode, struct file *filp); -- 2.6.3