From: Serge E. Hallyn Date: Tue, 29 Dec 2009 20:50:19 +0000 (-0600) Subject: generic_permission: MAY_OPEN is not write access X-Git-Tag: v2.6.31.10~8 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=92a5184168d552fd3e8f43d05ac04924d6aaa43b;p=karo-tx-linux.git generic_permission: MAY_OPEN is not write access commit 7ea6600148c265b1fd53e521022b1d7aec81d974 upstream. 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 Signed-off-by: Serge E. Hallyn Tested-by: Mike Kazantsev Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/namei.c b/fs/namei.c index fcfc5539252c..b224905ff98e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -221,6 +221,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;