BUG in tty_open when using containers and ptrace

Sukadev Bhattiprolu sukadev at linux.vnet.ibm.com
Fri Aug 7 12:08:02 PDT 2009


Grzegorz Nosek [root at localdomain.pl] wrote:
| Hi,
| 
| Dnia 2009-07-30, czw o godzinie 11:06 -0700, Sukadev Bhattiprolu pisze:
| > Well, I made some progress on this. In an earlier mail you mentioned
| > that your test case "survives" in kernels without the bad commit.
| > 
| > With the following patch the kernel seems to _survive_ but not sure if
| > "surviving" meets your real needs (i.e does the pty continue to function
| > as the console for the container) ? 
| 
| Both my patch and yours make the console open fail and I'm not sure we
| can do much better. I don't think this matters (too much) either as the
| supervisor (libvirt_lxc) exits only on container shutdown, so there's
| nothing much we can do to the container anyway.

Ok.  Hope you had some luck with the console and libvirtd.

FWIW, should we push this patch upstream ? It would at least prevent
the kernel crash and be consistent with the behavior before newptsinstance
changes ?

Peter, what do you think about this patch ?

---
Index: linux-2.6.30/fs/devpts/inode.c
===================================================================
--- linux-2.6.30.orig/fs/devpts/inode.c 2009-07-30 10:48:17.000000000 -0400
+++ linux-2.6.30/fs/devpts/inode.c      2009-08-04 11:43:51.000000000 -0400
@@ -519,11 +519,22 @@

 struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number)
 {
+       struct dentry *dentry;
+       struct tty_struct *tty;
+
        BUG_ON(pts_inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR));

+       dentry = d_find_alias(pts_inode);
+       if (!dentry)
+               return NULL;
+
+       tty = NULL;
        if (pts_inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC)
-               return (struct tty_struct *)pts_inode->i_private;
-       return NULL;
+               tty = (struct tty_struct *)pts_inode->i_private;
+
+       dput(dentry);
+
+       return tty;
 }

 void devpts_pty_kill(struct tty_struct *tty)


More information about the Containers mailing list