devpts: handle bind-mounts correctly
v5 cover devpts: handle bind-mounts correctly
Resending to CC grekh.
Hey everyone,
This is the fith iteration of this patch. Per-patch changes are summarized in the individual patches:
ChangeLog v4->v5:
* added non-functional patch to document devpts_mntget(). Reason for putting this in a separate patch is that it allows you, Linus and Eric, to simply drop it if judged useless.
* reverse error handling logic to further simplify
* dput() dentry in the non-function patch. This was not really a problem since the following patch included a fix for it. But better to get it right in all individual patches.
* I did another rewrite of the problem analysis for posterity in the patch "Subject: [PATCH 2/3 v3] devpts: resolve devpts bind-mounts" and in this cover letter.
ChangeLog v3->v4:
* small logical simplifications
* add test that bind-mounts of /dev/pts/ptmx to locations that do not resolve to a valid slave pty path under the originating devpts mount fail
ChangeLog v2->v3:
* rewritten commit message to thoroughly analyse the problem for posterity in the patch "Subject: [PATCH 2/3 v3] devpts: resolve devpts bind-mounts" and in this cover letter.
* extended selftests to test for correct handling of /dev/pts/ptmx bind-mounts to /dev/ptmx and non-standard devpts mounts such as mount -t devpts devpts /mnt
ChangeLog v1->v2:
* see individual patches
ChangeLog v0->v1:
* see individual patches
Christian Brauner (4):
devpts: hoist out check for DEVPTS_SUPER_MAGIC
devpts: resolve devpts bind-mounts
devpts: comment devpts_mntget()
selftests: add devpts selftests
fs/devpts/inode.c | 66 +++-- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/filesystems/.gitignore | 1 + tools/testing/selftests/filesystems/Makefile | 2 +- tools/testing/selftests/filesystems/devpts_pts.c | 313 +++++++++++++++++++++++ 5 files changed, 363 insertions(+), 20 deletions(-) create mode 100644 tools/testing/selftests/filesystems/devpts_pts.c
Signature · 1 line
2.15.1
PATCH RESEND v5 1/4 devpts: hoist out check for DEVPTS_SUPER_MAGIC
Hoist the check whether we have already found a suitable devpts filesystem out of devpts_ptmx_path() in preparation for the devpts bind-mount resolution patch. This is a non-functional change.
---
ChangeLog v4->v5:
* dput() dentry
ChangeLog v3->v4:
* patch unchanged
ChangeLog v2->v3:
* patch unchanged
ChangeLog v1->v2:
* patch added
ChangeLog v0->v1:
* patch not present
--- fs/devpts/inode.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
fs/devpts/inode.c +15 -11
@@ -138,10 +138,6 @@ static int devpts_ptmx_path(struct path *path)struct super_block *sb;int err; -/* Has the devpts filesystem already been found? */ -if (path->mnt->mnt_sb->s_magic ==DEVPTS_SUPER_MAGIC ) -return 0 ; -/* Is a devpts filesystem at "pts" in the same directory? */ err =path_pts (path);if (err)
@@ -159,21 +155,25 @@ static int devpts_ptmx_path(struct path *path)struct vfsmount *devpts_mntget (struct file *filp,struct pts_fs_info *fsi) {struct path path; -int err; +int err =0 ; path = filp->f_path;path_get (&path); - err =devpts_ptmx_path (&path); +/* Has the devpts filesystem already been found? */ +if (path.mnt->mnt_sb->s_magic !=DEVPTS_SUPER_MAGIC ) + err =devpts_ptmx_path (&path);dput (path.dentry);if (err) {mntput (path.mnt);return ERR_PTR (err); } +if (DEVPTS_SB (path.mnt->mnt_sb) != fsi) {mntput (path.mnt);return ERR_PTR (-ENODEV ); } +return path.mnt; }
@@ -182,15 +182,19 @@ struct pts_fs_info *devpts_acquire(struct file *filp)struct pts_fs_info *result;struct path path;struct super_block *sb; -int err; path = filp->f_path;path_get (&path); - err =devpts_ptmx_path (&path); -if (err) { - result =ERR_PTR (err); - goto out; +/* Has the devpts filesystem already been found? */ +if (path.mnt->mnt_sb->s_magic !=DEVPTS_SUPER_MAGIC ) { +int err; + + err =devpts_ptmx_path (&path); +if (err) { + result =ERR_PTR (err); + goto out; + } }/*
Signature · 1 line
2.15.1
PATCH RESEND v5 2/4 devpts: resolve devpts bind-mounts
In reply to Christian BraunerMost libcs will still look at /dev/ptmx when opening the master fd of a pty device. When /dev/ptmx is a bind-mount of /dev/pts/ptmx and the TIOCGPTPEER ioctl() is used to safely retrieve a file descriptor for the slave side of the pty based on the master fd, the /proc/self/fd/{0,1,2} symlinks will point to /. A very simply reproducer for this issue presupposing a libc that uses TIOCGPTPEER in its openpty() implementation is:
unshare --mount
mount --bind /dev/pts/ptmx /dev/ptmx
chmod 666 /dev/ptmx
script
ls -al /proc/self/fd/0
Having bind-mounts of /dev/pts/ptmx to /dev/ptmx not working correctly is a regression. In addition, it is also a fairly common scenario in containers employing user namespaces.
The reason for the current failure is that the kernel tries to verify the useability of the devpts filesystem without resolving the /dev/ptmx bind-mount first. This will lead it to detect that the dentry is escaping its bind-mount. The reason is that while the devpts filesystem mounted at /dev/pts has the devtmpfs mounted at /dev as its parent mount:
21 -- -- / /dev
-- 21 -- / /dev/pts
devtmpfs and devpts are on different devices
-- -- 0:6 / /dev
-- -- 0:20 / /dev/pts
This has the consequence that the pathname of the parent directory of the devpts filesystem mount at /dev/pts is /. So if /dev/ptmx is a bind-mount of /dev/pts/ptmx then the /dev/ptmx bind-mount and the devpts mount at /dev/pts will end up being located on the same device which is recorded in the superblock of their vfsmount. This means the parent directory of the /dev/ptmx bind-mount will be /ptmx:
-- -- ---- /ptmx /dev/ptmx
Without the bind-mount resolution patch the kernel will now perform the bind-mount escape check directly on /dev/ptmx. The function responsible for this is devpts_ptmx_path() which calls pts_path() which in turn calls path_parent_directory(). Based on the above explanation, path_parent_directory() will yield / as the parent directory for the /dev/ptmx bind-mount and not the expected /dev. Thus, the kernel detects that /dev/ptmx is escaping its bind-mount and will set /proc/<pid>/fd/<nr> to /.
This patch changes the logic to first resolve any bind-mounts. After the bind-mounts have been resolved (i.e. we have traced it back to the associated devpts mount) devpts_ptmx_path() can be called. In order to guarantee correct path generation for the slave file descriptor the kernel now requires that a pts directory is found in the parent directory of the ptmx bind-mount. This implies that when doing bind-mounts the ptmx bind-mount and the devpts mount should have a common parent directory. A valid example is:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /dev/ptmx
an invalid example is:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /ptmx
This allows us to support:
- calling open on ptmx devices located inside non-standard devpts mounts:
mount -t devpts devpts /mnt
master = open("/mnt/ptmx", ...);
slave = ioctl(master, TIOCGPTPEER, ...);
- calling open on ptmx devices located outside the devpts mount with a common ancestor directory:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /dev/ptmx
master = open("/dev/ptmx", ...);
slave = ioctl(master, TIOCGPTPEER, ...);
while failing on ptmx devices located outside the devpts mount without a common ancestor directory:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /ptmx
master = open("/ptmx", ...);
slave = ioctl(master, TIOCGPTPEER, ...);
in which case save path generation cannot be guaranteed.
---
ChangeLog v4->v5:
* reverse error handling logic to further simplify (Linus) ChangeLog v3->v4:
* simplify if condition (Eric)
ChangeLog v2->v3:
* rework logic to account for non-standard devpts mounts such as mount -t devpts devpts /mnt (Christian)
ChangeLog v1->v2:
* move removal of if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC) condition to separate patch with non-functional changes (Linus)
ChangeLog v0->v1:
* remove
/* Has the devpts filesystem already been found? */
if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC)
return 0
from devpts_ptmx_path() (Eric)
* check superblock after devpts_ptmx_path() returned (Christian)
---
fs/devpts/inode.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)fs/devpts/inode.c +16 -10
@@ -160,21 +160,27 @@ struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi) path = filp->f_path;path_get (&path); -/* Has the devpts filesystem already been found? */ -if (path.mnt->mnt_sb->s_magic !=DEVPTS_SUPER_MAGIC ) +/* Walk upward while the start point is a bind mount of +* a single file. +*/ +while (path.mnt->mnt_root == path.dentry) +if (follow_up (&path) ==0 ) +break ; + +/* devpts_ptmx_path() finds a devpts fs or returns an error. */ +if ((path.mnt->mnt_sb->s_magic !=DEVPTS_SUPER_MAGIC ) || + (DEVPTS_SB (path.mnt->mnt_sb) != fsi)) err =devpts_ptmx_path (&path);dput (path.dentry); -if (err) { -mntput (path.mnt); -return ERR_PTR (err); - } +if (!err) { +if (DEVPTS_SB (path.mnt->mnt_sb) == fsi) +return path.mnt; -if (DEVPTS_SB (path.mnt->mnt_sb) != fsi) { -mntput (path.mnt); -return ERR_PTR (-ENODEV ); + err = -ENODEV ; } -return path.mnt; +mntput (path.mnt); +return ERR_PTR (err); }struct pts_fs_info *devpts_acquire (struct file *filp)
Signature · 1 line
2.15.1
A message that is not in the archive (sent off-list or not yet received): 20180313165527.24038-1-christian.brauner-GeWIH/[email protected]
PATCH RESEND v5 2/4 devpts: resolve devpts bind-mounts
Most libcs will still look at /dev/ptmx when opening the master fd of a pty device. When /dev/ptmx is a bind-mount of /dev/pts/ptmx and the TIOCGPTPEER ioctl() is used to safely retrieve a file descriptor for the slave side of the pty based on the master fd, the /proc/self/fd/{0,1,2} symlinks will point to /. A very simply reproducer for this issue presupposing a libc that uses TIOCGPTPEER in its openpty() implementation is:
unshare --mount
mount --bind /dev/pts/ptmx /dev/ptmx
chmod 666 /dev/ptmx
script
ls -al /proc/self/fd/0
Having bind-mounts of /dev/pts/ptmx to /dev/ptmx not working correctly is a regression. In addition, it is also a fairly common scenario in containers employing user namespaces.
The reason for the current failure is that the kernel tries to verify the useability of the devpts filesystem without resolving the /dev/ptmx bind-mount first. This will lead it to detect that the dentry is escaping its bind-mount. The reason is that while the devpts filesystem mounted at /dev/pts has the devtmpfs mounted at /dev as its parent mount:
21 -- -- / /dev
-- 21 -- / /dev/pts
devtmpfs and devpts are on different devices
-- -- 0:6 / /dev
-- -- 0:20 / /dev/pts
This has the consequence that the pathname of the parent directory of the devpts filesystem mount at /dev/pts is /. So if /dev/ptmx is a bind-mount of /dev/pts/ptmx then the /dev/ptmx bind-mount and the devpts mount at /dev/pts will end up being located on the same device which is recorded in the superblock of their vfsmount. This means the parent directory of the /dev/ptmx bind-mount will be /ptmx:
-- -- ---- /ptmx /dev/ptmx
Without the bind-mount resolution patch the kernel will now perform the bind-mount escape check directly on /dev/ptmx. The function responsible for this is devpts_ptmx_path() which calls pts_path() which in turn calls path_parent_directory(). Based on the above explanation, path_parent_directory() will yield / as the parent directory for the /dev/ptmx bind-mount and not the expected /dev. Thus, the kernel detects that /dev/ptmx is escaping its bind-mount and will set /proc/<pid>/fd/<nr> to /.
This patch changes the logic to first resolve any bind-mounts. After the bind-mounts have been resolved (i.e. we have traced it back to the associated devpts mount) devpts_ptmx_path() can be called. In order to guarantee correct path generation for the slave file descriptor the kernel now requires that a pts directory is found in the parent directory of the ptmx bind-mount. This implies that when doing bind-mounts the ptmx bind-mount and the devpts mount should have a common parent directory. A valid example is:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /dev/ptmx
an invalid example is:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /ptmx
This allows us to support:
- calling open on ptmx devices located inside non-standard devpts mounts:
mount -t devpts devpts /mnt
master = open("/mnt/ptmx", ...);
slave = ioctl(master, TIOCGPTPEER, ...);
- calling open on ptmx devices located outside the devpts mount with a common ancestor directory:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /dev/ptmx
master = open("/dev/ptmx", ...);
slave = ioctl(master, TIOCGPTPEER, ...);
while failing on ptmx devices located outside the devpts mount without a common ancestor directory:
mount -t devpts devpts /dev/pts
mount --bind /dev/pts/ptmx /ptmx
master = open("/ptmx", ...);
slave = ioctl(master, TIOCGPTPEER, ...);
in which case save path generation cannot be guaranteed.
---
ChangeLog v4->v5:
* reverse error handling logic to further simplify (Linus) ChangeLog v3->v4:
* simplify if condition (Eric)
ChangeLog v2->v3:
* rework logic to account for non-standard devpts mounts such as mount -t devpts devpts /mnt (Christian)
ChangeLog v1->v2:
* move removal of if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC) condition to separate patch with non-functional changes (Linus)
ChangeLog v0->v1:
* remove
/* Has the devpts filesystem already been found? */
if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC)
return 0
from devpts_ptmx_path() (Eric)
* check superblock after devpts_ptmx_path() returned (Christian)
---
fs/devpts/inode.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)fs/devpts/inode.c +16 -10
@@ -160,21 +160,27 @@ struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi) path = filp->f_path;path_get (&path); -/* Has the devpts filesystem already been found? */ -if (path.mnt->mnt_sb->s_magic !=DEVPTS_SUPER_MAGIC ) +/* Walk upward while the start point is a bind mount of +* a single file. +*/ +while (path.mnt->mnt_root == path.dentry) +if (follow_up (&path) ==0 ) +break ; + +/* devpts_ptmx_path() finds a devpts fs or returns an error. */ +if ((path.mnt->mnt_sb->s_magic !=DEVPTS_SUPER_MAGIC ) || + (DEVPTS_SB (path.mnt->mnt_sb) != fsi)) err =devpts_ptmx_path (&path);dput (path.dentry); -if (err) { -mntput (path.mnt); -return ERR_PTR (err); - } +if (!err) { +if (DEVPTS_SB (path.mnt->mnt_sb) == fsi) +return path.mnt; -if (DEVPTS_SB (path.mnt->mnt_sb) != fsi) { -mntput (path.mnt); -return ERR_PTR (-ENODEV ); + err = -ENODEV ; } -return path.mnt; +mntput (path.mnt); +return ERR_PTR (err); }struct pts_fs_info *devpts_acquire (struct file *filp)
Signature · 1 line
2.15.1
PATCH RESEND v5 3/4 devpts: comment devpts_mntget()
In reply to a message not in the archive---
ChangeLog v4->v5:
* patch added
ChangeLog v3->v4:
* patch not present
ChangeLog v2->v3:
* patch not present
ChangeLog v1->v2:
* patch not present
ChangeLog v0->v1:
* patch not present
--- fs/devpts/inode.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fs/devpts/inode.c +18 -0
@@ -152,6 +152,24 @@ static int devpts_ptmx_path(struct path *path)return 0 ; } +/* +* Try to find a suitable devpts filesystem. We support the following +* scenarios: +* - The ptmx device node is located in the same directory as the devpts +* mount where the pts device nodes are located. +* This is e.g. the case when calling open on the /dev/pts/ptmx device +* node when the devpts filesystem is mounted at /dev/pts. +* - The ptmx device node is located outside the devpts filesystem mount +* where the pts device nodes are located. For example, the ptmx device +* is a symlink, separate device node, or bind-mount. +* A supported scenario is bind-mounting /dev/pts/ptmx to /dev/ptmx and +* then calling open on /dev/ptmx. In this case a suitable pts +* subdirectory can be found in the common parent directory /dev of the +* devpts mount and the ptmx bind-mount, after resolving the /dev/ptmx +* bind-mount. +* If no suitable pts subdirectory can be found this function will fail. +* This is e.g. the case when bind-mounting /dev/pts/ptmx to /ptmx. +*/ struct vfsmount *devpts_mntget (struct file *filp,struct pts_fs_info *fsi) {struct path path;
Signature · 1 line
2.15.1
PATCH RESEND v5 4/4 selftests: add devpts selftests
In reply to a message not in the archiveThis adds tests to check:
- bind-mounts from /dev/pts/ptmx to /dev/ptmx work
- non-standard mounts of devpts work
- bind-mounts of /dev/pts/ptmx to locations that do not resolve to a valid slave pty path under the originating devpts mount fail
---
ChangeLog v4->v5:
* extend tests to verify failure on ptmx devices located outside the devpts mount without a common ancestor directory
ChangeLog v3->v4:
* patch unchanged
ChangeLog v2->v3:
* extend test for non-standard devpts mounts such as mount -t devpts e devpts /mnt
ChangeLog v1->v2:
* patch added
ChangeLog v0->v1:
* patch not present
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/filesystems/.gitignore | 1 + tools/testing/selftests/filesystems/Makefile | 2 +- tools/testing/selftests/filesystems/devpts_pts.c | 313 +++++++++++++++++++++++ 4 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/filesystems/devpts_pts.c
tools/testing/selftests/Makefile +1 -0
@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems TARGETS += firmware TARGETS += ftrace TARGETS += futex
tools/testing/selftests/filesystems/.gitignore +1 -0
@@ -1 +1,2 @@ dnotify_test +devpts_pts
tools/testing/selftests/filesystems/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts all: $(TEST_PROGS) include ../lib.mk
tools/testing/selftests/filesystems/devpts_pts.c new file +313 -0
313 lines not on this page · raw message
Signature · 1 line
2.15.1
Quoted 3 lines · Christian Brauner
This is the fith iteration of this patch. Per-patch changes are summarized in the individual patches:
I don't see anything I react to any more. So Ack from me.
Linus
PATCH RESEND v5 3/4 devpts: comment devpts_mntget()
In reply to Christian Brauner---
ChangeLog v4->v5:
* patch added
ChangeLog v3->v4:
* patch not present
ChangeLog v2->v3:
* patch not present
ChangeLog v1->v2:
* patch not present
ChangeLog v0->v1:
* patch not present
--- fs/devpts/inode.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fs/devpts/inode.c +18 -0
@@ -152,6 +152,24 @@ static int devpts_ptmx_path(struct path *path)return 0 ; } +/* +* Try to find a suitable devpts filesystem. We support the following +* scenarios: +* - The ptmx device node is located in the same directory as the devpts +* mount where the pts device nodes are located. +* This is e.g. the case when calling open on the /dev/pts/ptmx device +* node when the devpts filesystem is mounted at /dev/pts. +* - The ptmx device node is located outside the devpts filesystem mount +* where the pts device nodes are located. For example, the ptmx device +* is a symlink, separate device node, or bind-mount. +* A supported scenario is bind-mounting /dev/pts/ptmx to /dev/ptmx and +* then calling open on /dev/ptmx. In this case a suitable pts +* subdirectory can be found in the common parent directory /dev of the +* devpts mount and the ptmx bind-mount, after resolving the /dev/ptmx +* bind-mount. +* If no suitable pts subdirectory can be found this function will fail. +* This is e.g. the case when bind-mounting /dev/pts/ptmx to /ptmx. +*/ struct vfsmount *devpts_mntget (struct file *filp,struct pts_fs_info *fsi) {struct path path;
Signature · 1 line
2.15.1
PATCH RESEND v5 4/4 selftests: add devpts selftests
In reply to Christian BraunerThis adds tests to check:
- bind-mounts from /dev/pts/ptmx to /dev/ptmx work
- non-standard mounts of devpts work
- bind-mounts of /dev/pts/ptmx to locations that do not resolve to a valid slave pty path under the originating devpts mount fail
---
ChangeLog v4->v5:
* extend tests to verify failure on ptmx devices located outside the devpts mount without a common ancestor directory
ChangeLog v3->v4:
* patch unchanged
ChangeLog v2->v3:
* extend test for non-standard devpts mounts such as mount -t devpts e devpts /mnt
ChangeLog v1->v2:
* patch added
ChangeLog v0->v1:
* patch not present
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/filesystems/.gitignore | 1 + tools/testing/selftests/filesystems/Makefile | 2 +- tools/testing/selftests/filesystems/devpts_pts.c | 313 +++++++++++++++++++++++ 4 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/filesystems/devpts_pts.c
tools/testing/selftests/Makefile +1 -0
@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems TARGETS += firmware TARGETS += ftrace TARGETS += futex
tools/testing/selftests/filesystems/.gitignore +1 -0
@@ -1 +1,2 @@ dnotify_test +devpts_pts
tools/testing/selftests/filesystems/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts all: $(TEST_PROGS) include ../lib.mk
tools/testing/selftests/filesystems/devpts_pts.c new file +313 -0
313 lines not on this page · raw message
Signature · 1 line
2.15.1
Re: [PATCH 4/4 v5 RESEND] selftests: add devpts selftests
Hi Christian,
tools/testing/selftests/Makefile TARGETS += cpufreq · line 10
Quoted 9 lines · Christian Brauner
tools/testing/selftests/Makefile +1
-0@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems
^ This, and ...
tools/testing/selftests/filesystems/Makefile line 2
Quoted 8 lines
tools/testing/selftests/filesystems/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts
^
this ...Have the unfortunate effect of running dnotify_test as part of the default selftest run.
dnotify_test boils down to:
while (1) {
pause();
printf("Got event on fd=%d\n", event_fd);
}ie. an infinite loop :)
I'll send a patch to fix it.
cheers
Re: [PATCH 4/4 v5 RESEND] selftests: add devpts selftests
Quoted 30 lines · Michael Ellerman
Hi Christian,
tools/testing/selftests/Makefile TARGETS += cpufreq · line 10
Quoted 9 lines · Christian Brauner
tools/testing/selftests/Makefile +1
-0@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems^ This, and ...
tools/testing/selftests/filesystems/Makefile line 2
Quoted 8 lines
tools/testing/selftests/filesystems/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts^ this ...Have the unfortunate effect of running
dnotify_testas part of the default selftest run.
dnotify_testboils down to:
Quoted 7 lines
while (1) { pause(); printf("Got event on fd=%d\n", event_fd); }ie. an infinite loop :)
Hi Michael,
Ugh, didn't notice this before. Weird test.
Quoted 2 lines
I'll send a patch to fix it.
Excellent, you can likely route it through Greg's tty tree.
Thanks!
Christian
Re: [PATCH 4/4 v5 RESEND] selftests: add devpts selftests
Quoted 35 lines · Christian Brauner
Quoted 34 lines · Michael Ellerman
tools/testing/selftests/Makefile TARGETS += cpufreq · line 10
Quoted 9 lines · Christian Brauner
tools/testing/selftests/Makefile +1
-0@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems^ This, and ...
tools/testing/selftests/filesystems/Makefile line 2
Quoted 8 lines
tools/testing/selftests/filesystems/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts^ this ...Have the unfortunate effect of running
dnotify_testas part of the default selftest run.
dnotify_testboils down to:while (1) { pause(); printf("Got event on fd=%d\n", event_fd); }
Quoted 5 lines
Quoted 1 line
ie. an infinite loop :)
Hi Michael,
Ugh, didn't notice this before. Weird test.
No worries. It looks like it was copied from Documentation where it was really just sample code, rather than a test.
Quoted 3 lines
Quoted 1 line
I'll send a patch to fix it.
Excellent, you can likely route it through Greg's tty tree.
I've sent it to the kselftest list as well as Greg, so whoever wants to merge it is fine by me.
cheers
Re: [PATCH 4/4 v5 RESEND] selftests: add devpts selftests
Quoted 45 lines · Michael Ellerman
Quoted 35 lines · Christian Brauner
Quoted 34 lines · Michael Ellerman
tools/testing/selftests/Makefile TARGETS += cpufreq · line 10
Quoted 9 lines · Christian Brauner
tools/testing/selftests/Makefile +1
-0@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems^ This, and ...
tools/testing/selftests/filesystems/Makefile line 2
Quoted 8 lines
tools/testing/selftests/filesystems/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts^ this ...Have the unfortunate effect of running
dnotify_testas part of the default selftest run.
dnotify_testboils down to:while (1) { pause(); printf("Got event on fd=%d\n", event_fd); }Quoted 5 lines
Quoted 1 line
ie. an infinite loop :)
Hi Michael,
Ugh, didn't notice this before. Weird test.
No worries. It looks like it was copied from Documentation where it was really just sample code, rather than a test.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I'll send a patch to fix it.
Excellent, you can likely route it through Greg's tty tree.
I've sent it to the kselftest list as well as Greg, so whoever wants to merge it is fine by me.
Perfect, thanks!
Christian
A message that is not in the archive (sent off-list or not yet received): 20180410084208.GA14520-cl+VPiYnx/[email protected]
Re: [PATCH 4/4 v5 RESEND] selftests: add devpts selftests
Quoted 35 lines · Christian Brauner
Quoted 34 lines · Michael Ellerman
tools/testing/selftests/Makefile TARGETS += cpufreq · line 10
Quoted 9 lines · Christian Brauner
tools/testing/selftests/Makefile +1
-0@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems^ This, and ...
tools/testing/selftests/filesystems/Makefile line 2
Quoted 8 lines
tools/testing/selftests/filesystems/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts^ this ...Have the unfortunate effect of running
dnotify_testas part of the default selftest run.
dnotify_testboils down to:while (1) { pause(); printf("Got event on fd=%d\n", event_fd); }
Quoted 5 lines
Quoted 1 line
ie. an infinite loop :)
Hi Michael,
Ugh, didn't notice this before. Weird test.
No worries. It looks like it was copied from Documentation where it was really just sample code, rather than a test.
Quoted 3 lines
Quoted 1 line
I'll send a patch to fix it.
Excellent, you can likely route it through Greg's tty tree.
I've sent it to the kselftest list as well as Greg, so whoever wants to merge it is fine by me.
cheers
A message that is not in the archive (sent off-list or not yet received): 87efjnbn0j.fsf-W0DJWXSxmBNbyGPkN3NxC2scP1bn1w/[email protected]
Re: [PATCH 4/4 v5 RESEND] selftests: add devpts selftests
Quoted 30 lines · Michael Ellerman
Hi Christian,
tools/testing/selftests/Makefile TARGETS += cpufreq · line 10
Quoted 9 lines · Christian Brauner
tools/testing/selftests/Makefile +1
-0@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems^ This, and ...
tools/testing/selftests/filesystems/Makefile line 2
Quoted 8 lines
tools/testing/selftests/filesystems/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts^ this ...Have the unfortunate effect of running
dnotify_testas part of the default selftest run.
dnotify_testboils down to:
Quoted 7 lines
while (1) { pause(); printf("Got event on fd=%d\n", event_fd); }ie. an infinite loop :)
Hi Michael,
Ugh, didn't notice this before. Weird test.
Quoted 2 lines
I'll send a patch to fix it.
Excellent, you can likely route it through Greg's tty tree.
Thanks!
Christian
A message that is not in the archive (sent off-list or not yet received): 20180313165527.24038-5-christian.brauner-GeWIH/[email protected]
Re: [PATCH 4/4 v5 RESEND] selftests: add devpts selftests
Hi Christian,
tools/testing/selftests/Makefile TARGETS += cpufreq · line 10
Quoted 9 lines · Christian Brauner
tools/testing/selftests/Makefile +1
-0@@ -7,6 +7,7 @@ TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += efivarfs TARGETS += exec +TARGETS += filesystems
^ This, and ...
tools/testing/selftests/filesystems/Makefile line 2
Quoted 8 lines
tools/testing/selftests/filesystems/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := dnotify_test +TEST_PROGS := dnotify_test devpts_pts
^
this ...Have the unfortunate effect of running dnotify_test as part of the default selftest run.
dnotify_test boils down to:
while (1) {
pause();
printf("Got event on fd=%d\n", event_fd);
}ie. an infinite loop :)
I'll send a patch to fix it.
cheers
Quoted 1 line · Christian Brauner
Resending to CC grekh.
And the first two patches can also have
Greg this patchset looks read or just about ready to be merged. Do you want to take this through your tty tree or should I take it through my tree.
Eric
Quoted 50 lines
Hey everyone,
This is the fith iteration of this patch. Per-patch changes are summarized in the individual patches:
ChangeLog
v4->v5:
* added non-functional patch to documentdevpts_mntget(). Reason for putting this in a separate patch is that it allows you, Linus and Eric, to simply drop it if judged useless.
* reverse error handling logic to further simplify
*dput()dentry in the non-function patch. This was not really a problem since the following patch included a fix for it. But better to get it right in all individual patches.
* I did another rewrite of the problem analysis for posterity in the patch "Subject: [PATCH 2/3 v3] devpts: resolve devpts bind-mounts" and in this cover letter.ChangeLog
v3->v4:
* small logical simplifications
* add test that bind-mounts of/dev/pts/ptmxto locations that do not resolve to a valid slave pty path under the originating devpts mount failChangeLog
v2->v3:
* rewritten commit message to thoroughly analyse the problem for posterity in the patch "Subject: [PATCH 2/3 v3] devpts: resolve devpts bind-mounts" and in this cover letter.
* extended selftests to test for correct handling of/dev/pts/ptmxbind-mounts to/dev/ptmxand non-standard devpts mounts such as mount -t devpts devpts /mntChangeLog
v1->v2:
* see individual patches
ChangeLogv0->v1:
* see individual patchesChristian Brauner (4):
devpts: hoist out check forDEVPTS_SUPER_MAGIC
devpts: resolve devpts bind-mounts
devpts: commentdevpts_mntget()
selftests: add devpts selftestsfs/devpts/inode.c | 66 +++-- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/filesystems/.gitignore | 1 + tools/testing/selftests/filesystems/Makefile | 2 +- tools/testing/selftests/filesystems/devpts_pts.c | 313 +++++++++++++++++++++++ 5 files changed, 363 insertions(+), 20 deletions(-) create mode 100644 tools/testing/selftests/filesystems/devpts_pts.c
Quoted 6 lines · Eric W. Biederman
Quoted 1 line · Christian Brauner
Resending to CC grekh.
Quoted 8 lines
And the first two patches can also have
Greg this patchset looks read or just about ready to be merged. Do you want to take this through your tty tree or should I take it through my tree.
I can take it through my tree. I'll go through the pending tty/serial patches tomorrow and pick these up.
thanks,
greg k-h
Quoted 3 lines · Christian Brauner
This is the fith iteration of this patch. Per-patch changes are summarized in the individual patches:
I don't see anything I react to any more. So Ack from me.
Linus