From: Stas Sergeev 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 --- fs/namei.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff -puN fs/namei.c~honour-mnt_noexec-for-access fs/namei.c --- a/fs/namei.c~honour-mnt_noexec-for-access +++ a/fs/namei.c @@ -249,9 +249,11 @@ int permission(struct inode *inode, int /* * 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. */ _