From 2561f409d2122c0079a1b53a274f4f6f92d4e60d Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 22 Aug 2006 20:06:03 -0400 Subject: [PATCH] --- yaml --- r: 33550 b: refs/heads/master c: a343bb7750e6a098909c34f5c5dfddbc4fa40053 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/namei.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index f3241a64c7b3..728175b21e0a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 16b4289c7460ba9c04af40c574949dcca9029658 +refs/heads/master: a343bb7750e6a098909c34f5c5dfddbc4fa40053 diff --git a/trunk/fs/namei.c b/trunk/fs/namei.c index 863166441bf3..432d6bc6fab0 100644 --- a/trunk/fs/namei.c +++ b/trunk/fs/namei.c @@ -227,10 +227,10 @@ int generic_permission(struct inode *inode, int mask, int permission(struct inode *inode, int mask, struct nameidata *nd) { + umode_t mode = inode->i_mode; int retval, submask; if (mask & MAY_WRITE) { - umode_t mode = inode->i_mode; /* * Nobody gets write access to a read-only fs. @@ -247,6 +247,13 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) } + /* + * MAY_EXEC on regular files requires special handling: We override + * filesystem execute permissions if the mode bits aren't set. + */ + if ((mask & MAY_EXEC) && S_ISREG(mode) && !(mode & S_IXUGO)) + return -EACCES; + /* Ordinary permission routines do not understand MAY_APPEND. */ submask = mask & ~MAY_APPEND; if (inode->i_op && inode->i_op->permission)