Skip to content

Commit 754f8cb

Browse files
rhvgoyalMiklos Szeredi
authored andcommitted
ovl: do not require mounter to have MAY_WRITE on lower
Now we have two levels of checks in ovl_permission(). overlay inode is checked with the creds of task while underlying inode is checked with the creds of mounter. Looks like mounter does not have to have WRITE access to files on lower/. So remove the MAY_WRITE from access mask for checks on underlying lower inode. This means task should still have the MAY_WRITE permission on lower inode and mounter is not required to have MAY_WRITE. It also solves the problem of read only NFS mounts being used as lower. If __inode_permission(lower_inode, MAY_WRITE) is called on read only NFS, it fails. By resetting MAY_WRITE, check succeeds and case of read only NFS shold work with overlay without having to specify any special mount options (default permission). Signed-off-by: Vivek Goyal <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 1175b6b commit 754f8cb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/overlayfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ int ovl_permission(struct inode *inode, int mask)
184184
return err;
185185

186186
old_cred = ovl_override_creds(inode->i_sb);
187+
if (!is_upper)
188+
mask &= ~(MAY_WRITE | MAY_APPEND);
187189
err = __inode_permission(realinode, mask);
188190
revert_creds(old_cred);
189191

0 commit comments

Comments
 (0)