From patchwork Sat Feb 14 05:17:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: d-email-bdonlan@fushizen.net X-Patchwork-Id: 23141 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id C3988DDD1B for ; Sat, 14 Feb 2009 16:41:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751428AbZBNFlN (ORCPT ); Sat, 14 Feb 2009 00:41:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751013AbZBNFlN (ORCPT ); Sat, 14 Feb 2009 00:41:13 -0500 Received: from satoko.is.fushizen.net ([207.192.69.114]:58944 "EHLO satoko.is.fushizen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbZBNFlN (ORCPT ); Sat, 14 Feb 2009 00:41:13 -0500 X-Greylist: delayed 1440 seconds by postgrey-1.27 at vger.kernel.org; Sat, 14 Feb 2009 00:41:12 EST Received: from haml-195.res.umass.edu ([72.19.82.195] helo=localhost.localdomain) by satoko.is.fushizen.net with esmtpa (Exim 4.69) (envelope-from ) id 1LYCtr-000825-7c; Sat, 14 Feb 2009 05:17:11 +0000 From: d-email-bdonlan@fushizen.net To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: sct@redhat.com, akpm@linux-foundation.org, adilger@sun.com, tytso@mit.edu, Bryan Donlan Subject: [RESEND/PATCH] ext[234]: Return -EIO not -ESTALE on directory traversal missing inode Date: Sat, 14 Feb 2009 00:17:10 -0500 Message-Id: <1234588630-9380-1-git-send-email-d-email-bdonlan@fushizen.net> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <1234588099-8445-1-git-sen--dry-run> References: <1234588099-8445-1-git-sen--dry-run> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Bryan Donlan The ext[234]_iget() functions in the ext[234] family of filesystems returns -ESTALE if invoked on a deleted inode, in order to report errors to NFS properly. However, in ext[234]_lookup(), this -ESTALE can be propagated to userspace if the filesystem is corrupted, and a inode is linked even though it is marked as deleted. This leads to a misleading error message - "Stale NFS file handle" - and confusion on the part of the admin. The bug can be easily reproduced by creating a new filesystem, making a link to an unused inode using debugfs, then mounting and attempting to ls -l said link. This patch thus changes ext[234]_lookup to return -EIO if it receives -ESTALE from ext[234]_iget(), as ext[234] does for other filesystem metadata corruption. Signed-off-by: Bryan Donlan --- Apologies for the resend so quickly for those on the CC list - my mailer was misconfigured and the mail rejected by vger. fs/ext2/namei.c | 8 ++++++-- fs/ext3/namei.c | 8 ++++++-- fs/ext4/namei.c | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 90ea179..7dab3e8 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -66,8 +66,12 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str inode = NULL; if (ino) { inode = ext2_iget(dir->i_sb, ino); - if (IS_ERR(inode)) - return ERR_CAST(inode); + if (unlikely(IS_ERR(inode))) { + if (PTR_ERR(inode) == -ESTALE) + return ERR_PTR(-EIO); + else + return ERR_CAST(inode); + } } return d_splice_alias(inode, dentry); } diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 4db4ffa..625f5dc 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1047,8 +1047,12 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str return ERR_PTR(-EIO); } inode = ext3_iget(dir->i_sb, ino); - if (IS_ERR(inode)) - return ERR_CAST(inode); + if (unlikely(IS_ERR(inode))) { + if (PTR_ERR(inode) == -ESTALE) + return ERR_PTR(-EIO); + else + return ERR_CAST(inode); + } } return d_splice_alias(inode, dentry); } diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index ba702bd..4b054b3 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1052,8 +1052,12 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru return ERR_PTR(-EIO); } inode = ext4_iget(dir->i_sb, ino); - if (IS_ERR(inode)) - return ERR_CAST(inode); + if (unlikely(IS_ERR(inode))) { + if (PTR_ERR(inode) == -ESTALE) + return ERR_PTR(-EIO); + else + return ERR_CAST(inode); + } } return d_splice_alias(inode, dentry); }