From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH 3/4] devpts: Make the newinstance option historical Date: Sun, 23 Sep 2012 05:46:03 +0100 Message-ID: <20120923044603.GN13973@ZenIV.linux.org.uk> References: <20120124010758.GJ23916@ZenIV.linux.org.uk> <20120124220247.GA26353@hallyn.com> <20120124231601.GA4470@sergelap> <20120128195103.GA11299@sergelap> <87txup763i.fsf_-_@xmission.com> <87d31d75yj.fsf_-_@xmission.com> <20120923041906.GM13973@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20120923041906.GM13973-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: "Eric W. Biederman" Cc: Greg Kroah-Hartman , containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Kay Sievers , Dave Hansen , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andy Whitcroft , sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org, Linus Torvalds , Alan Cox List-Id: containers.vger.kernel.org On Sun, Sep 23, 2012 at 05:19:06AM +0100, Al Viro wrote: > On Sat, Sep 22, 2012 at 08:50:44PM -0700, Eric W. Biederman wrote: > > > +struct inode *devpts_redirect(struct file *filp) > > +{ > > + struct inode *inode; > > + struct file *filp2; > > + > > + /* Is the inode already a devpts inode? */ > > + inode = filp->f_dentry->d_inode; > > + if (filp->f_dentry->d_sb->s_magic == DEVPTS_SUPER_MAGIC) > > + goto out; > > + > > + /* Is f_dentry->d_parent usable? */ > > + inode = ERR_PTR(-ENODEV); > > + if (filp->f_vfsmnt->mnt_root == filp->f_dentry) > > + goto out; > > + > > + /* Is there a devpts inode we can use instead? */ > > + > > + filp2 = file_open_root(filp->f_dentry->d_parent, filp->f_vfsmnt, > > + "pts/ptmx", O_PATH); > > + if (!IS_ERR(filp2)) { > > + if (filp2->f_dentry->d_sb->s_magic == DEVPTS_SUPER_MAGIC) { > > + struct path old; > > + old = filp->f_path; > > + filp->f_path = filp2->f_path; > > + inode = filp->f_dentry->d_inode; > > + path_get(&filp->f_path); > > + path_put(&old); > > You are welcome to supply an analysis of the reasons why ->open() pulling > such tricks will not break all kinds of code in VFS. > > + } > > + fput(filp2); > > ... starting with "what happens when some joker binds /dev/ptmx on > /dev/pts/ptmx" Or does mknod /tmp/ptmx c 5 2; mkdir /tmp/pts; ln /tmp/ptmx /tmp/pts/ptmx, for that matter... From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753604Ab2IWEqO (ORCPT ); Sun, 23 Sep 2012 00:46:14 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:42676 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751740Ab2IWEqN (ORCPT ); Sun, 23 Sep 2012 00:46:13 -0400 Date: Sun, 23 Sep 2012 05:46:03 +0100 From: Al Viro To: "Eric W. Biederman" Cc: Greg Kroah-Hartman , Kay Sievers , "Serge E. Hallyn" , containers@lists.linux-foundation.org, Dave Hansen , linux-kernel@vger.kernel.org, Andy Whitcroft , sukadev@linux.vnet.ibm.com, Linus Torvalds , Alan Cox , Serge Hallyn Subject: Re: [PATCH 3/4] devpts: Make the newinstance option historical Message-ID: <20120923044603.GN13973@ZenIV.linux.org.uk> References: <20120124010758.GJ23916@ZenIV.linux.org.uk> <20120124220247.GA26353@hallyn.com> <20120124231601.GA4470@sergelap> <20120128195103.GA11299@sergelap> <87txup763i.fsf_-_@xmission.com> <87d31d75yj.fsf_-_@xmission.com> <20120923041906.GM13973@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120923041906.GM13973@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 23, 2012 at 05:19:06AM +0100, Al Viro wrote: > On Sat, Sep 22, 2012 at 08:50:44PM -0700, Eric W. Biederman wrote: > > > +struct inode *devpts_redirect(struct file *filp) > > +{ > > + struct inode *inode; > > + struct file *filp2; > > + > > + /* Is the inode already a devpts inode? */ > > + inode = filp->f_dentry->d_inode; > > + if (filp->f_dentry->d_sb->s_magic == DEVPTS_SUPER_MAGIC) > > + goto out; > > + > > + /* Is f_dentry->d_parent usable? */ > > + inode = ERR_PTR(-ENODEV); > > + if (filp->f_vfsmnt->mnt_root == filp->f_dentry) > > + goto out; > > + > > + /* Is there a devpts inode we can use instead? */ > > + > > + filp2 = file_open_root(filp->f_dentry->d_parent, filp->f_vfsmnt, > > + "pts/ptmx", O_PATH); > > + if (!IS_ERR(filp2)) { > > + if (filp2->f_dentry->d_sb->s_magic == DEVPTS_SUPER_MAGIC) { > > + struct path old; > > + old = filp->f_path; > > + filp->f_path = filp2->f_path; > > + inode = filp->f_dentry->d_inode; > > + path_get(&filp->f_path); > > + path_put(&old); > > You are welcome to supply an analysis of the reasons why ->open() pulling > such tricks will not break all kinds of code in VFS. > > + } > > + fput(filp2); > > ... starting with "what happens when some joker binds /dev/ptmx on > /dev/pts/ptmx" Or does mknod /tmp/ptmx c 5 2; mkdir /tmp/pts; ln /tmp/ptmx /tmp/pts/ptmx, for that matter...