Skip to content

Commit

Permalink
generic_permission: MAY_OPEN is not write access
Browse files Browse the repository at this point in the history
generic_permission was refusing CAP_DAC_READ_SEARCH-enabled
processes from opening DAC-protected files read-only, because
do_filp_open adds MAY_OPEN to the open mask.

Ignore MAY_OPEN.  After this patch, CAP_DAC_READ_SEARCH is
again sufficient to open(fname, O_RDONLY) on a file to which
DAC otherwise refuses us read permission.

Reported-by: Mike Kazantsev <mk.fraggod@gmail.com>
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Tested-by: Mike Kazantsev <mk.fraggod@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Serge E. Hallyn authored and Linus Torvalds committed Dec 30, 2009
1 parent 9a7262a commit 7ea6600
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ int generic_permission(struct inode *inode, int mask,
/*
* 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 (capable(CAP_DAC_READ_SEARCH))
return 0;
Expand Down

0 comments on commit 7ea6600

Please sign in to comment.