From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934937AbcJ0CR7 (ORCPT ); Wed, 26 Oct 2016 22:17:59 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45992 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932239AbcJ0CR4 (ORCPT ); Wed, 26 Oct 2016 22:17:56 -0400 Date: Thu, 27 Oct 2016 03:17:53 +0100 From: Al Viro To: Ian Kent Cc: Andrew Morton , autofs mailing list , Kernel Mailing List , "Eric W. Biederman" , linux-fsdevel , Omar Sandoval Subject: Re: [PATCH 6/8] autofs - use path_is_mountpoint() to fix unreliable d_mountpoint() checks Message-ID: <20161027021753.GJ19539@ZenIV.linux.org.uk> References: <20161011053352.27645.83962.stgit@pluto.themaw.net> <20161011053418.27645.15241.stgit@pluto.themaw.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161011053418.27645.15241.stgit@pluto.themaw.net> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 11, 2016 at 01:34:18PM +0800, Ian Kent wrote: > + path = file->f_path; > + > /* > * An empty directory in an autofs file system is always a > * mount point. The daemon must have failed to mount this > @@ -123,7 +126,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) > * it. > */ > spin_lock(&sbi->lookup_lock); > - if (!d_mountpoint(dentry) && simple_empty(dentry)) { > + if (!path_is_mountpoint(&path) && simple_empty(dentry)) { Why not &file->f_path, provided that you constify that thing properly? > + if (rcu_walk) { > + if (!path_is_mountpoint_rcu(path)) > + return -EISDIR; > + } else { > + if (!path_is_mountpoint(path)) > + return -EISDIR; IDGI. What's the point of _having_ the _rcu() variant, anyway? Here you are probably paying more in terms of i-cache footprint/branch prediction than you win on not doing that rcu_read_lock()/rcu_read_unlock()... _rcu variants make sense when non-RCU case does something you can't do under RCU; here your path_is_mountpoint() is pretty close to being rcu_read_lock()+path_is_mountpoint_rcu()+rcu_read_unlock() anyway...