Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186AbcDTDxv (ORCPT ); Tue, 19 Apr 2016 23:53:51 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:49076 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753958AbcDTDxu (ORCPT ); Tue, 19 Apr 2016 23:53:50 -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> Date: Tue, 19 Apr 2016 22:43:03 -0500 In-Reply-To: <20160420032541.GE25498@ZenIV.linux.org.uk> (Al Viro's message of "Wed, 20 Apr 2016 04:25:42 +0100") Message-ID: <87k2jtc5dk.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: U2FsdGVkX18Hey8UYjNwRBBFpvyfr5o6JzQjeCdtZXA= 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 * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 1.0 T_XMDrugObfuBody_04 obfuscated drug references X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Al Viro X-Spam-Relay-Country: X-Spam-Timing: total 1279 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 4.5 (0.4%), b_tie_ro: 3.1 (0.2%), parse: 1.03 (0.1%), extract_message_metadata: 16 (1.2%), get_uri_detail_list: 2.1 (0.2%), tests_pri_-1000: 7 (0.5%), tests_pri_-950: 1.19 (0.1%), tests_pri_-900: 1.04 (0.1%), tests_pri_-400: 23 (1.8%), check_bayes: 22 (1.7%), b_tokenize: 7 (0.5%), b_tok_get_all: 7 (0.6%), b_comp_prob: 1.83 (0.1%), b_tok_touch_all: 3.4 (0.3%), b_finish: 0.81 (0.1%), tests_pri_0: 1218 (95.2%), check_dkim_signature: 0.52 (0.0%), check_dkim_adsp: 3.5 (0.3%), tests_pri_500: 5.0 (0.4%), 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1442 Lines: 51 Al Viro writes: > On Tue, Apr 19, 2016 at 10:04:20PM -0500, Eric W. Biederman wrote: >> +#ifdef CONFIG_UNIX98_PTYS >> +int path_pts(struct path *path) >> +{ >> + /* Find "pts" in the same directory as the input path */ >> + struct dentry *child, *parent; >> + struct qstr this; >> + int ret; >> + >> + ret = path_parent_directory(path); >> + if (ret) >> + return ret; >> + >> + parent = path->dentry; >> + 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. >> + 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. >> + child = d_lookup(parent, &this); >> + inode_unlock(parent->d_inode); >> + if (!child) >> + return -ENOENT; > > Take a look at d_hash_and_lookup(), BTW... Yes. That does look like a reasonable simplification. Eric