From patchwork Fri Oct 9 09:01:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 7360141 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EC61C9F1D5 for ; Fri, 9 Oct 2015 09:01:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C95B2082C for ; Fri, 9 Oct 2015 09:01:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 302E32082B for ; Fri, 9 Oct 2015 09:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933085AbbJIJB0 (ORCPT ); Fri, 9 Oct 2015 05:01:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43525 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932632AbbJIJBZ (ORCPT ); Fri, 9 Oct 2015 05:01:25 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id C43D7C0BE08B; Fri, 9 Oct 2015 09:01:24 +0000 (UTC) Received: from localhost.localdomain (vpn1-7-172.pek2.redhat.com [10.72.7.172]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9991Jw1023778; Fri, 9 Oct 2015 05:01:21 -0400 From: "Yan, Zheng" To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, "Yan, Zheng" Subject: [PATCH] namei: revalidate negative dentry before return -ENOENT Date: Fri, 9 Oct 2015 17:01:03 +0800 Message-Id: <1444381263-6505-1-git-send-email-zyan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After commit 766c4cbf "namei: d_is_negative() should be checked before ->d_seq validation", lookup_fast() can return -ENOENT without revalidating the negative dentry. This breaks network filesystems that allow creating/deleting files from multiple hosts. Signed-off-by: Yan, Zheng --- fs/namei.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 726d211..5ffbf53 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1558,8 +1558,6 @@ static int lookup_fast(struct nameidata *nd, negative = d_is_negative(dentry); if (read_seqcount_retry(&dentry->d_seq, seq)) return -ECHILD; - if (negative) - return -ENOENT; /* * This sequence count validates that the parent had no @@ -1580,6 +1578,10 @@ static int lookup_fast(struct nameidata *nd, goto unlazy; } } + + if (negative) + return -ENOENT; + path->mnt = mnt; path->dentry = dentry; if (likely(__follow_mount_rcu(nd, path, inode, seqp)))