Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754238AbcDTEcJ (ORCPT ); Wed, 20 Apr 2016 00:32:09 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:53173 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626AbcDTEcG (ORCPT ); Wed, 20 Apr 2016 00:32:06 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Al Viro Cc: Linus Torvalds , "H. Peter Anvin" , Andy Lutomirski , security@debian.org, "security\@kernel.org" , "security\@ubuntu.com \>\> security" , Peter Hurley , Serge Hallyn , Willy Tarreau , Aurelien Jarno , One Thousand Gnomes , Jann Horn , Greg KH , Linux Kernel Mailing List , Jiri Slaby , Florian Weimer References: <570D4781.3070600@zytor.com> <877ffyzy1j.fsf_-_@x220.int.ebiederm.org> <87twixgsnq.fsf@x220.int.ebiederm.org> <87oa95gevf.fsf_-_@x220.int.ebiederm.org> <20160420032541.GE25498@ZenIV.linux.org.uk> <87k2jtc5dk.fsf@x220.int.ebiederm.org> <20160420041113.GF25498@ZenIV.linux.org.uk> Date: Tue, 19 Apr 2016 23:21:11 -0500 In-Reply-To: <20160420041113.GF25498@ZenIV.linux.org.uk> (Al Viro's message of "Wed, 20 Apr 2016 05:11:13 +0100") Message-ID: <8760vcc3m0.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX19dicwGai1TqFdQCOVzz6Jnss7fHemvStI= X-SA-Exim-Connect-IP: 97.119.105.151 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 * 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 * [sa01 1397; Body=1 Fuz1=1 Fuz2=1] * 1.0 T_XMDrugObfuBody_04 obfuscated drug references X-Spam-DCC: XMission; sa01 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Al Viro X-Spam-Relay-Country: X-Spam-Timing: total 4698 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.1 (0.1%), b_tie_ro: 2.9 (0.1%), parse: 1.37 (0.0%), extract_message_metadata: 31 (0.6%), get_uri_detail_list: 3.1 (0.1%), tests_pri_-1000: 12 (0.3%), tests_pri_-950: 2.0 (0.0%), tests_pri_-900: 1.68 (0.0%), tests_pri_-400: 39 (0.8%), check_bayes: 37 (0.8%), b_tokenize: 15 (0.3%), b_tok_get_all: 9 (0.2%), b_comp_prob: 4.9 (0.1%), b_tok_touch_all: 3.3 (0.1%), b_finish: 0.88 (0.0%), tests_pri_0: 1508 (32.1%), check_dkim_signature: 0.96 (0.0%), check_dkim_adsp: 6 (0.1%), tests_pri_500: 3094 (65.8%), poll_dns_idle: 3086 (65.7%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -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: 2097 Lines: 57 Al Viro writes: > On Tue, Apr 19, 2016 at 10:43:03PM -0500, Eric W. Biederman wrote: >> >> + if (!d_can_lookup(parent)) >> >> + return -ENOENT; >> > >> > And how, pray tell, would a parent of anything fail to be a directory? >> >> It is to make that function be visually distinct from path_parentat >> which does something rather different. > > Huh? I'm asking how can that condition ever turn out to be true. Unless > you really advocate something like > if (2 * 17 != 34) > return -234567; // to make it visually distinct from foobar(), > // which doesn't have such a test > your reply doesn't seem to make any sense... Oh apologies I thought you were asking about the naming of the function, path_parent_directory. Yes. The d_can_lookup does appear to be redundant. It definitely looks like bedtime for me. >> >> + this.name = "pts"; >> >> + this.len = 3; >> >> + this.hash = full_name_hash(this.name, this.len); >> >> + if (parent->d_flags & DCACHE_OP_HASH) { >> >> + int err = parent->d_op->d_hash(parent, &this); >> >> + if (err < 0) >> >> + return err; >> >> + } >> >> + inode_lock(parent->d_inode); >> > >> > What the hell for? What does that lock on parent change for the >> > dcache lookup you are doing here? >> >> Good point. That is overkill. As we know the dentry is a mount point and >> must be in the dcache, the customary lock for performing a lookup from >> the disk is not necessary. > > Er... To avoid reader confusion: > a) d_lookup() does *not* do a filesystem lookup > b) it does not need inode_lock() > c) it (and not a "lookup from the disk") is what's actually being > called in the code in question. And since I was stripping down the ordinary filesystem lookup path to just the pieces needed I apparently wound up with a few extras. Do you think it would be possible to guarantee an rcu lookup for the operations in path_pts? I think needing to perform a follow_mount makes that impossible to guarantee. All the caller wants is to find the superblock of the mounted filesystem and increment sb->s_active. Eric