From patchwork Fri Aug 22 22:20:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 4767371 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3EFB1C0338 for ; Fri, 22 Aug 2014 22:21:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 674152012F for ; Fri, 22 Aug 2014 22:21:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 951092013A for ; Fri, 22 Aug 2014 22:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752291AbaHVWU4 (ORCPT ); Fri, 22 Aug 2014 18:20:56 -0400 Received: from mail-oi0-f47.google.com ([209.85.218.47]:38789 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282AbaHVWUy (ORCPT ); Fri, 22 Aug 2014 18:20:54 -0400 Received: by mail-oi0-f47.google.com with SMTP id x69so8163494oia.6 for ; Fri, 22 Aug 2014 15:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=GAmizLEw8E0ogByn8R/QXQznGTWttkt6PoGRpx64w+g=; b=JqqK4ikGUD2r9AXEhoTK19fXAIdvQc3hFd6pqy9eAexeE303/5UKDhr0moHVrOqAf5 mTlA3965L6dyDBYvrC+8566d37tyrdVoHz1sD1glQd/X4LDso4eUBnWzidPV5jknXog6 dVivxN6HeexWmhPAZxUGz94KJv4F3vrHYqSC09dOunpguNcp2VgajXHbTKq2hAeQvcgF 1WiKRyI6608EbeXUTrlk+D/Da5d6/Lvr0Pkno0DsG3w31uLYxMonirPEmGDmrXLbv3oK /vzkxwOFjpDAS0P+0rCM/qZ0Cn+1n7r/8R92cMBaupdGfITrh9P1Id57b0umOBuZcrDK FvGQ== X-Received: by 10.182.135.201 with SMTP id pu9mr5014584obb.81.1408746054134; Fri, 22 Aug 2014 15:20:54 -0700 (PDT) Received: from shirish-ThinkPad-T400.gns.novell.com (75-13-85-90.lightspeed.austtx.sbcglobal.net. [75.13.85.90]) by mx.google.com with ESMTPSA id v5sm44159664oei.13.2014.08.22.15.20.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 15:20:52 -0700 (PDT) From: shirishpargaonkar@gmail.com X-Google-Original-From: spargaonkar@suse.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, shirish , Shirish Pargaonkar Subject: [PATCH 1/5] cifs: shared-superblock: create a root dentry/inode for EACCES error Date: Fri, 22 Aug 2014 17:20:46 -0500 Message-Id: <1408746046-10147-1-git-send-email-spargaonkar@suse.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: shirish It is possible that an authenticated user has access to a subdirectory being mounted but does not have access to the share directory at the server to be mounted on a root directory. Create an dummy inode with ROOT_I and continue the mount process. Signed-off-by: Shirish Pargaonkar --- fs/cifs/inode.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 41de393..fd5941b 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -889,8 +889,10 @@ inode_has_hashed_dentries(struct inode *inode) spin_lock(&inode->i_lock); hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { if (!d_unhashed(dentry) || IS_ROOT(dentry)) { - spin_unlock(&inode->i_lock); - return true; + if (!(dentry->d_flags & DCACHE_DISCONNECTED)) { + spin_unlock(&inode->i_lock); + return true; + } } } spin_unlock(&inode->i_lock); @@ -942,6 +944,23 @@ retry_iget5_locked: return inode; } +void +fill_phfattr(struct cifs_fattr *cf, struct super_block *sb) +{ + + struct cifs_sb_info *cifs_sb = CIFS_SB(sb); + + memset(cf, 0, sizeof(*cf)); + cf->cf_uniqueid = ROOT_I; + cf->cf_nlink = 1; + cf->cf_atime = CURRENT_TIME; + cf->cf_ctime = CURRENT_TIME; + cf->cf_mtime = CURRENT_TIME; + cf->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU; + cf->cf_uid = cifs_sb->mnt_uid; + cf->cf_gid = cifs_sb->mnt_gid; +} + /* gets root inode */ struct inode *cifs_root_iget(struct super_block *sb) { @@ -950,6 +969,7 @@ struct inode *cifs_root_iget(struct super_block *sb) struct inode *inode = NULL; long rc; struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); + struct cifs_fattr phfattr; xid = get_xid(); if (tcon->unix_ext) @@ -958,8 +978,16 @@ struct inode *cifs_root_iget(struct super_block *sb) rc = cifs_get_inode_info(&inode, "", NULL, sb, xid, NULL); if (!inode) { - inode = ERR_PTR(rc); - goto out; + if (rc == -EACCES) { + fill_phfattr(&phfattr, sb); + inode = cifs_iget(sb, &phfattr); + if (inode) + rc = 0; + } + if (rc) { + inode = ERR_PTR(rc); + goto out; + } } #ifdef CONFIG_CIFS_FSCACHE