diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/exec.c | 4 | ||||
-rw-r--r-- | fs/namei.c | 13 |
2 files changed, 6 insertions, 11 deletions
@@ -118,7 +118,7 @@ asmlinkage long sys_uselib(const char __user * library) | |||
118 | if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) | 118 | if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) |
119 | goto exit; | 119 | goto exit; |
120 | 120 | ||
121 | error = vfs_permission(&nd, MAY_READ | MAY_EXEC); | 121 | error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN); |
122 | if (error) | 122 | if (error) |
123 | goto exit; | 123 | goto exit; |
124 | 124 | ||
@@ -666,7 +666,7 @@ struct file *open_exec(const char *name) | |||
666 | struct inode *inode = nd.path.dentry->d_inode; | 666 | struct inode *inode = nd.path.dentry->d_inode; |
667 | file = ERR_PTR(-EACCES); | 667 | file = ERR_PTR(-EACCES); |
668 | if (S_ISREG(inode->i_mode)) { | 668 | if (S_ISREG(inode->i_mode)) { |
669 | int err = vfs_permission(&nd, MAY_EXEC); | 669 | int err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN); |
670 | file = ERR_PTR(err); | 670 | file = ERR_PTR(err); |
671 | if (!err) { | 671 | if (!err) { |
672 | file = nameidata_to_filp(&nd, | 672 | file = nameidata_to_filp(&nd, |
diff --git a/fs/namei.c b/fs/namei.c index 33dcaf025c49..6b0e8e5e079e 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -263,12 +263,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
263 | 263 | ||
264 | /* Ordinary permission routines do not understand MAY_APPEND. */ | 264 | /* Ordinary permission routines do not understand MAY_APPEND. */ |
265 | if (inode->i_op && inode->i_op->permission) { | 265 | if (inode->i_op && inode->i_op->permission) { |
266 | int extra = 0; | 266 | retval = inode->i_op->permission(inode, mask); |
267 | if (nd) { | ||
268 | if (nd->flags & LOOKUP_OPEN) | ||
269 | extra |= MAY_OPEN; | ||
270 | } | ||
271 | retval = inode->i_op->permission(inode, mask | extra); | ||
272 | if (!retval) { | 267 | if (!retval) { |
273 | /* | 268 | /* |
274 | * Exec permission on a regular file is denied if none | 269 | * Exec permission on a regular file is denied if none |
@@ -292,7 +287,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
292 | return retval; | 287 | return retval; |
293 | 288 | ||
294 | return security_inode_permission(inode, | 289 | return security_inode_permission(inode, |
295 | mask & (MAY_READ|MAY_WRITE|MAY_EXEC), nd); | 290 | mask & (MAY_READ|MAY_WRITE|MAY_EXEC)); |
296 | } | 291 | } |
297 | 292 | ||
298 | /** | 293 | /** |
@@ -492,7 +487,7 @@ static int exec_permission_lite(struct inode *inode, | |||
492 | 487 | ||
493 | return -EACCES; | 488 | return -EACCES; |
494 | ok: | 489 | ok: |
495 | return security_inode_permission(inode, MAY_EXEC, nd); | 490 | return security_inode_permission(inode, MAY_EXEC); |
496 | } | 491 | } |
497 | 492 | ||
498 | /* | 493 | /* |
@@ -1692,7 +1687,7 @@ struct file *do_filp_open(int dfd, const char *pathname, | |||
1692 | int will_write; | 1687 | int will_write; |
1693 | int flag = open_to_namei_flags(open_flag); | 1688 | int flag = open_to_namei_flags(open_flag); |
1694 | 1689 | ||
1695 | acc_mode = ACC_MODE(flag); | 1690 | acc_mode = MAY_OPEN | ACC_MODE(flag); |
1696 | 1691 | ||
1697 | /* O_TRUNC implies we need access checks for write permissions */ | 1692 | /* O_TRUNC implies we need access checks for write permissions */ |
1698 | if (flag & O_TRUNC) | 1693 | if (flag & O_TRUNC) |