]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/namei.c
r/o bind mounts: rearrange may_open() to be r/o friendly
[mirror_ubuntu-bionic-kernel.git] / fs / namei.c
index 2792e0ca01d4f03effa44a304e477da9b5e706c0..a29bb0f40ed5c1c22e3d33e2247b71fda8832394 100644 (file)
@@ -1604,10 +1604,6 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
        if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE))
                return -EISDIR;
 
-       error = vfs_permission(nd, acc_mode);
-       if (error)
-               return error;
-
        /*
         * FIFO's, sockets and device files are special: they don't
         * actually live on the filesystem itself, and as such you
@@ -1622,6 +1618,10 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
                flag &= ~O_TRUNC;
        } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
                return -EROFS;
+
+       error = vfs_permission(nd, acc_mode);
+       if (error)
+               return error;
        /*
         * An append-only file must be opened in append mode for writing.
         */