diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2018-10-26 17:34:39 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-10-26 17:34:39 -0400 |
commit | 007ea44892e6fa963a0876a979e34890325c64eb (patch) | |
tree | 83dff50eb71f2222451342424e4dd3e64b5f27fb | |
parent | 6cd078702f2f33cb6b19a682de3e9184112f1a46 (diff) |
ovl: relax permission checking on underlying layers
Make permission checking more consistent:
- special files don't need any access check on underling fs
- exec permission check doesn't need to be performed on underlying fs
Reported-by: "J. Bruce Fields" <bfields@fieldses.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r-- | fs/overlayfs/inode.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 3b7ed5d2279c..6bcc9dedc342 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -286,13 +286,22 @@ int ovl_permission(struct inode *inode, int mask) | |||
286 | if (err) | 286 | if (err) |
287 | return err; | 287 | return err; |
288 | 288 | ||
289 | old_cred = ovl_override_creds(inode->i_sb); | 289 | /* No need to do any access on underlying for special files */ |
290 | if (!upperinode && | 290 | if (special_file(realinode->i_mode)) |
291 | !special_file(realinode->i_mode) && mask & MAY_WRITE) { | 291 | return 0; |
292 | |||
293 | /* No need to access underlying for execute */ | ||
294 | mask &= ~MAY_EXEC; | ||
295 | if ((mask & (MAY_READ | MAY_WRITE)) == 0) | ||
296 | return 0; | ||
297 | |||
298 | /* Lower files get copied up, so turn write access into read */ | ||
299 | if (!upperinode && mask & MAY_WRITE) { | ||
292 | mask &= ~(MAY_WRITE | MAY_APPEND); | 300 | mask &= ~(MAY_WRITE | MAY_APPEND); |
293 | /* Make sure mounter can read file for copy up later */ | ||
294 | mask |= MAY_READ; | 301 | mask |= MAY_READ; |
295 | } | 302 | } |
303 | |||
304 | old_cred = ovl_override_creds(inode->i_sb); | ||
296 | err = inode_permission(realinode, mask); | 305 | err = inode_permission(realinode, mask); |
297 | revert_creds(old_cred); | 306 | revert_creds(old_cred); |
298 | 307 | ||