diff options
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c index 9fa10c614de7..2112e578dccc 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2849,18 +2849,24 @@ static int may_open(const struct path *path, int acc_mode, int flag) case S_IFLNK: return -ELOOP; case S_IFDIR: - if (acc_mode & MAY_WRITE) + if (acc_mode & (MAY_WRITE | MAY_EXEC)) return -EISDIR; break; case S_IFBLK: case S_IFCHR: if (!may_open_dev(path)) return -EACCES; - /*FALLTHRU*/ + fallthrough; case S_IFIFO: case S_IFSOCK: + if (acc_mode & MAY_EXEC) + return -EACCES; flag &= ~O_TRUNC; break; + case S_IFREG: + if ((acc_mode & MAY_EXEC) && path_noexec(path)) + return -EACCES; + break; } error = inode_permission(inode, MAY_OPEN | acc_mode); |