From linux-kernel-owner@vger.kernel.org Wed Feb 14 23:26:51 2007 Return-Path: Received: from mx7.internal (mx7.internal [10.202.2.206]) by store22m.internal (Cyrus v2.3.7-fmsvn10115) with LMTPA; Wed, 14 Feb 2007 23:26:51 -0500 X-Sieve: CMU Sieve 2.3 X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -0.7, FORGED_RCVD_HELO 0.135 X-Spam-source: Country='US', FromHeader='net', MailFrom='org' X-Resolved-to: iankent@fastmail.com.au X-Delivered-to: raven@themaw.net X-Mail-from: linux-kernel-owner+raven=40themaw.net-S932616AbXBOEXB@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by mx1.messagingengine.com (Postfix) with ESMTP id 228A426C481 for ; Wed, 14 Feb 2007 23:26:48 -0500 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932616AbXBOEXB (ORCPT ); Wed, 14 Feb 2007 23:23:01 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932653AbXBOEXA (ORCPT ); Wed, 14 Feb 2007 23:23:00 -0500 Received: from out4.smtp.messagingengine.com ([66.111.4.28]:58503 "EHLO out4.smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932616AbXBOEXA (ORCPT ); Wed, 14 Feb 2007 23:23:00 -0500 Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id BBA051AF21C; Wed, 14 Feb 2007 23:22:57 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by out1.internal (MEProxy); Wed, 14 Feb 2007 23:22:57 -0500 X-Sasl-enc: /QM2JFsDUNrkk7lmy+fJGdsL9vvKL02Q/ha6z2Mx4QGI 1171513376 Received: from raven.themaw.net (210-84-28-121.dyn.iinet.net.au [210.84.28.121]) by mail.messagingengine.com (Postfix) with ESMTP id D6909221F2; Wed, 14 Feb 2007 23:22:54 -0500 (EST) Date: Thu, 15 Feb 2007 13:23:40 +0900 (WST) From: Ian Kent To: Andrew Morton cc: Kernel Mailing List , autofs mailing list Subject: [PATCH 2/2] autofs4 - check for directory re-create in lookup Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org X-Evolution-Source: imap://iankent%40fastmail.com.au@mail.messagingengine.com/ Content-Transfer-Encoding: 8bit Hi Andrew, This problem was identified and fixed some time ago by Jeff Moyer but it fell through the cracks somehow. It is possible that a user space application could remove and re-create a directory during a request. To avoid returning a failure from lookup incorrectly when our current dentry is unhashed we need to check if another positive, hashed dentry matching this one exists and if so return it instead of a fail. Signed-off-by: Jeff Moyer Signed-off-by: Ian Kent Ian --- --- linux-2.6.20/fs/autofs4/root.c.lookup-check-unhased 2007-02-12 13:49:46.000000000 +0900 +++ linux-2.6.20/fs/autofs4/root.c 2007-02-12 13:54:58.000000000 +0900 @@ -655,14 +655,29 @@ static struct dentry *autofs4_lookup(str /* * If this dentry is unhashed, then we shouldn't honour this - * lookup even if the dentry is positive. Returning ENOENT here - * doesn't do the right thing for all system calls, but it should - * be OK for the operations we permit from an autofs. + * lookup. Returning ENOENT here doesn't do the right thing + * for all system calls, but it should be OK for the operations + * we permit from an autofs. */ if (dentry->d_inode && d_unhashed(dentry)) { + /* + * A user space application can (and has done in the past) + * remove and re-create this directory during the callback. + * This can leave us with an unhashed dentry, but a + * successful mount! So we need to perform another + * cached lookup in case the dentry now exists. + */ + struct dentry *parent = dentry->d_parent; + struct dentry *new = d_lookup(parent, &dentry->d_name); + if (new != NULL) + dentry = new; + else + dentry = ERR_PTR(-ENOENT); + if (unhashed) dput(unhashed); - return ERR_PTR(-ENOENT); + + return dentry; } if (unhashed) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/