From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752164AbcDOPqz (ORCPT ); Fri, 15 Apr 2016 11:46:55 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:37263 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752086AbcDOPqr (ORCPT ); Fri, 15 Apr 2016 11:46:47 -0400 From: "Eric W. Biederman" To: Linus Torvalds Cc: "H. Peter Anvin" , Andy Lutomirski , security@debian.org, security@kernel.org, Al Viro , security@ubuntu.com, Peter Hurley , Serge Hallyn , Willy Tarreau , Aurelien Jarno , One Thousand Gnomes , Jann Horn , Greg KH , Linux Kernel Mailing List , Jiri Slaby , Florian Weimer , "Eric W. Biederman" Date: Fri, 15 Apr 2016 10:35:18 -0500 Message-Id: <1460734532-20134-2-git-send-email-ebiederm@xmission.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1460734532-20134-1-git-send-email-ebiederm@xmission.com> References: <877ffyzy1j.fsf_-_@x220.int.ebiederm.org> <1460734532-20134-1-git-send-email-ebiederm@xmission.com> X-XM-AID: U2FsdGVkX18PBhM8ia2IM7F4iVpd9GVOOz/P2LJiSQA= 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.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 * [sa03 1397; Body=1 Fuz1=1] X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 X-Spam-Combo: *;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 1042 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.8 (0.4%), b_tie_ro: 2.7 (0.3%), parse: 1.29 (0.1%), extract_message_metadata: 26 (2.5%), get_uri_detail_list: 2.4 (0.2%), tests_pri_-1000: 11 (1.1%), tests_pri_-950: 2.0 (0.2%), tests_pri_-900: 1.67 (0.2%), tests_pri_-400: 35 (3.3%), check_bayes: 33 (3.2%), b_tokenize: 15 (1.4%), b_tok_get_all: 8 (0.7%), b_comp_prob: 3.5 (0.3%), b_tok_touch_all: 3.5 (0.3%), b_finish: 0.89 (0.1%), tests_pri_0: 950 (91.2%), check_dkim_signature: 0.85 (0.1%), check_dkim_adsp: 4.3 (0.4%), tests_pri_500: 6 (0.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 02/16] devpts: Set the proper fops for /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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simplify things and accelerate the open a bit by setting ptmx_fops directly on the /dev/pts/ptmx inode. Signed-off-by: "Eric W. Biederman" --- drivers/tty/pty.c | 2 +- fs/devpts/inode.c | 6 +++--- include/linux/devpts_fs.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index e16a49b507ef..c71d5b6ddbb8 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -803,7 +803,7 @@ err_file: return retval; } -static struct file_operations ptmx_fops; +struct file_operations ptmx_fops; static void __init unix98_pty_init(void) { diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index e8bf61cd1bf8..4fc6c49b0efd 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -232,7 +232,6 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES static int mknod_ptmx(struct super_block *sb) { - int mode; int rc = -ENOMEM; struct dentry *dentry; struct inode *inode; @@ -274,8 +273,9 @@ static int mknod_ptmx(struct super_block *sb) inode->i_ino = 2; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; - mode = S_IFCHR|opts->ptmxmode; - init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2)); + inode->i_mode = S_IFCHR|opts->ptmxmode; + inode->i_fop = &ptmx_fops; + inode->i_rdev = MKDEV(TTYAUX_MAJOR, PTMX_MINOR); inode->i_uid = root_uid; inode->i_gid = root_gid; diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h index db329cd3d14e..ff2b7c274435 100644 --- a/include/linux/devpts_fs.h +++ b/include/linux/devpts_fs.h @@ -20,6 +20,8 @@ #ifdef CONFIG_UNIX98_PTYS +extern struct file_operations ptmx_fops; + int devpts_new_index(struct inode *ptmx_inode); void devpts_kill_index(struct inode *ptmx_inode, int idx); void devpts_add_ref(struct inode *ptmx_inode); -- 2.8.1