Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #5 from mjg59/overlayfs_selinux_lower
Browse files Browse the repository at this point in the history
Don't verify write permissions on lower inodes on overlayfs
  • Loading branch information
mjg59 committed Jan 5, 2016
2 parents 91872e3 + 3f2106f commit 0f9fcbb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/overlayfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ int ovl_permission(struct inode *inode, int mask)
goto out_dput;
}

if (!is_upper)
mask |= MAY_OPEN_LOWER;

err = __inode_permission(realinode, mask);
out_dput:
dput(alias);
Expand Down
1 change: 1 addition & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typedef void (dax_iodone_t)(struct buffer_head *bh_map, int uptodate);
#define MAY_CHDIR 0x00000040
/* called from RCU mode, don't block */
#define MAY_NOT_BLOCK 0x00000080
#define MAY_OPEN_LOWER 0x00000100

/*
* flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
Expand Down
9 changes: 9 additions & 0 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,15 @@ static int selinux_inode_permission(struct inode *inode, int mask)
u32 audited, denied;

from_access = mask & MAY_ACCESS;

/*
* If we're trying to open the lower layer of an overlay mount, don't
* worry about write or append permissions - these will be verified
* against the upper context
*/
if (mask & MAY_OPEN_LOWER)
mask &= ~(MAY_WRITE|MAY_APPEND);

mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND);

/* No permission to check. Existence test. */
Expand Down

0 comments on commit 0f9fcbb

Please sign in to comment.