Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 257322
b: refs/heads/master
c: d594e7e
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed Jul 20, 2011
1 parent af9e183 commit 5f1e969
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eecdd358b467405a084d400d5ec571bbdbfe97a3
refs/heads/master: d594e7ec4da6c1a527dea4965eee37cd785792b8
17 changes: 13 additions & 4 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,29 @@ int generic_permission(struct inode *inode, int mask)
if (ret != -EACCES)
return ret;

if (S_ISDIR(inode->i_mode)) {
/* DACs are overridable for directories */
if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
return 0;
if (!(mask & MAY_WRITE))
if (ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
return 0;
return -EACCES;
}
/*
* Read/write DACs are always overridable.
* Executable DACs are overridable for all directories and
* for non-directories that have least one exec bit set.
* Executable DACs are overridable when there is
* at least one exec bit set.
*/
if (!(mask & MAY_EXEC) || execute_ok(inode))
if (!(mask & MAY_EXEC) || (inode->i_mode & S_IXUGO))
if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
return 0;

/*
* Searching includes executable on directories, else just read.
*/
mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
if (mask == MAY_READ || (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE)))
if (mask == MAY_READ)
if (ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
return 0;

Expand Down

0 comments on commit 5f1e969

Please sign in to comment.