linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-audit@redhat.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH v7 34/49] vfs: have faccessat retry once on an ESTALE error
Date: Mon,  1 Oct 2012 20:16:43 -0400	[thread overview]
Message-ID: <1349137018-21948-35-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1349137018-21948-1-git-send-email-jlayton@redhat.com>

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/open.c | 64 +++++++++++++++++++++++++++++++++------------------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index 5dcee00..a5a5c9a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -312,6 +312,8 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
 	struct path path;
 	struct inode *inode;
 	int res;
+	unsigned int lookup_flags = LOOKUP_FOLLOW;
+	unsigned int try = 0;
 
 	if (mode & ~S_IRWXO)	/* where's F_OK, X_OK, W_OK, R_OK? */
 		return -EINVAL;
@@ -335,42 +337,44 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
 
 	old_cred = override_creds(override_cred);
 
-	res = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
-	if (res)
-		goto out;
+	do {
+		res = user_path_at(dfd, filename, lookup_flags, &path);
+		if (res)
+			break;
 
-	inode = path.dentry->d_inode;
+		inode = path.dentry->d_inode;
+
+		if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) {
+			/*
+			 * MAY_EXEC on regular files is denied if the fs is
+			 * mounted with the "noexec" flag.
+			 */
+			res = -EACCES;
+			if (path.mnt->mnt_flags & MNT_NOEXEC)
+				goto out_path_release;
+		}
 
-	if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) {
+		res = inode_permission(inode, mode | MAY_ACCESS);
+		/* SuS v2 requires we report a read only fs too */
+		if (res || !(mode & S_IWOTH) || special_file(inode->i_mode))
+			goto out_path_release;
 		/*
-		 * MAY_EXEC on regular files is denied if the fs is mounted
-		 * with the "noexec" flag.
+		 * This is a rare case where using __mnt_is_readonly()
+		 * is OK without a mnt_want/drop_write() pair.  Since
+		 * no actual write to the fs is performed here, we do
+		 * not need to telegraph to that to anyone.
+		 *
+		 * By doing this, we accept that this access is
+		 * inherently racy and know that the fs may change
+		 * state before we even see this result.
 		 */
-		res = -EACCES;
-		if (path.mnt->mnt_flags & MNT_NOEXEC)
-			goto out_path_release;
-	}
-
-	res = inode_permission(inode, mode | MAY_ACCESS);
-	/* SuS v2 requires we report a read only fs too */
-	if (res || !(mode & S_IWOTH) || special_file(inode->i_mode))
-		goto out_path_release;
-	/*
-	 * This is a rare case where using __mnt_is_readonly()
-	 * is OK without a mnt_want/drop_write() pair.  Since
-	 * no actual write to the fs is performed here, we do
-	 * not need to telegraph to that to anyone.
-	 *
-	 * By doing this, we accept that this access is
-	 * inherently racy and know that the fs may change
-	 * state before we even see this result.
-	 */
-	if (__mnt_is_readonly(path.mnt))
-		res = -EROFS;
+		if (__mnt_is_readonly(path.mnt))
+			res = -EROFS;
 
 out_path_release:
-	path_put(&path);
-out:
+		path_put(&path);
+		lookup_flags |= LOOKUP_REVAL;
+	} while (retry_estale(res, try++));
 	revert_creds(old_cred);
 	put_cred(override_cred);
 	return res;
-- 
1.7.11.4

  parent reply	other threads:[~2012-10-02  0:16 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02  0:16 [PATCH v7 00/49] audit/getname/estale patch series Jeff Layton
2012-10-02  0:16 ` [PATCH v7 01/49] audit: remove unnecessary NULL ptr checks from do_path_lookup Jeff Layton
2012-10-02  0:16 ` [PATCH v7 02/49] audit: pass in dentry to audit_copy_inode wherever possible Jeff Layton
2012-10-02 15:53   ` Christoph Hellwig
2012-10-02 16:40     ` Jeff Layton
2012-10-02  0:16 ` [PATCH v7 03/49] audit: no need to walk list in audit_inode if name is NULL Jeff Layton
2012-10-02 15:56   ` Christoph Hellwig
2012-10-02  0:16 ` [PATCH v7 04/49] audit: reverse arguments to audit_inode_child Jeff Layton
2012-10-02  0:16 ` [PATCH v7 05/49] audit: add a new "type" field to audit_names struct Jeff Layton
2012-10-02 15:50   ` Christoph Hellwig
2012-10-02 15:58     ` Jeff Layton
2012-10-02 16:55     ` Jeff Layton
2012-10-02  0:16 ` [PATCH v7 06/49] audit: set the name_len in audit_inode for parent lookups Jeff Layton
2012-10-02  0:16 ` [PATCH v7 07/49] audit: remove dirlen argument to audit_compare_dname_path Jeff Layton
2012-10-02  0:16 ` [PATCH v7 08/49] audit: make audit_compare_dname_path use parent_len helper Jeff Layton
2012-10-02  0:16 ` [PATCH v7 09/49] audit: optimize audit_compare_dname_path Jeff Layton
2012-10-02  0:16 ` [PATCH v7 10/49] audit: overhaul __audit_inode_child to accomodate retrying Jeff Layton
2012-10-02  0:16 ` [PATCH v7 11/49] vfs: allocate page instead of names_cache buffer in mount_block_root Jeff Layton
2012-10-02  0:16 ` [PATCH v7 12/49] vfs: make dir_name arg to do_mount a const char * Jeff Layton
2012-10-02  0:16 ` [PATCH v7 13/49] acct: constify the name arg to acct_on Jeff Layton
2012-10-02  0:16 ` [PATCH v7 14/49] vfs: define getname_info struct and have getname() return it Jeff Layton
2012-10-02  0:16 ` [PATCH v7 15/49] audit: allow audit code to satisfy getname requests from its names_list Jeff Layton
2012-10-02  0:16 ` [PATCH v7 16/49] vfs: turn do_path_lookup into wrapper around getname_info variant Jeff Layton
2012-10-02  0:16 ` [PATCH v7 17/49] vfs: make path_openat take a getname_info pointer Jeff Layton
2012-10-02  0:16 ` [PATCH v7 18/49] audit: make audit_inode take getname_info Jeff Layton
2012-10-02  0:16 ` [PATCH v7 19/49] vfs: embed getname_info inside of names_cache allocation if possible Jeff Layton
2012-10-02  0:16 ` [PATCH v7 20/49] vfs: unexport getname and putname symbols Jeff Layton
2012-10-02  0:16 ` [PATCH v7 21/49] vfs: add a retry_estale helper function to handle retries on ESTALE Jeff Layton
2012-10-02  0:16 ` [PATCH v7 22/49] vfs: make fstatat retry on ESTALE errors from getattr call Jeff Layton
2012-10-02  0:16 ` [PATCH v7 23/49] vfs: fix readlinkat to retry on ESTALE Jeff Layton
2012-10-02  0:16 ` [PATCH v7 24/49] vfs: add new "reval" argument to kern_path_create and user_path_create Jeff Layton
2012-10-02  0:16 ` [PATCH v7 25/49] vfs: fix mknodat to retry on ESTALE errors Jeff Layton
2012-10-02  0:16 ` [PATCH v7 26/49] vfs: fix mkdir " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 27/49] vfs: fix symlinkat " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 28/49] vfs: fix linkat " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 29/49] vfs: add a reval argument to user_path_parent Jeff Layton
2012-10-02  0:16 ` [PATCH v7 30/49] vfs: make rmdir retry on ESTALE errors Jeff Layton
2012-10-02  0:16 ` [PATCH v7 31/49] vfs: make do_unlinkat " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 32/49] vfs: fix renameat to " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 33/49] vfs: have do_sys_truncate retry once on an ESTALE error Jeff Layton
2012-10-02  0:16 ` Jeff Layton [this message]
2012-10-02  0:16 ` [PATCH v7 35/49] vfs: have chdir retry lookup and call once on " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 36/49] vfs: make chroot retry " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 37/49] vfs: make fchmodat retry once on ESTALE errors Jeff Layton
2012-10-02  0:16 ` [PATCH v7 38/49] vfs: make fchownat " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 39/49] vfs: convert do_filp_open to use retry_estale helper Jeff Layton
2012-10-02  0:16 ` [PATCH v7 40/49] vfs: convert do_file_open_root " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 41/49] vfs: allow utimensat() calls to retry once on an ESTALE error Jeff Layton
2012-10-02  0:16 ` [PATCH v7 42/49] vfs: allow setxattr to retry once on ESTALE errors Jeff Layton
2012-10-02  0:16 ` [PATCH v7 43/49] vfs: allow lsetxattr() " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 44/49] vfs: make getxattr retry once on an ESTALE error Jeff Layton
2012-10-02  0:16 ` [PATCH v7 45/49] vfs: make lgetxattr retry once on ESTALE Jeff Layton
2012-10-02  0:16 ` [PATCH v7 46/49] vfs: make listxattr retry once on ESTALE error Jeff Layton
2012-10-02  0:16 ` [PATCH v7 47/49] vfs: make llistxattr " Jeff Layton
2012-10-02  0:16 ` [PATCH v7 48/49] vfs: make removexattr retry once on ESTALE Jeff Layton
2012-10-02  0:16 ` [PATCH v7 49/49] vfs: make lremovexattr retry once on ESTALE error 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=1349137018-21948-35-git-send-email-jlayton@redhat.com \
    --to=jlayton@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).