Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1371063 > unrolled thread
| Started by | ebiederm@xmission.com (Eric W. Biederman) |
|---|---|
| First post | 2016-04-05 02:20 +0200 |
| Last post | 2016-04-11 22:20 +0200 |
| Articles | 20 on this page of 114 — 12 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 00/13] devpts: New instances for every mount ebiederm@xmission.com (Eric W. Biederman) - 2016-04-05 02:20 +0200
[PATCH 04/13] devpts: Stop rolling devpts_remount by hand in devpts_mount "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 05/13] devpts: Fail early (if appropriate) on overmount "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 08/13] devpts: Make devpts_kill_sb safe if fsi is NULL "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 03/13] devpts: Cleanup newinstance parsing "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 06/13] devpts: Use the same default mode for both /dev/ptmx and dev/pts/ptmx "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 09/13] devpts: Move the creation of /dev/pts/ptmx into fill_super "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 02/13] devpts: More obvious check for the system devpts in pty allocation "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 13/13] devpts: Kill the DEVPTS_MULTIPLE_INSTANCE config option "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 07/13] devpts: Move parse_mount_options into fill_super "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 03:50 +0200
[PATCH 12/13] devpts: Always return a distinct instance when mounting "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 04:00 +0200
[PATCH 11/13] vfs: Implement mount_super_once "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 04:00 +0200
[PATCH 10/13] devpts: Simplify devpts_mount by using mount_nodev "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-05 04:00 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-05 05:00 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-05 05:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-08 21:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-07 18:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-08 21:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-08 21:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-08 22:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Andy Lutomirski <luto@amacapital.net> - 2016-04-08 22:50 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-08 23:50 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Andy Lutomirski <luto@amacapital.net> - 2016-04-09 00:00 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-09 00:00 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-09 01:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-04-09 15:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "H. Peter Anvin" <hpa@zytor.com> - 2016-04-09 16:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-09 17:00 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "H. Peter Anvin" <hpa@zytor.com> - 2016-04-10 00:50 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-10 02:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "H. Peter Anvin" <hpa@zytor.com> - 2016-04-10 02:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-10 02:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Andy Lutomirski <luto@amacapital.net> - 2016-04-10 02:50 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "H. Peter Anvin" <hpa@zytor.com> - 2016-04-11 17:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-12 03:40 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Andy Lutomirski <luto@amacapital.net> - 2016-04-11 22:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "H. Peter Anvin" <hpa@zytor.com> - 2016-04-11 22:30 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-12 01:50 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-12 02:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-12 02:30 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-12 03:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "H. Peter Anvin" <hpa@zytor.com> - 2016-04-12 03:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-12 03:40 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-12 03:50 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-12 03:40 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-12 04:30 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-11 22:30 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Andy Lutomirski <luto@amacapital.net> - 2016-04-12 19:50 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-12 20:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup "H. Peter Anvin" <hpa@zytor.com> - 2016-04-12 21:20 +0200
[PATCH 01/16] devpts: Attempting to get it right ebiederm@xmission.com (Eric W. Biederman) - 2016-04-15 17:50 +0200
[PATCH 08/16] devpts: Stop rolling devpts_remount by hand in devpts_mount "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 17:50 +0200
[PATCH 05/16] vfs: Allow unlink, and rename on expirable file mounts "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 17:50 +0200
[PATCH 04/16] devpts: Teach /dev/ptmx to automount the appropriate devpts via path lookup "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 17:50 +0200
Re: [PATCH 04/16] devpts: Teach /dev/ptmx to automount the appropriate devpts via path lookup Jann Horn <jann@thejh.net> - 2016-04-16 00:10 +0200
Re: [PATCH 04/16] devpts: Teach /dev/ptmx to automount the appropriate devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-19 21:00 +0200
[PATCH 09/16] devpts: Fail early (if appropriate) on overmount "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 17:50 +0200
[PATCH 10/16] devpts: Move parse_mount_options into fill_super "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 17:50 +0200
[PATCH 06/16] devpts: More obvious check for the system devpts in pty allocation "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 17:50 +0200
[PATCH 01/16] devpts: Use the same default mode for both /dev/ptmx and dev/pts/ptmx "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 17:50 +0200
[PATCH 12/16] devpts: Move the creation of /dev/pts/ptmx into fill_super "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 18:00 +0200
[PATCH 11/16] devpts: Make devpts_kill_sb safe if fsi is NULL "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 18:00 +0200
[PATCH 16/16] devpts: Kill the DEVPTS_MULTIPLE_INSTANCE config option "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 18:00 +0200
[PATCH 15/16] devpts: Always return a distinct instance when mounting "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 18:00 +0200
[PATCH 13/16] devpts: Simplify devpts_mount by using mount_nodev "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 18:00 +0200
[PATCH 14/16] vfs: Implement mount_super_once "Eric W. Biederman" <ebiederm@xmission.com> - 2016-04-15 18:00 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-16 01:10 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once ebiederm@xmission.com (Eric W. Biederman) - 2016-04-19 20:40 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once "H. Peter Anvin" <hpa@zytor.com> - 2016-04-19 21:00 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once ebiederm@xmission.com (Eric W. Biederman) - 2016-04-19 21:20 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once "H. Peter Anvin" <hpa@zytor.com> - 2016-04-19 21:30 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 05:40 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2016-04-20 14:00 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once "H. Peter Anvin" <hpa@zytor.com> - 2016-04-20 18:20 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once "H. Peter Anvin" <hpa@zytor.com> - 2016-04-19 21:30 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once "H. Peter Anvin" <hpa@zytor.com> - 2016-04-19 21:00 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-20 01:30 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-20 03:30 +0200
Re: [PATCH 14/16] vfs: Implement mount_super_once "H. Peter Anvin" <hpa@zytor.com> - 2016-04-20 03:50 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right Andy Lutomirski <luto@amacapital.net> - 2016-04-15 18:50 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right ebiederm@xmission.com (Eric W. Biederman) - 2016-04-15 23:00 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right "H. Peter Anvin" <hpa@zytor.com> - 2016-04-15 23:40 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right ebiederm@xmission.com (Eric W. Biederman) - 2016-04-19 21:20 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-16 20:40 +0200
Does anyone care about a race free ptsname? ebiederm@xmission.com (Eric W. Biederman) - 2016-04-19 21:00 +0200
Re: Does anyone care about a race free ptsname? "H. Peter Anvin" <hpa@zytor.com> - 2016-04-19 21:30 +0200
Re: Does anyone care about a race free ptsname? ebiederm@xmission.com (Eric W. Biederman) - 2016-04-19 22:50 +0200
Re: Does anyone care about a race free ptsname? "H. Peter Anvin" <hpa@zytor.com> - 2016-04-19 23:10 +0200
Re: Does anyone care about a race free ptsname? "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-19 22:50 +0200
Re: Does anyone care about a race free ptsname? Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-20 01:30 +0200
Re: Does anyone care about a race free ptsname? "H. Peter Anvin" <hpa@zytor.com> - 2016-04-20 01:50 +0200
Re: Does anyone care about a race free ptsname? Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-20 02:20 +0200
Re: Does anyone care about a race free ptsname? "Serge E. Hallyn" <serge@hallyn.com> - 2016-04-20 03:50 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 00:20 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-20 01:40 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right Peter Hurley <peter@hurleysoftware.com> - 2016-04-20 02:30 +0200
Re: [PATCH 01/16] devpts: Attempting to get it right Peter Hurley <peter@hurleysoftware.com> - 2016-04-20 02:50 +0200
[PATCH] devpts: Make each mount of devpts an independent filesystem. ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 05:20 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-20 05:30 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 06:00 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-20 06:20 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 06:40 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. Konstantin Khlebnikov <koct9i@gmail.com> - 2016-04-20 06:40 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-20 07:00 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 17:10 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. Konstantin Khlebnikov <koct9i@gmail.com> - 2016-04-20 17:40 +0200
Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 18:10 +0200
[PATCH v2] devpts: Make each mount of devpts an independent filesystem. ebiederm@xmission.com (Eric W. Biederman) - 2016-04-20 19:20 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-12 02:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-12 02:10 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-12 02:40 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-12 03:00 +0200
Re: [PATCH 01/13] devpts: Teach /dev/ptmx to find the associated devpts via path lookup ebiederm@xmission.com (Eric W. Biederman) - 2016-04-11 22:20 +0200
Page 4 of 6 — ← Prev page 1 2 3 [4] 5 6 Next page →
| From | "Eric W. Biederman" <ebiederm@xmission.com> |
|---|---|
| Date | 2016-04-15 17:50 +0200 |
| Subject | [PATCH 01/16] devpts: Use the same default mode for both /dev/ptmx and dev/pts/ptmx |
| Message-ID | <roeal-5jh-7@gated-at.bofh.it> |
| In reply to | #1379934 |
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.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
drivers/tty/tty_io.c | 5 +++--
fs/devpts/inode.c | 8 --------
include/linux/devpts_fs.h | 3 +++
3 files changed, 6 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 655f21f99160..e8bf61cd1bf8 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -29,14 +29,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 e0ee0b3000b2..db329cd3d14e 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);
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | "Eric W. Biederman" <ebiederm@xmission.com> |
|---|---|
| Date | 2016-04-15 18:00 +0200 |
| Subject | [PATCH 12/16] devpts: Move the creation of /dev/pts/ptmx into fill_super |
| Message-ID | <roek2-5nF-11@gated-at.bofh.it> |
| In reply to | #1379943 |
The code makes more sense here and things are just clearer.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
fs/devpts/inode.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index f33744debb59..3aa223803a08 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -296,6 +296,10 @@ static inline void update_ptmx_mode(struct pts_fs_info *fsi)
{
return;
}
+static inline int mknod_ptmx(struct super_block *sb)
+{
+ return 0;
+}
#endif
static int devpts_remount(struct super_block *sb, int *flags, char *data)
@@ -408,11 +412,19 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
set_nlink(inode, 2);
s->s_root = d_make_root(inode);
- if (s->s_root)
- return 0;
+ if (!s->s_root) {
+ pr_err("get root dentry failed\n");
+ goto fail;
+ }
- pr_err("get root dentry failed\n");
+ error = mknod_ptmx(s);
+ if (error)
+ goto fail_dput;
+ return 0;
+fail_dput:
+ dput(s->s_root);
+ s->s_root = NULL;
fail:
return error;
}
@@ -481,10 +493,6 @@ static struct dentry *devpts_mount(struct file_system_type *fs_type,
if (error)
goto out_undo_sget;
- error = mknod_ptmx(s);
- if (error)
- goto out_undo_sget;
-
s->s_flags |= MS_ACTIVE;
} else {
/* Match mount_single ignore errors on remount */
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | "Eric W. Biederman" <ebiederm@xmission.com> |
|---|---|
| Date | 2016-04-15 18:00 +0200 |
| Subject | [PATCH 11/16] devpts: Make devpts_kill_sb safe if fsi is NULL |
| Message-ID | <roek2-5nF-13@gated-at.bofh.it> |
| In reply to | #1379943 |
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
fs/devpts/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 2f2760142ed2..f33744debb59 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -514,7 +514,8 @@ static void devpts_kill_sb(struct super_block *sb)
{
struct pts_fs_info *fsi = DEVPTS_SB(sb);
- ida_destroy(&fsi->allocated_ptys);
+ if (fsi)
+ ida_destroy(&fsi->allocated_ptys);
kfree(fsi);
kill_litter_super(sb);
}
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | "Eric W. Biederman" <ebiederm@xmission.com> |
|---|---|
| Date | 2016-04-15 18:00 +0200 |
| Subject | [PATCH 16/16] devpts: Kill the DEVPTS_MULTIPLE_INSTANCE config option |
| Message-ID | <roek2-5nF-9@gated-at.bofh.it> |
| In reply to | #1379943 |
Retain the code that was previously enabled with
DEVPTS_MULTIPLE_INSTANCES and remove the config option, and kill the
little bit of code that existed only when DEVPTS_MULTIPLE_INSTANCES
was not selected. With the recently updated semantics userspace
actively depends on having multiple instances of devpts for correct
operation.
Having each mount of devpts return a distinct instance ensures that
user space will not accidentally stomp gid or mode devpts options, of
the primary system devpts, by mounting devpts in a chroot environment.
A guarantee that userspace will not stomp attributes of system devpts
removes the need for a setuid root pt_chown executable.
Running a userspace without DEVPTS_MULTIPLE_INSTANCES that has depends
on the current behavior and has removed a setuid root pt_chown
exectuable will allow the system devpts gid and mode options to be
stomped breaking userspace. Which makes the ability to disable the
code previously selected by DEVPTS_MULTIPLE_INSTANCES actively wrong.
The size increase by always using the DEVPTS_MULTIPLE_INSTANCE
path is minimal, and the code is much easier to maintain and
use without having two different code paths to worry about.
The documentation has been updated to relfect this change.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
Documentation/filesystems/devpts.txt | 122 ++++++++++++++---------------------
drivers/tty/Kconfig | 11 ----
fs/devpts/inode.c | 34 ----------
3 files changed, 47 insertions(+), 120 deletions(-)
diff --git a/Documentation/filesystems/devpts.txt b/Documentation/filesystems/devpts.txt
index 30d2fcb32f72..984b645ac341 100644
--- a/Documentation/filesystems/devpts.txt
+++ b/Documentation/filesystems/devpts.txt
@@ -1,38 +1,32 @@
-To support containers, we now allow multiple instances of devpts filesystem,
-such that indices of ptys allocated in one instance are independent of indices
-allocated in other instances of devpts.
-
-To preserve backward compatibility, this support for multiple instances is
-enabled only if:
-
- - CONFIG_DEVPTS_MULTIPLE_INSTANCES=y, and
- - '-o newinstance' mount option is specified while mounting devpts
-
-IOW, devpts now supports both single-instance and multi-instance semantics.
-
-If CONFIG_DEVPTS_MULTIPLE_INSTANCES=n, there is no change in behavior and
-this referred to as the "legacy" mode. In this mode, the new mount options
-(-o newinstance and -o ptmxmode) will be ignored with a 'bogus option' message
-on console.
-
-If CONFIG_DEVPTS_MULTIPLE_INSTANCES=y and devpts is mounted without the
-'newinstance' option (as in current start-up scripts) the new mount binds
-to the initial kernel mount of devpts. This mode is referred to as the
-'single-instance' mode and the current, single-instance semantics are
-preserved, i.e PTYs are common across the system.
-
-The only difference between this single-instance mode and the legacy mode
-is the presence of new, '/dev/pts/ptmx' node with permissions 0000, which
-can safely be ignored.
-
-If CONFIG_DEVPTS_MULTIPLE_INSTANCES=y and 'newinstance' option is specified,
-the mount is considered to be in the multi-instance mode and a new instance
-of the devpts fs is created. Any ptys created in this instance are independent
-of ptys in other instances of devpts. Like in the single-instance mode, the
-/dev/pts/ptmx node is present. To effectively use the multi-instance mode,
-open of /dev/ptmx must be a redirected to '/dev/pts/ptmx' using a symlink or
-bind-mount.
+Each mount of the devpts filesystem is now a distinct instance from
+all other mounts of devpts. Mount options and indicies of ptys
+allocated in one instance are independent of indices allocated in
+other instances of devpts.
+
+If devpts is mounted without the 'newinstance' option (as in current
+start-up scripts) and if the initial kernel mount of devpts has not
+been exported to userspace the new mount binds to the initial kernel
+mount of devpts.
+
+If devpts is mounted with the 'newinstance' option or the initial
+internal mount of devpts has already been mounted a new instance of
+the devpts filesystem is created. Any ptys created in this instance
+are independent of the ptys created in other instances of devpts, and
+the initial permissions of those ptys are independent from the initial
+permissions from any other instance of the devpts filesystem.
+
+Ideally people will make use of the /dev/pts/ptmx device node to
+create ptys on the devpts filesystem. This can be done by updating
+userspace, bind mounting /dev/pts/ptmx onto /dev/ptmx or making
+/dev/ptmx a symlink to /dev/pts/ptmx.
+
+To be seemlessly backwards compatible an open of /dev/ptmx will look
+to see if the name pts in the same directory is the root directory of
+a devpts filesystem. If that is the case and it is not the initial
+instance of devpts /dev/pts/ptmx is opened. Otherwise the initial
+instance of devpts is opened. In older kernels /dev/ptmx did not
+perform this redirection.
Eg: A container startup script could do the following:
@@ -60,44 +54,34 @@ Per-instance limit could be set by adding mount option "max=<count>".
This feature was added in kernel 3.4 together with sysctl kernel.pty.reserve.
In kernels older than 3.4 sysctl kernel.pty.max works as per-instance limit.
-User-space changes
-------------------
+What user-space needs to do
+----------------------------
-In multi-instance mode (i.e '-o newinstance' mount option is specified at least
-once), following user-space issues should be noted.
+1. If the devpts filesystem is only mounted once /dev/pts/ptmx can be
+ ignored and no change is needed to system-startup scripts.
-1. If -o newinstance mount option is never used, /dev/pts/ptmx can be ignored
- and no change is needed to system-startup scripts.
+2. For best results userspace libraries and applications should be updated
+ to try opening /dev/pts/ptmx before /dev/ptmx, as /dev/pts/ptmx is less
+ ambiguous and higher performance.
-2. To effectively use multi-instance mode (i.e -o newinstance is specified)
- administrators or startup scripts should "redirect" open of /dev/ptmx to
- /dev/pts/ptmx using either a bind mount or symlink.
+3. To effectively use a new instance of devpts open of /dev/ptmx should
+ be redirected to /dev/pts/ptmx using either a bind mount or symlink.
$ mount -t devpts -o newinstance devpts /dev/pts
followed by either
- $ rm /dev/ptmx
$ ln -s pts/ptmx /dev/ptmx
$ chmod 666 /dev/pts/ptmx
or
$ mount -o bind /dev/pts/ptmx /dev/ptmx
-3. The '/dev/ptmx -> pts/ptmx' symlink is the preferred method since it
- enables better error-reporting and treats both single-instance and
- multi-instance mounts similarly.
-
- But this method requires that system-startup scripts set the mode of
- /dev/pts/ptmx correctly (default mode is 0000). The scripts can set the
- mode by, either
+4. The '/dev/ptmx -> pts/ptmx' symlink is the preferred method since it
+ enables better error-reporting and treats all cases the same.
- - adding ptmxmode mount option to devpts entry in /etc/fstab, or
- - using 'chmod 0666 /dev/pts/ptmx'
-
-4. If multi-instance mode mount is needed for containers, but the system
- startup scripts have not yet been updated, container-startup scripts
- should bind mount /dev/ptmx to /dev/pts/ptmx to avoid breaking single-
- instance mounts.
+5. If the system startup scripts do not create /dev/ptmx as a symlink,
+ container-startup scripts should bind mount /dev/ptmx to /dev/pts/ptmx
+ to avoid breaking the rest of the system.
Or, in general, container-startup scripts should use:
@@ -106,11 +90,9 @@ once), following user-space issues should be noted.
mount -o bind /dev/pts/ptmx /dev/ptmx
fi
- When all devpts mounts are multi-instance, /dev/ptmx can permanently be
- a symlink to pts/ptmx and the bind mount can be ignored.
-
-5. A multi-instance mount that is not accompanied by the /dev/ptmx to
- /dev/pts/ptmx redirection would result in an unusable/unreachable pty.
+6. A mount of devpts that is not accompanied by the /dev/ptmx to
+ /dev/pts/ptmx redirection will result in an unusable/unreachable pty,
+ on older kernels.
mount -t devpts -o newinstance lxcpts /dev/pts
@@ -121,21 +103,11 @@ once), following user-space issues should be noted.
would create a pty, say /dev/pts/7, in the initial kernel mount.
But /dev/pts/7 would be invisible in the new mount.
-6. The permissions for /dev/pts/ptmx node should be specified when mounting
- /dev/pts, using the '-o ptmxmode=%o' mount option (default is 0000).
+7. The permissions for /dev/pts/ptmx node should be specified when mounting
+ /dev/pts, using the '-o ptmxmode=%o' mount option (default is 0666 was 0000).
mount -t devpts -o newinstance -o ptmxmode=0644 devpts /dev/pts
The permissions can be later be changed as usual with 'chmod'.
chmod 666 /dev/pts/ptmx
-
-7. A mount of devpts without the 'newinstance' option results in binding to
- initial kernel mount. This behavior while preserving legacy semantics,
- does not provide strict isolation in a container environment. i.e by
- mounting devpts without the 'newinstance' option, a container could
- get visibility into the 'host' or root container's devpts.
-
- To workaround this and have strict isolation, all mounts of devpts,
- including the mount in the root container, should use the newinstance
- option.
diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
index 82c4d2e45319..95103054c0e4 100644
--- a/drivers/tty/Kconfig
+++ b/drivers/tty/Kconfig
@@ -120,17 +120,6 @@ config UNIX98_PTYS
All modern Linux systems use the Unix98 ptys. Say Y unless
you're on an embedded system and want to conserve memory.
-config DEVPTS_MULTIPLE_INSTANCES
- bool "Support multiple instances of devpts"
- depends on UNIX98_PTYS
- default n
- ---help---
- Enable support for multiple instances of devpts filesystem.
- If you want to have isolated PTY namespaces (eg: in containers),
- say Y here. Otherwise, say N. If enabled, each mount of devpts
- filesystem with the '-o newinstance' option will create an
- independent PTY namespace.
-
config LEGACY_PTYS
bool "Legacy (BSD) PTY support"
default y
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index e5e533fe824a..9ae15ef06475 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -109,11 +109,9 @@ static const match_table_t tokens = {
{Opt_uid, "uid=%u"},
{Opt_gid, "gid=%u"},
{Opt_mode, "mode=%o"},
-#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
{Opt_ptmxmode, "ptmxmode=%o"},
{Opt_newinstance, "newinstance"},
{Opt_max, "max=%d"},
-#endif
{Opt_err, NULL}
};
@@ -130,10 +128,8 @@ static inline struct pts_fs_info *DEVPTS_SB(struct super_block *sb)
static inline struct super_block *pts_sb_from_inode(struct inode *inode)
{
-#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC)
return inode->i_sb;
-#endif
if (!devpts_mnt)
return NULL;
return devpts_mnt->mnt_sb;
@@ -206,7 +202,6 @@ static int parse_mount_options(char *data, struct pts_mount_opts *opts)
return -EINVAL;
opts->mode = option & S_IALLUGO;
break;
-#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
case Opt_ptmxmode:
if (match_octal(&args[0], &option))
return -EINVAL;
@@ -220,7 +215,6 @@ static int parse_mount_options(char *data, struct pts_mount_opts *opts)
return -EINVAL;
opts->max = option;
break;
-#endif
default:
pr_err("called with bogus options\n");
return -EINVAL;
@@ -230,7 +224,6 @@ static int parse_mount_options(char *data, struct pts_mount_opts *opts)
return 0;
}
-#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
static int mknod_ptmx(struct super_block *sb)
{
int rc = -ENOMEM;
@@ -291,16 +284,6 @@ static void update_ptmx_mode(struct pts_fs_info *fsi)
inode->i_mode = S_IFCHR|fsi->mount_opts.ptmxmode;
}
}
-#else
-static inline void update_ptmx_mode(struct pts_fs_info *fsi)
-{
- return;
-}
-static inline int mknod_ptmx(struct super_block *sb)
-{
- return 0;
-}
-#endif
static int devpts_remount(struct super_block *sb, int *flags, char *data)
{
@@ -334,11 +317,9 @@ static int devpts_show_options(struct seq_file *seq, struct dentry *root)
seq_printf(seq, ",gid=%u",
from_kgid_munged(&init_user_ns, opts->gid));
seq_printf(seq, ",mode=%03o", opts->mode);
-#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
seq_printf(seq, ",ptmxmode=%03o", opts->ptmxmode);
if (opts->max < NR_UNIX98_PTY_MAX)
seq_printf(seq, ",max=%d", opts->max);
-#endif
return 0;
}
@@ -429,7 +410,6 @@ fail:
return error;
}
-#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
/*
* devpts_mount()
*
@@ -482,18 +462,6 @@ static struct dentry *devpts_mount(struct file_system_type *fs_type,
return root;
}
-#else
-/*
- * This supports only the legacy single-instance semantics (no
- * multiple-instance semantics)
- */
-static struct dentry *devpts_mount(struct file_system_type *fs_type, int flags,
- const char *dev_name, void *data)
-{
- return mount_single(fs_type, flags, data, devpts_fill_super);
-}
-#endif
-
static void devpts_kill_sb(struct super_block *sb)
{
struct pts_fs_info *fsi = DEVPTS_SB(sb);
@@ -508,9 +476,7 @@ static struct file_system_type devpts_fs_type = {
.name = "devpts",
.mount = devpts_mount,
.kill_sb = devpts_kill_sb,
-#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
.fs_flags = FS_USERNS_MOUNT | FS_USERNS_DEV_MOUNT,
-#endif
};
/*
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | "Eric W. Biederman" <ebiederm@xmission.com> |
|---|---|
| Date | 2016-04-15 18:00 +0200 |
| Subject | [PATCH 15/16] devpts: Always return a distinct instance when mounting |
| Message-ID | <roek3-5nF-25@gated-at.bofh.it> |
| In reply to | #1379943 |
When devpts is mounted and the newinstance flag is not passed the code
first checks to see if the system devpts instance has been exported to
userspace. If it has not the system devpts instance is returned
otherwise a fresh instance of devpts is allocated and returned.
If newinstance is passed a fresh devpts instance is always returned.
Combined with the earlier work to cause mounts of devpts to fail
if devpts is mounted over itself, this ensures that the system devpts
is mounted on /dev/pts on all of the systems I have tested.
This has been verified to work properly on openwrt-15.05, centos5,
centos6, centos7, debian-6.0.2, debian-7.9, debian-8.2, ubuntu-14.04.3,
ubuntu-15.10, fedora23, magia-5, mint-17.3, opensuse-42.1, slackware-14.1,
gentoo-20151225 (13.0?), archlinux-2015-12-01
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
fs/devpts/inode.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index c1c346190f35..e5e533fe824a 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -430,13 +430,6 @@ fail:
}
#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
-static int compare_init_pts_sb(struct super_block *s, void *p)
-{
- if (devpts_mnt)
- return devpts_mnt->mnt_sb == s;
- return 0;
-}
-
/*
* devpts_mount()
*
@@ -467,28 +460,26 @@ static int compare_init_pts_sb(struct super_block *s, void *p)
static struct dentry *devpts_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
- struct super_block *s;
+ struct dentry *root;
bool newinstance;
newinstance = parse_newinstance(data);
+ if (flags & MS_KERNMOUNT)
+ newinstance = true;
- /* Require newinstance for all user namespace mounts to ensure
+ /* Force newinstance for all user namespace mounts to ensure
* the mount options are not changed.
*/
- if ((current_user_ns() != &init_user_ns) && !newinstance)
- return ERR_PTR(-EINVAL);
-
- if (newinstance)
- return mount_nodev(fs_type, flags, data, devpts_fill_super);
-
- s = sget(fs_type, compare_init_pts_sb, set_anon_super, flags, NULL);
- if (IS_ERR(s))
- return ERR_CAST(s);
+ if (current_user_ns() != &init_user_ns)
+ newinstance = true;
- /* Match mount_single ignore errors on remount */
- devpts_remount(s, &flags, data);
+ root = NULL;
+ if (!newinstance)
+ root = mount_super_once(devpts_mnt->mnt_sb, flags, data);
+ if (IS_ERR_OR_NULL(root))
+ root = mount_nodev(fs_type, flags, data, devpts_fill_super);
- return dget(s->s_root);
+ return root;
}
#else
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | "Eric W. Biederman" <ebiederm@xmission.com> |
|---|---|
| Date | 2016-04-15 18:00 +0200 |
| Subject | [PATCH 13/16] devpts: Simplify devpts_mount by using mount_nodev |
| Message-ID | <roek3-5nF-23@gated-at.bofh.it> |
| In reply to | #1379943 |
Now that all of the work of setting up a superblock has been moved to
devpts_fill_super simplify devpts_mount by calling mount_nodev instead
of rolling mount_nodev by hand.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
fs/devpts/inode.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 3aa223803a08..c1c346190f35 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -467,7 +467,6 @@ static int compare_init_pts_sb(struct super_block *s, void *p)
static struct dentry *devpts_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
- int error;
struct super_block *s;
bool newinstance;
@@ -480,30 +479,16 @@ static struct dentry *devpts_mount(struct file_system_type *fs_type,
return ERR_PTR(-EINVAL);
if (newinstance)
- s = sget(fs_type, NULL, set_anon_super, flags, NULL);
- else
- s = sget(fs_type, compare_init_pts_sb, set_anon_super, flags,
- NULL);
+ return mount_nodev(fs_type, flags, data, devpts_fill_super);
+ s = sget(fs_type, compare_init_pts_sb, set_anon_super, flags, NULL);
if (IS_ERR(s))
return ERR_CAST(s);
- if (!s->s_root) {
- error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
- if (error)
- goto out_undo_sget;
-
- s->s_flags |= MS_ACTIVE;
- } else {
- /* Match mount_single ignore errors on remount */
- devpts_remount(s, &flags, data);
- }
+ /* Match mount_single ignore errors on remount */
+ devpts_remount(s, &flags, data);
return dget(s->s_root);
-
-out_undo_sget:
- deactivate_locked_super(s);
- return ERR_PTR(error);
}
#else
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | "Eric W. Biederman" <ebiederm@xmission.com> |
|---|---|
| Date | 2016-04-15 18:00 +0200 |
| Subject | [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <roek3-5nF-29@gated-at.bofh.it> |
| In reply to | #1379943 |
The devpts filesystem has a notion of a system or primary instance of
devpts. To retain the notion of a primary system instance of devpts
the code needs a way to allow userspace to mount the internally
mounted instance of devpts when it is not currently mounted by
userspace. The new helper mount_super_once allows that.
The function mount_super_once ignores vfsmounts that are in use but
are not mounted in userspace. The set of ignored mounts includes
internal mounts, lazily unmounted instances of mounts, and
loopback/bind mounts show root directory is not a filesystems root
directory.
Furthermore mount_super_once only allows exporting a mount to
userspace if it can account for every reference in s_active
on the superblock. Ensuring races do not allow two simultaneous
mount requestions export the same filesystem to userspace.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
fs/super.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/fs.h | 2 ++
2 files changed, 36 insertions(+)
diff --git a/fs/super.c b/fs/super.c
index 74914b1bae70..4a6552395fad 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -33,6 +33,7 @@
#include <linux/cleancache.h>
#include <linux/fsnotify.h>
#include <linux/lockdep.h>
+#include "mount.h"
#include "internal.h"
@@ -1101,6 +1102,39 @@ struct dentry *mount_single(struct file_system_type *fs_type,
}
EXPORT_SYMBOL(mount_single);
+struct dentry *mount_super_once(struct super_block *sb, int flags, void *data)
+{
+ /* Allow mounting the specified superblock by userspace if there
+ * are not any existing userspace mounts of it.
+ */
+ struct mount *mnt;
+ int count = 0;
+
+ /* Walk through the existing mounts of this superblock. Fail
+ * if any of those mounts are exported to userspace. Otherwise
+ * increment s_active if the superblock s_active count matches
+ * the number of mounts in the list. This ensures that multiple
+ * simultaneous calls to mount_super_once do not race and result
+ * in the filesystem exported to userspace multiple times.
+ */
+ lock_mount_hash();
+ list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
+ if (is_mounted(&mnt->mnt) && (mnt->mnt.mnt_root == sb->s_root)) {
+ unlock_mount_hash();
+ return ERR_PTR(-EBUSY);
+ }
+ count++;
+ }
+ if (atomic_cmpxchg(&sb->s_active, count, count + 1) != count) {
+ unlock_mount_hash();
+ return ERR_PTR(-EBUSY);
+ }
+ unlock_mount_hash();
+ down_write(&sb->s_umount);
+ do_remount_sb(sb, flags, data, 0);
+ return dget(sb->s_root);
+}
+
struct dentry *
mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
{
diff --git a/include/linux/fs.h b/include/linux/fs.h
index aade033bed49..465c1155bf72 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2002,6 +2002,8 @@ extern struct dentry *mount_single(struct file_system_type *fs_type,
extern struct dentry *mount_nodev(struct file_system_type *fs_type,
int flags, void *data,
int (*fill_super)(struct super_block *, void *, int));
+extern struct dentry *mount_super_once(struct super_block *sb,
+ int flags, void *data);
extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path);
void generic_shutdown_super(struct super_block *sb);
void kill_block_super(struct super_block *sb);
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2016-04-16 01:10 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rol29-2j5-1@gated-at.bofh.it> |
| In reply to | #1379955 |
On Fri, Apr 15, 2016 at 8:35 AM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> The devpts filesystem has a notion of a system or primary instance of
> devpts. To retain the notion of a primary system instance of devpts
> the code needs a way to allow userspace to mount the internally
> mounted instance of devpts when it is not currently mounted by
> userspace. The new helper mount_super_once allows that.
This is where I stopped reading this patch series.
No.
We want to get *rid* of the idiotic "primary instance" crap.
The whole and only point of doing the "which pts filesystem am I
associated with" for ptmx is to stop the idiotic "one devpts is
pecial".
I don't want to see 16 random patches.
I want to see *one* patch that makes /dev/ptmx look up the pts
filesystem, and be done with it.
Plonk.
Linus
[toc] | [prev] | [next] | [standalone]
| From | ebiederm@xmission.com (Eric W. Biederman) |
|---|---|
| Date | 2016-04-19 20:40 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpIJ4-2OR-23@gated-at.bofh.it> |
| In reply to | #1380362 |
Linus Torvalds <torvalds@linux-foundation.org> writes: > On Fri, Apr 15, 2016 at 8:35 AM, Eric W. Biederman > <ebiederm@xmission.com> wrote: >> The devpts filesystem has a notion of a system or primary instance of >> devpts. To retain the notion of a primary system instance of devpts >> the code needs a way to allow userspace to mount the internally >> mounted instance of devpts when it is not currently mounted by >> userspace. The new helper mount_super_once allows that. > > This is where I stopped reading this patch series. > > No. > > We want to get *rid* of the idiotic "primary instance" crap. That is actually pretty much the opposite of what you said last time, but having looked at the cost to maintian a "primary instance" notion and what will break if we don't I am happy to remove such a notion from devpts. > The whole and only point of doing the "which pts filesystem am I > associated with" for ptmx is to stop the idiotic "one devpts is > pecial". > > I don't want to see 16 random patches. > > I want to see *one* patch that makes /dev/ptmx look up the pts > filesystem, and be done with it. Now that I know where most of the landmines are in userspace I performed some limited testing to see to see what the implications are: Causing every userspace mount of devpts to use mount_nodev means the following: - Support for reserving ptys for the system devpts instance using /proc/sys/kernel/pty/reserve needs to be removed. - On CentOS6 devpts will wind up mounted twice /dev/pts. - Open of /dev/ptmx can use devpts_mnt to find the devpts filesystem. In my cursory testing userspace still boots and works desipite those changes so I am quite happy to go down this path. Eric
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-04-19 21:00 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpJ2p-2WB-7@gated-at.bofh.it> |
| In reply to | #1382786 |
On April 19, 2016 11:22:24 AM PDT, ebiederm@xmission.com wrote: >Linus Torvalds <torvalds@linux-foundation.org> writes: > >> On Fri, Apr 15, 2016 at 8:35 AM, Eric W. Biederman >> <ebiederm@xmission.com> wrote: >>> The devpts filesystem has a notion of a system or primary instance >of >>> devpts. To retain the notion of a primary system instance of devpts >>> the code needs a way to allow userspace to mount the internally >>> mounted instance of devpts when it is not currently mounted by >>> userspace. The new helper mount_super_once allows that. >> >> This is where I stopped reading this patch series. >> >> No. >> >> We want to get *rid* of the idiotic "primary instance" crap. > >That is actually pretty much the opposite of what you said last time, >but having looked at the cost to maintian a "primary instance" notion >and what will break if we don't I am happy to remove such a notion >from devpts. > >> The whole and only point of doing the "which pts filesystem am I >> associated with" for ptmx is to stop the idiotic "one devpts is >> pecial". >> >> I don't want to see 16 random patches. >> >> I want to see *one* patch that makes /dev/ptmx look up the pts >> filesystem, and be done with it. > >Now that I know where most of the landmines are in userspace I >performed >some limited testing to see to see what the implications are: > >Causing every userspace mount of devpts to use mount_nodev means the >following: > >- Support for reserving ptys for the system devpts instance using > /proc/sys/kernel/pty/reserve needs to be removed. > >- On CentOS6 devpts will wind up mounted twice /dev/pts. > >- Open of /dev/ptmx can use devpts_mnt to find the devpts filesystem. > >In my cursory testing userspace still boots and works desipite those >changes so I am quite happy to go down this path. > >Eric pty capping should probably be a devpts mount option, and perhaps a sufficiently privileged user could be allowed to set another mount option to allow that instance to dip into the reserved pool or exempt it completely from the global limit as set in sysctl. -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.
[toc] | [prev] | [next] | [standalone]
| From | ebiederm@xmission.com (Eric W. Biederman) |
|---|---|
| Date | 2016-04-19 21:20 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpJlM-3mj-29@gated-at.bofh.it> |
| In reply to | #1382793 |
"H. Peter Anvin" <hpa@zytor.com> writes: >>- Support for reserving ptys for the system devpts instance using >> /proc/sys/kernel/pty/reserve needs to be removed. >> >>Eric > > pty capping should probably be a devpts mount option There is a max option so pty capping is a per devpts option. > , and perhaps a > sufficiently privileged user could be allowed to set another mount > option to allow that instance to dip into the reserved pool or exempt > it completely from the global limit as set in sysctl. I agree that we could keep the reserved pool, and add a new way to access it. However no piece of existing userspace could use it. So the simplest thing to do (unless something actually breaks), is to just remove the reserve pool. Eric
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-04-19 21:30 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpJvs-3qe-1@gated-at.bofh.it> |
| In reply to | #1382808 |
On April 19, 2016 12:25:03 PM PDT, "H. Peter Anvin" <hpa@zytor.com> wrote: >On April 19, 2016 12:03:47 PM PDT, ebiederm@xmission.com wrote: >>"H. Peter Anvin" <hpa@zytor.com> writes: >> >>>>- Support for reserving ptys for the system devpts instance using >>>> /proc/sys/kernel/pty/reserve needs to be removed. >>>> >>>>Eric >>> >>> pty capping should probably be a devpts mount option >> >>There is a max option so pty capping is a per devpts option. >> >>> , and perhaps a >>> sufficiently privileged user could be allowed to set another mount >>> option to allow that instance to dip into the reserved pool or >exempt >>> it completely from the global limit as set in sysctl. >> >>I agree that we could keep the reserved pool, and add a new way to >>access it. However no piece of existing userspace could use it. So >>the >>simplest thing to do (unless something actually breaks), is to just >>remove the reserve pool. >> >>Eric > >Perhaps a (privileged) option to exempt from the global limit, then. >Something we can implement if asked for. > >However, I wouldn't be 100% that the reserved pool isn't used. Someone >added it presumably for a reason. An administrator could say it and >we'd have no idea. ... and if I personally was running a container-hosting system, I would *absolutely* set it to make sure the administrator could not get locked out. -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.
[toc] | [prev] | [next] | [standalone]
| From | ebiederm@xmission.com (Eric W. Biederman) |
|---|---|
| Date | 2016-04-20 05:40 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpR9D-1eV-1@gated-at.bofh.it> |
| In reply to | #1382810 |
"H. Peter Anvin" <hpa@zytor.com> writes: > On April 19, 2016 12:25:03 PM PDT, "H. Peter Anvin" <hpa@zytor.com> wrote: >> >>Perhaps a (privileged) option to exempt from the global limit, then. >>Something we can implement if asked for. >> >>However, I wouldn't be 100% that the reserved pool isn't used. Someone >>added it presumably for a reason. An administrator could say it and >>we'd have no idea. > > ... and if I personally was running a container-hosting system, I > would *absolutely* set it to make sure the administrator could not get > locked out. That is likely easier done by setting: echo RIDICULOUSLY_LARGE_NUMBER > /proc/sys/kernel/pty/max All I am certain about at this point is that no one cares on a day to day basis or in any kind of ordinary scenario so this is something that we can get away with changing. But yes I would not be surprised if we have to come back and implement something like your suggested extra mount option for devpts, so some specified instances can dip into the reserved pool. Eric
[toc] | [prev] | [next] | [standalone]
| From | "Austin S. Hemmelgarn" <ahferroin7@gmail.com> |
|---|---|
| Date | 2016-04-20 14:00 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpYXv-7jN-7@gated-at.bofh.it> |
| In reply to | #1383030 |
On 2016-04-19 23:27, Eric W. Biederman wrote: > "H. Peter Anvin" <hpa@zytor.com> writes: > >> On April 19, 2016 12:25:03 PM PDT, "H. Peter Anvin" <hpa@zytor.com> wrote: >>> >>> Perhaps a (privileged) option to exempt from the global limit, then. >>> Something we can implement if asked for. >>> >>> However, I wouldn't be 100% that the reserved pool isn't used. Someone >>> added it presumably for a reason. An administrator could say it and >>> we'd have no idea. >> >> ... and if I personally was running a container-hosting system, I >> would *absolutely* set it to make sure the administrator could not get >> locked out. > > That is likely easier done by setting: > echo RIDICULOUSLY_LARGE_NUMBER > /proc/sys/kernel/pty/max This may protect against administrative lockout on a sane system with responsible users, but it doesn't protect you from lockout due to a DoS attack, while the reserved pool does (or at least, it makes sure you can still allocate a few PTY's even when under attack).
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-04-20 18:20 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rq318-2dU-3@gated-at.bofh.it> |
| In reply to | #1383325 |
On April 20, 2016 4:50:53 AM PDT, "Austin S. Hemmelgarn" <ahferroin7@gmail.com> wrote: >On 2016-04-19 23:27, Eric W. Biederman wrote: >> "H. Peter Anvin" <hpa@zytor.com> writes: >> >>> On April 19, 2016 12:25:03 PM PDT, "H. Peter Anvin" <hpa@zytor.com> >wrote: >>>> >>>> Perhaps a (privileged) option to exempt from the global limit, >then. >>>> Something we can implement if asked for. >>>> >>>> However, I wouldn't be 100% that the reserved pool isn't used. >Someone >>>> added it presumably for a reason. An administrator could say it >and >>>> we'd have no idea. >>> >>> ... and if I personally was running a container-hosting system, I >>> would *absolutely* set it to make sure the administrator could not >get >>> locked out. >> >> That is likely easier done by setting: >> echo RIDICULOUSLY_LARGE_NUMBER > /proc/sys/kernel/pty/max >This may protect against administrative lockout on a sane system with >responsible users, but it doesn't protect you from lockout due to a DoS > >attack, while the reserved pool does (or at least, it makes sure you >can >still allocate a few PTY's even when under attack). ... or even accidental due to some runaway script. (I may or may not have some first hand knowledge of a similar situation once in college...) -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-04-19 21:30 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpJvs-3qe-3@gated-at.bofh.it> |
| In reply to | #1382808 |
On April 19, 2016 12:03:47 PM PDT, ebiederm@xmission.com wrote: >"H. Peter Anvin" <hpa@zytor.com> writes: > >>>- Support for reserving ptys for the system devpts instance using >>> /proc/sys/kernel/pty/reserve needs to be removed. >>> >>>Eric >> >> pty capping should probably be a devpts mount option > >There is a max option so pty capping is a per devpts option. > >> , and perhaps a >> sufficiently privileged user could be allowed to set another mount >> option to allow that instance to dip into the reserved pool or exempt >> it completely from the global limit as set in sysctl. > >I agree that we could keep the reserved pool, and add a new way to >access it. However no piece of existing userspace could use it. So >the >simplest thing to do (unless something actually breaks), is to just >remove the reserve pool. > >Eric Perhaps a (privileged) option to exempt from the global limit, then. Something we can implement if asked for. However, I wouldn't be 100% that the reserved pool isn't used. Someone added it presumably for a reason. An administrator could say it and we'd have no idea. -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-04-19 21:00 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpJ2q-2WB-11@gated-at.bofh.it> |
| In reply to | #1382786 |
On April 19, 2016 11:22:24 AM PDT, ebiederm@xmission.com wrote: >Linus Torvalds <torvalds@linux-foundation.org> writes: > >> On Fri, Apr 15, 2016 at 8:35 AM, Eric W. Biederman >> <ebiederm@xmission.com> wrote: >>> The devpts filesystem has a notion of a system or primary instance >of >>> devpts. To retain the notion of a primary system instance of devpts >>> the code needs a way to allow userspace to mount the internally >>> mounted instance of devpts when it is not currently mounted by >>> userspace. The new helper mount_super_once allows that. >> >> This is where I stopped reading this patch series. >> >> No. >> >> We want to get *rid* of the idiotic "primary instance" crap. > >That is actually pretty much the opposite of what you said last time, >but having looked at the cost to maintian a "primary instance" notion >and what will break if we don't I am happy to remove such a notion >from devpts. > >> The whole and only point of doing the "which pts filesystem am I >> associated with" for ptmx is to stop the idiotic "one devpts is >> pecial". >> >> I don't want to see 16 random patches. >> >> I want to see *one* patch that makes /dev/ptmx look up the pts >> filesystem, and be done with it. > >Now that I know where most of the landmines are in userspace I >performed >some limited testing to see to see what the implications are: > >Causing every userspace mount of devpts to use mount_nodev means the >following: > >- Support for reserving ptys for the system devpts instance using > /proc/sys/kernel/pty/reserve needs to be removed. > >- On CentOS6 devpts will wind up mounted twice /dev/pts. > >- Open of /dev/ptmx can use devpts_mnt to find the devpts filesystem. > >In my cursory testing userspace still boots and works desipite those >changes so I am quite happy to go down this path. > >Eric On a totally different subject: I'm still quite unhappy with the pty number assignment policy. We had to move away from a completely circular policy because of glibc issues in the handling of utmp, which may or may not have been fixed since, but the current policy of always allocating the lowest number is absolutely pessimal for accidental references to a stale pty. At the time, I suggested that we'd go with a circular policy within the used high water mark, which would still work around the glibc problem; another option would be to quarantine a pty number for a time before reallocation. -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.
[toc] | [prev] | [next] | [standalone]
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2016-04-20 01:30 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpNfI-6EG-9@gated-at.bofh.it> |
| In reply to | #1382786 |
On Tue, Apr 19, 2016 at 11:22 AM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>>
>> No.
>>
>> We want to get *rid* of the idiotic "primary instance" crap.
>
> That is actually pretty much the opposite of what you said last time,
> but having looked at the cost to maintian a "primary instance" notion
> and what will break if we don't I am happy to remove such a notion
> from devpts.
No, it's what I said last time too, but there may have been an misunderstanding.
I _violently_ oppose the stupid DEVPTS_MULTIPLE_INSTANCES config option.
But I do _not_ oppose it because I want to have that "primary
instance" cap. Quite the reverse. I oppose it because the *option* is
stupid, and we should not have such an option.
The kernel should always do multiple instances. There should never
_ever_ be a "single instance" option, although obviously if you were
to do a bind-mount of devpts, the bound mount would be the same
instance.
But if you do two separate mounts, they should alwats be separate insnaces.
So what I want to fix is the crazy "that doesn't work" problem with
Ubuntu or CentOS (or whatever distro it was) breaking, because
/dev/ptmx ends up pointing to the *wrong* instance.
This is literally why I think /dev/ptmx should just look up /dev/pts -
simply to get rid of that idiotic special instance. It should not
exist. It should not exist in the kernel, and it shouldn't exist in
user space.
Linus
[toc] | [prev] | [next] | [standalone]
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2016-04-20 03:30 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpP7R-86l-15@gated-at.bofh.it> |
| In reply to | #1382902 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Apr 19, 2016 at 4:29 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> I _violently_ oppose the stupid DEVPTS_MULTIPLE_INSTANCES config option.
So just to show what I want to actually happen, here's the hacky patch
on top of my (now merged) cleanup patch that actually does what I want
devpts to do.
I say it's hacky, because the "follow_mount()" thing there really is
pretty hacky. Al - suggestions for how to do this *right*?
But this actually forcibly removes the whole "newinstance" thing, and
makes every pts mount a new instance, and just relies on "ptmx" doing
the right thing.
In other words, with this patch, you can *literally* do just this (as
root, obviously):
mkdir test-dir
cd test-dir
mknod ptmx c 5 2
mkdir pts
mount -t devpts pts pts
and after that it all just works. You can do this:
ls -l pts
which shows just the other ptmx noode (that is unused and pointless -
I'd actually like to just remove it, but whatever), and then you can
do
sleep 100 < ptmx &
sleep 100 < ptmx &
ls -l pts
and you will magically see those new 0/1 entries in that pts
subdirectory.. It's entirely independent of /dev/pts/, and there's no
magic connection or any magic dis-connection. It all JustWorks(tm).
Note how this works even *outside* of /dev. But it works inside of
/dev equally well.
Now, a *real* patch would
- solve that "follow_mount()" issue some other way
- not remove the newinstance code immediately (I did it to show that
even the bootup works with a unmodified distro)
- actually remove the whole "DEVPTS_MULTIPLE_INSTANCES" config option
- I'm not happy with devpts_pty_kill(). I would want to clean that up
a bit somehow. I think this is at least partly what Peter Hurley was
talking about. That thing is not pretty.
so this attached patch is by no means meant to be applied as-is. But
it's meant to show what (a) the new organization allows and (b) what I
was going for.
Linus
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-04-20 03:50 +0200 |
| Subject | Re: [PATCH 14/16] vfs: Implement mount_super_once |
| Message-ID | <rpPrd-8e3-31@gated-at.bofh.it> |
| In reply to | #1382961 |
On April 19, 2016 6:24:12 PM PDT, Linus Torvalds <torvalds@linux-foundation.org> wrote: >On Tue, Apr 19, 2016 at 4:29 PM, Linus Torvalds ><torvalds@linux-foundation.org> wrote: >> >> I _violently_ oppose the stupid DEVPTS_MULTIPLE_INSTANCES config >option. > >So just to show what I want to actually happen, here's the hacky patch >on top of my (now merged) cleanup patch that actually does what I want >devpts to do. > >I say it's hacky, because the "follow_mount()" thing there really is >pretty hacky. Al - suggestions for how to do this *right*? > >But this actually forcibly removes the whole "newinstance" thing, and >makes every pts mount a new instance, and just relies on "ptmx" doing >the right thing. > >In other words, with this patch, you can *literally* do just this (as >root, obviously): > > mkdir test-dir > cd test-dir > > mknod ptmx c 5 2 > mkdir pts > mount -t devpts pts pts > >and after that it all just works. You can do this: > > ls -l pts > >which shows just the other ptmx noode (that is unused and pointless - >I'd actually like to just remove it, but whatever), and then you can >do > > sleep 100 < ptmx & > sleep 100 < ptmx & > ls -l pts > >and you will magically see those new 0/1 entries in that pts >subdirectory.. It's entirely independent of /dev/pts/, and there's no >magic connection or any magic dis-connection. It all JustWorks(tm). > >Note how this works even *outside* of /dev. But it works inside of >/dev equally well. > >Now, a *real* patch would > > - solve that "follow_mount()" issue some other way > > - not remove the newinstance code immediately (I did it to show that >even the bootup works with a unmodified distro) > > - actually remove the whole "DEVPTS_MULTIPLE_INSTANCES" config option > > - I'm not happy with devpts_pty_kill(). I would want to clean that up >a bit somehow. I think this is at least partly what Peter Hurley was >talking about. That thing is not pretty. > >so this attached patch is by no means meant to be applied as-is. But >it's meant to show what (a) the new organization allows and (b) what I >was going for. > > Linus I say let's remove it unless ptmxmode= is specified. That way we don't break people who actually did the symlink thing. -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.
[toc] | [prev] | [next] | [standalone]
Page 4 of 6 — ← Prev page 1 2 3 [4] 5 6 Next page →
Back to top | Article view | linux.kernel
csiph-web