From patchwork Tue Oct 30 16:43:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Prabhu X-Patchwork-Id: 1671201 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B5127DFB7B for ; Tue, 30 Oct 2012 16:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754899Ab2J3QoE (ORCPT ); Tue, 30 Oct 2012 12:44:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41760 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754637Ab2J3QoC (ORCPT ); Tue, 30 Oct 2012 12:44:02 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9UGhcSG005696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Oct 2012 12:43:39 -0400 Received: from localhost.localdomain.com (vpn1-7-197.ams2.redhat.com [10.36.7.197]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9UGhYOH001445 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Oct 2012 12:43:36 -0400 From: Sachin Prabhu To: linux-cifs Cc: Steve French , Jeff Layton , vit.zahradka@tiscali.cz, linux-fsdevel@vger.kernel.org Subject: [PATCH] cifs: Do not lookup hashed negative dentry in cifs_atomic_open Date: Tue, 30 Oct 2012 16:43:33 +0000 Message-Id: <1351615413-9182-1-git-send-email-sprabhu@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org We do not need to lookup a hashed negative directory since we have already revalidated it before and have found it to be fine. This also prevents a crash in cifs_lookup() when it attempts to rehash the already hashed negative lookup dentry. The patch has been tested using the reproducer at https://bugzilla.redhat.com/show_bug.cgi?id=867344#c28 Cc: # 3.6.x Reported-by: Vit Zahradka Signed-off-by: Sachin Prabhu Acked-by: Jeff Layton --- fs/cifs/dir.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 7c0a812..e26d0a6 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -398,6 +398,12 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, * in network traffic in the other paths. */ if (!(oflags & O_CREAT)) { + /* Check for hashed negative dentry. We have already revalidated + * the dentry and it is fine. No need to perform another lookup. + */ + if (!d_unhashed(direntry)) + return -ENOENT; + struct dentry *res = cifs_lookup(inode, direntry, 0); if (IS_ERR(res)) return PTR_ERR(res);