linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Trond Myklebust <trond.myklebust@primarydata.com>,
	Jeff Layton <jlayton@poochiereds.net>,
	Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
	Oleg Drokin <green@linuxhacker.ru>
Subject: [PATCH 1/2] nfs: Fix spurios EPERM when mkdir of existing dentry
Date: Thu,  7 Jul 2016 01:53:46 -0400	[thread overview]
Message-ID: <1467870827-2959489-2-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1467870827-2959489-1-git-send-email-green@linuxhacker.ru>

It's great when we can shave an extra RPC, but not at the expense
of correctness.
We should not return EPERM (from vfs_create/mknod/mkdir) if the
name already exists, even if we have no write access in parent.

Since the check in nfs_permission is clearly not enough to stave
off this, just throw in the extra READ access to actually
go through.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 fs/nfs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index d8015a0..8c7835b 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1383,8 +1383,10 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
 	/*
 	 * If we're doing an exclusive create, optimize away the lookup
 	 * but don't hash the dentry.
+	 * This optimization only works if we can write in the parent.
 	 */
-	if (nfs_is_exclusive_create(dir, flags))
+	if (nfs_is_exclusive_create(dir, flags) &&
+	    (inode_permission(dir, MAY_WRITE | MAY_READ | MAY_EXEC) == 0))
 		return NULL;
 
 	res = ERR_PTR(-ENOMEM);
-- 
2.7.4


  reply	other threads:[~2016-07-07  5:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-07  5:53 [RFC] [PATCH 0/2] mkdir lookup optimization Oleg Drokin
2016-07-07  5:53 ` Oleg Drokin [this message]
2016-07-07 16:16   ` [PATCH 1/2] nfs: Fix spurios EPERM when mkdir of existing dentry Trond Myklebust
2016-07-07 16:52     ` Oleg Drokin
2016-07-07 16:59       ` Trond Myklebust
2016-07-07 17:07         ` Oleg Drokin
2016-07-07 17:27           ` Trond Myklebust
2016-07-07 17:32             ` Oleg Drokin
2016-07-07 21:52             ` Oleg Drokin
2016-07-07 23:17               ` Trond Myklebust
2016-07-07  5:53 ` [PATCH 2/2] staging/lustre: Prevent spurious EPERM on mkdir Oleg Drokin
2016-07-07 10:53 ` [RFC] [PATCH 0/2] mkdir lookup optimization Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467870827-2959489-2-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=jlayton@poochiereds.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@primarydata.com \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).