Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751624AbdHQBhz (ORCPT ); Wed, 16 Aug 2017 21:37:55 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:48380 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751509AbdHQBhy (ORCPT ); Wed, 16 Aug 2017 21:37:54 -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 20:37:38 -0500 In-Reply-To: (Linus Torvalds's message of "Wed, 16 Aug 2017 13:19:01 -0700") Message-ID: <87y3qjoty5.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=1di9ko-00075i-EC;;;mid=<87y3qjoty5.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=67.3.200.44;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+VaRyxKYMHjwKu75ojh+l4x5J5PkLUHrs= 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.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 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; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 5311 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 3.8 (0.1%), b_tie_ro: 2.6 (0.0%), parse: 1.46 (0.0%), extract_message_metadata: 19 (0.4%), get_uri_detail_list: 3.0 (0.1%), tests_pri_-1000: 10 (0.2%), tests_pri_-950: 1.80 (0.0%), tests_pri_-900: 1.42 (0.0%), tests_pri_-400: 28 (0.5%), check_bayes: 26 (0.5%), b_tokenize: 10 (0.2%), b_tok_get_all: 8 (0.1%), b_comp_prob: 3.2 (0.1%), b_tok_touch_all: 2.9 (0.1%), b_finish: 0.75 (0.0%), tests_pri_0: 300 (5.6%), check_dkim_signature: 0.62 (0.0%), check_dkim_adsp: 3.9 (0.1%), tests_pri_500: 4941 (93.0%), poll_dns_idle: 4936 (92.9%), 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2589 Lines: 62 Linus Torvalds writes: > On Wed, Aug 16, 2017 at 12:56 PM, Linus Torvalds > wrote: >> >> So the fact that we _don't_ get the right pathname for the pts entry >> here means that something got screwed up in setting filp->f_path to >> the right thing. We have all the code in place that _tries_ to do it, >> but it clearly has a bug somewhere. > > Ok, I think I see what the bug is, although I don't have a fix for it yet. > > We generate the path largely correctly: the path has a nice dentry > that contains the right pts number, and has the right parent pointer > that points to the root of the pts mount. > > And we also fill in the path 'mnt' field. Everything should be fine. > > Except when we actually hit that root dentry of the pts mount, the > code in prepend_path() hits this condition: > > if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { > struct mount *parent = ACCESS_ONCE(mnt->mnt_parent); > /* Escaped? */ > if (dentry != vfsmnt->mnt_root) { > > and we break out, and reset the path to '/' because we think it > somehow escaped out of the user namespace. Escaped it's bind mount actually. There should always be a path from mnt_root to a dentry under that mount point. In some rare caseses involving bind mounts a rename that moves a dentry from one directory to another can result in dentries that are not reachable from mnt_root. As those entries do not have a path in a meaningful sense setting the path to '/' is the best we can do. This condition should be limited to bind mounts as any dentry on a filesystem is descendent from the filesystems root directory. The rest of your analysis below is correct. My apologies for the pendantic reply. I am repling just so that someone doesn't find this in an email archive 20 years from now and become impossibly confused. > So it looks like we filled in the path with the *wrong* mount information. > > And THAT in turn is because we fill the path with the mount > information for the "/dev/ptmx" field - which is *not* in the > /dev/pts/ mount - that's the mount for '/dev'. > > So we have a dentry and a mnt, but they simply aren't paired up correctly. > > And you can see this with your test program: if you open /dev/pts/ptmx > for the master, it actually works correctly (but you need to make sure > the permissions for that ptmx node allow that). > > Anyway, I know what's wrong, next step is to figure out what the fix is. > > Linus