Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751767AbcDTEL4 (ORCPT ); Wed, 20 Apr 2016 00:11:56 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:42828 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751281AbcDTELz (ORCPT ); Wed, 20 Apr 2016 00:11:55 -0400 Date: Wed, 20 Apr 2016 05:11:13 +0100 From: Al Viro To: "Eric W. Biederman" 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 Subject: Re: [PATCH] devpts: Make each mount of devpts an independent filesystem. Message-ID: <20160420041113.GF25498@ZenIV.linux.org.uk> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k2jtc5dk.fsf@x220.int.ebiederm.org> 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 Content-Length: 1397 Lines: 38 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... > >> + 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.