public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	containers@lists.linux-foundation.org,
	Dave Hansen <haveblue@us.ibm.com>,
	linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>,
	sukadev@linux.vnet.ibm.com,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Serge Hallyn <serge.hallyn@canonical.com>
Subject: [PATCH 2/4] devpts: Set the default permissions of /dev/pts/ptmx and /dev/ptmx to 0666
Date: Sat, 22 Sep 2012 20:49:37 -0700	[thread overview]
Message-ID: <87ipb5760e.fsf_-_@xmission.com> (raw)
In-Reply-To: <87txup763i.fsf_-_@xmission.com> (Eric W. Biederman's message of "Sat, 22 Sep 2012 20:47:45 -0700")


These are difference instances of the same device not so it only
makes sense that they would have the same default permissions.

Move the definitions of DEVPTS_DEEFAULT_PTMX_MODE and PTM_MINOR
into devpts_fs.h so we can use the same definitions throughout.

Acked-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 drivers/tty/pty.c         |    6 +++---
 drivers/tty/tty_io.c      |    5 +++--
 fs/devpts/inode.c         |    8 --------
 include/linux/devpts_fs.h |    3 +++
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 5505ffc..6beb7e1 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -722,10 +722,10 @@ static void __init unix98_pty_init(void)
 	ptmx_fops.open = ptmx_open;
 
 	cdev_init(&ptmx_cdev, &ptmx_fops);
-	if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
-	    register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
+	if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, PTMX_MINOR), 1) ||
+	    register_chrdev_region(MKDEV(TTYAUX_MAJOR, PTMX_MINOR), 1, "/dev/ptmx") < 0)
 		panic("Couldn't register /dev/ptmx driver\n");
-	device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
+	device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, PTMX_MINOR), NULL, "ptmx");
 }
 
 #else
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index b425c79..6c3a7c2 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3314,9 +3314,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 5f0d64e..61b54aa 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -27,14 +27,6 @@
 #include <linux/seq_file.h>
 
 #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.
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
index 5ce0e5f..2d539ae 100644
--- a/include/linux/devpts_fs.h
+++ b/include/linux/devpts_fs.h
@@ -15,6 +15,9 @@
 
 #include <linux/errno.h>
 
+#define DEVPTS_DEFAULT_PTMX_MODE 0666
+#define PTMX_MINOR	2
+
 #ifdef CONFIG_UNIX98_PTYS
 
 int devpts_new_index(struct inode *ptmx_inode);
-- 
1.7.5.4


  parent reply	other threads:[~2012-09-23  3:49 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-24  0:05 [RFC] fix devpts mount behavior Serge Hallyn
2012-01-24  0:13 ` Linus Torvalds
2012-01-24  0:25   ` Serge Hallyn
2012-01-24  0:41     ` Linus Torvalds
2012-01-24  1:07       ` Al Viro
2012-01-24 18:21         ` Serge E. Hallyn
2012-01-24 20:16           ` Sukadev Bhattiprolu
2012-01-24 20:53             ` Serge E. Hallyn
2012-01-24 20:24         ` Eric W. Biederman
2012-01-24 22:02           ` Serge E. Hallyn
2012-01-24 22:54             ` Kay Sievers
2012-01-24 23:16               ` Serge Hallyn
2012-01-24 23:25                 ` Sukadev Bhattiprolu
2012-01-24 23:29                   ` Serge E. Hallyn
2012-01-24 23:27                 ` Kay Sievers
2012-01-28 19:51                   ` Serge Hallyn
2012-01-28 20:52                     ` Eric W. Biederman
2012-01-28 21:32                       ` Kay Sievers
2012-09-23  3:47                     ` [PATCH 0/4] devpts: " Eric W. Biederman
2012-09-23  3:48                       ` [PATCH 1/4] devpts: Remove CONFIG_DEVPTS_MULTIPLE_INSTANCES Eric W. Biederman
2012-09-23  3:49                       ` Eric W. Biederman [this message]
2012-09-23  3:50                       ` [PATCH 3/4] devpts: Make the newinstance option historical Eric W. Biederman
2012-09-23  4:19                         ` Al Viro
2012-09-23  4:46                           ` Al Viro
2012-09-23  5:59                           ` Eric W. Biederman
2012-09-23  6:30                             ` Al Viro
2012-09-23  6:34                               ` Al Viro
2012-09-23  7:00                                 ` Eric W. Biederman
2012-09-23  3:51                       ` [PATCH 4/4] devpts: Update the documentation Eric W. Biederman
2012-09-23 16:48                       ` [PATCH 0/4] devpts: fix devpts mount behavior H. Peter Anvin
2012-09-23 17:42                         ` Eric W. Biederman
2012-09-23 17:44                           ` H. Peter Anvin
2012-01-24 23:35             ` [RFC] " Eric W. Biederman
2012-01-24 20:55       ` Sukadev Bhattiprolu
2012-01-24 21:19         ` Nick Bowler
2012-01-24  0:26   ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ipb5760e.fsf_-_@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=apw@canonical.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=haveblue@us.ibm.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge.hallyn@canonical.com \
    --cc=serge@hallyn.com \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox