From: Stas Sergeev Date: Thu, 7 Dec 2006 04:35:25 +0000 (-0800) Subject: [PATCH] honour MNT_NOEXEC for access() X-Git-Tag: v2.6.20-rc1~145^2^2~238 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=317a40ac2237732aba531eee2c7b5e39dd40e959;p=linux-2.6-omap-h63xx.git [PATCH] honour MNT_NOEXEC for access() Make access(X_OK) take the "noexec" mount option into account. Signed-off-by: Stas Sergeev Cc: Jakub Jelinek Cc: Arjan van de Ven Cc: Alan Cox Cc: Hugh Dickins Cc: Ulrich Drepper Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/namei.c b/fs/namei.c index 28d49b301d5..61f99c1967d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -249,9 +249,11 @@ 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. + * filesystem execute permissions if the mode bits aren't set or + * the fs is mounted with the "noexec" flag. */ - if ((mask & MAY_EXEC) && S_ISREG(mode) && !(mode & S_IXUGO)) + if ((mask & MAY_EXEC) && S_ISREG(mode) && (!(mode & S_IXUGO) || + (nd && nd->mnt && (nd->mnt->mnt_flags & MNT_NOEXEC)))) return -EACCES; /* Ordinary permission routines do not understand MAY_APPEND. */