From: Miklos Szeredi <mszeredi@suse.cz>
For execute permission on a regular files we need to check if file has
any execute bits at all, regardless of capabilites.
This check is normally performed by generic_permission() but was also
added to the case when the filesystem defines its own ->permission()
method. In the latter case the filesystem should be responsible for
performing this check.
So create a helper function exec_permission() that checks returns
-EACCESS if MAY_EXEC is present, the inode is a regular file and no
execute bits are present in inode->i_mode.
Call this function from filesystems which don't call
generic_permission() from their ->permission() methods and which
aren't already performing this check. Also remove the check from
dentry_permission().
The new code should be equivalent to the old.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/cifs/cifsfs.c | 2 +-
fs/coda/dir.c | 4 ++++
fs/coda/pioctl.c | 2 +-
fs/hfs/inode.c | 2 +-
fs/namei.c | 38 +++++++++++++++++++++++---------------
fs/nfs/dir.c | 3 +++
fs/proc/proc_sysctl.c | 3 +++
fs/smbfs/file.c | 6 +++---
include/linux/fs.h | 1 +
9 files changed, 40 insertions(+), 21 deletions(-)
Index: linux-2.6/fs/cifs/cifsfs.c
===================================================================
--- linux-2.6.orig/fs/cifs/cifsfs.c 2008-05-21 13:41:30.000000000 +0200
+++ linux-2.6/fs/cifs/cifsfs.c 2008-05-21 13:41:36.000000000 +0200
@@ -276,7 +276,7 @@ static int cifs_permission(struct dentry
cifs_sb = CIFS_SB(inode->i_sb);
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
- return 0;
+ return exec_permission(inode, mask);
else /* file mode might have been restricted at mount time
on the client (above and beyond ACL on servers) for
servers which do not support setting and viewing mode bits,
Index: ...