summaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-08-23 21:16:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-08-23 21:16:11 -0400
commit143c97cc652949893c8056c679012f0aeccb80e5 (patch)
tree987e3a7fd939ae8169f7ddfc4d0b145a666536fa /drivers/tty/pty.c
parent2acf097f16abba684012cca670a61d94178bd1ab (diff)
Revert "pty: fix the cached path of the pty slave file descriptor in the master"
This reverts commit c8c03f1858331e85d397bacccd34ef409aae993c. It turns out that while fixing the ptmx file descriptor to have the correct 'struct path' to the associated slave pty is a really good thing, it breaks some user space tools for a very annoying reason. The problem is that /dev/ptmx and its associated slave pty (/dev/pts/X) are on different mounts. That was what caused us to have the wrong path in the first place (we would mix up the vfsmount of the 'ptmx' node, with the dentry of the pty slave node), but it also means that now while we use the right vfsmount, having the pty master open also keeps the pts mount busy. And it turn sout that that makes 'pbuilder' very unhappy, as noted by Stefan Lippers-Hollmann: "This patch introduces a regression for me when using pbuilder 0.228.7[2] (a helper to build Debian packages in a chroot and to create and update its chroots) when trying to umount /dev/ptmx (inside the chroot) on Debian/ unstable (full log and pbuilder configuration file[3] attached). [...] Setting up build-essential (12.3) ... Processing triggers for libc-bin (2.24-15) ... I: unmounting dev/ptmx filesystem W: Could not unmount dev/ptmx: umount: /var/cache/pbuilder/build/1340/dev/ptmx: target is busy (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1).)" apparently pbuilder tries to unmount the /dev/pts filesystem while still holding at least one master node open, which is arguably not very nice, but we don't break user space even when fixing other bugs. So this commit has to be reverted. I'll try to figure out a way to avoid caching the path to the slave pty in the master pty. The only thing that actually wants that slave pty path is the "TIOCGPTPEER" ioctl, and I think we could just recreate the path at that time. Reported-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> Cc: Eric W Biederman <ebiederm@xmission.com> Cc: Christian Brauner <christian.brauner@canonical.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 1fc80ea87c13..284749fb0f6b 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -793,7 +793,6 @@ static int ptmx_open(struct inode *inode, struct file *filp)
793 struct tty_struct *tty; 793 struct tty_struct *tty;
794 struct path *pts_path; 794 struct path *pts_path;
795 struct dentry *dentry; 795 struct dentry *dentry;
796 struct vfsmount *mnt;
797 int retval; 796 int retval;
798 int index; 797 int index;
799 798
@@ -806,7 +805,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
806 if (retval) 805 if (retval)
807 return retval; 806 return retval;
808 807
809 fsi = devpts_acquire(filp, &mnt); 808 fsi = devpts_acquire(filp);
810 if (IS_ERR(fsi)) { 809 if (IS_ERR(fsi)) {
811 retval = PTR_ERR(fsi); 810 retval = PTR_ERR(fsi);
812 goto out_free_file; 811 goto out_free_file;
@@ -850,7 +849,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
850 pts_path = kmalloc(sizeof(struct path), GFP_KERNEL); 849 pts_path = kmalloc(sizeof(struct path), GFP_KERNEL);
851 if (!pts_path) 850 if (!pts_path)
852 goto err_release; 851 goto err_release;
853 pts_path->mnt = mnt; 852 pts_path->mnt = filp->f_path.mnt;
854 pts_path->dentry = dentry; 853 pts_path->dentry = dentry;
855 path_get(pts_path); 854 path_get(pts_path);
856 tty->link->driver_data = pts_path; 855 tty->link->driver_data = pts_path;
@@ -867,7 +866,6 @@ err_path_put:
867 path_put(pts_path); 866 path_put(pts_path);
868 kfree(pts_path); 867 kfree(pts_path);
869err_release: 868err_release:
870 mntput(mnt);
871 tty_unlock(tty); 869 tty_unlock(tty);
872 // This will also put-ref the fsi 870 // This will also put-ref the fsi
873 tty_release(inode, filp); 871 tty_release(inode, filp);
@@ -876,7 +874,6 @@ out:
876 devpts_kill_index(fsi, index); 874 devpts_kill_index(fsi, index);
877out_put_fsi: 875out_put_fsi:
878 devpts_release(fsi); 876 devpts_release(fsi);
879 mntput(mnt);
880out_free_file: 877out_free_file:
881 tty_free_file(filp); 878 tty_free_file(filp);
882 return retval; 879 return retval;