vfs: have chroot retry once on ESTALE error
authorJeff Layton <jlayton@redhat.com>
Thu, 20 Dec 2012 22:08:32 +0000 (17:08 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 20 Dec 2012 23:50:06 +0000 (18:50 -0500)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/open.c

index 402dfcb6720b7fff3fa7dab47b04c27ec606c0c5..a13a54d3e6912d10217406b737bb07ecc70e2d68 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -445,8 +445,9 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
 {
        struct path path;
        int error;
-
-       error = user_path_dir(filename, &path);
+       unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
+retry:
+       error = user_path_at(AT_FDCWD, filename, lookup_flags, &path);
        if (error)
                goto out;
 
@@ -465,6 +466,10 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
        error = 0;
 dput_and_out:
        path_put(&path);
+       if (retry_estale(error, lookup_flags)) {
+               lookup_flags |= LOOKUP_REVAL;
+               goto retry;
+       }
 out:
        return error;
 }