Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752563AbdHPWrM (ORCPT ); Wed, 16 Aug 2017 18:47:12 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:50941 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752450AbdHPWrB (ORCPT ); Wed, 16 Aug 2017 18:47:01 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Linus Torvalds Cc: Christian Brauner , Christian Brauner , Linux Kernel Mailing List , "Serge E. Hallyn" , Al Viro References: <20170816171211.4021-1-christian.brauner@ubuntu.com> <20170816194805.hnof3aqiqykwki7p@gmail.com> Date: Wed, 16 Aug 2017 17:46:46 -0500 In-Reply-To: (Linus Torvalds's message of "Wed, 16 Aug 2017 14:03:14 -0700") Message-ID: <87pobvruzt.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1di75S-0007oy-1S;;;mid=<87pobvruzt.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.200.44;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18DxgHdiKiNIq62m/7kuQu1i353jE8p5rw= X-SA-Exim-Connect-IP: 67.3.200.44 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 2.5 XMGppyBdWords BODY: Gappy or l33t words * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_03 6+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 5305 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 2.6 (0.0%), b_tie_ro: 1.85 (0.0%), parse: 0.77 (0.0%), extract_message_metadata: 15 (0.3%), get_uri_detail_list: 2.3 (0.0%), tests_pri_-1000: 7 (0.1%), tests_pri_-950: 1.23 (0.0%), tests_pri_-900: 1.00 (0.0%), tests_pri_-400: 25 (0.5%), check_bayes: 24 (0.5%), b_tokenize: 7 (0.1%), b_tok_get_all: 7 (0.1%), b_comp_prob: 1.97 (0.0%), b_tok_touch_all: 4.9 (0.1%), b_finish: 2.0 (0.0%), tests_pri_0: 1229 (23.2%), check_dkim_signature: 0.47 (0.0%), check_dkim_adsp: 6 (0.1%), tests_pri_500: 4021 (75.8%), poll_dns_idle: 4013 (75.7%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 0/1] devpts: use dynamic_dname() to generate proc name X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2323 Lines: 75 Linus Torvalds writes: > On Wed, Aug 16, 2017 at 1:30 PM, Linus Torvalds > wrote: >> >> I suspect the easiest fix is to just add a "mnt" argument to >> devpts_acquire(), It shouldn't be too painful. Let me try. > > Ok, here's a *very* lightly tested patch. It might have new bugs, but > it makes your test program DTRT. > > Al, mind going over this and making sure I didn't miss anything? > > And Christian, if you can beat on this, that would be good. Linus reading through this it looks like your error handling is wrong. > diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c > index 284749fb0f6b..432f514e3f42 100644 > --- a/drivers/tty/pty.c > +++ b/drivers/tty/pty.c > @@ -793,6 +793,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) > struct tty_struct *tty; > struct path *pts_path; > struct dentry *dentry; > + struct vfsmount *mnt; > int retval; > int index; > > @@ -805,7 +806,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) > if (retval) > return retval; > > - fsi = devpts_acquire(filp); > + fsi = devpts_acquire(filp, &mnt); > if (IS_ERR(fsi)) { > retval = PTR_ERR(fsi); > goto out_free_file; > @@ -849,9 +850,14 @@ static int ptmx_open(struct inode *inode, struct file *filp) > pts_path = kmalloc(sizeof(struct path), GFP_KERNEL); > if (!pts_path) > goto err_release; > - pts_path->mnt = filp->f_path.mnt; > - pts_path->dentry = dentry; > - path_get(pts_path); > + > + /* > + * The mnt already got a ref from devpts_acquire(), > + * so we only dget() on the dentry. > + */ > + pts_path->mnt = mnt; > + pts_path->dentry = dget(dentry); > + > tty->link->driver_data = pts_path; > > retval = ptm_driver->ops->open(tty, filp); ^^^^^^^ If this open fails the code jumps to err_put_path which falls through into out_put_fsi. But it also does path_put(pts_path). Which will result in a double mntput of mnt. So I think err_path_put needs to be updated to just put the dentry, and let the later mntput put the mount. > @@ -874,6 +880,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) > devpts_kill_index(fsi, index); > out_put_fsi: > devpts_release(fsi); > + mntput(mnt); > out_free_file: > tty_free_file(filp); > return retval; Eric