aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-20 19:48:41 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:43:29 -0400
commiteecdd358b467405a084d400d5ec571bbdbfe97a3 (patch)
tree357332873b909a19964e77dbae3c4aed5c100dc6 /fs
parentcf1dd1dae851ce5765cda5de16aa965eef7c2dbf (diff)
->permission() sanitizing: don't pass flags to exec_permission()
pass mask instead; kill security_inode_exec_permission() since we can use security_inode_permission() instead. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/namei.c b/fs/namei.c
index c5c382620a86..21eba95368f2 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -304,7 +304,7 @@ int inode_permission(struct inode *inode, int mask)
304/** 304/**
305 * exec_permission - check for right to do lookups in a given directory 305 * exec_permission - check for right to do lookups in a given directory
306 * @inode: inode to check permission on 306 * @inode: inode to check permission on
307 * @flags: IPERM_FLAG_ flags. 307 * @mask: MAY_EXEC and possibly MAY_NOT_BLOCK flags.
308 * 308 *
309 * Short-cut version of inode_permission(), for calling on directories 309 * Short-cut version of inode_permission(), for calling on directories
310 * during pathname resolution. Combines parts of inode_permission() 310 * during pathname resolution. Combines parts of inode_permission()
@@ -314,13 +314,10 @@ int inode_permission(struct inode *inode, int mask)
314 * short-cut DAC fails, then call ->permission() to do more 314 * short-cut DAC fails, then call ->permission() to do more
315 * complete permission check. 315 * complete permission check.
316 */ 316 */
317static inline int exec_permission(struct inode *inode, unsigned int flags) 317static inline int exec_permission(struct inode *inode, int mask)
318{ 318{
319 int ret; 319 int ret;
320 struct user_namespace *ns = inode_userns(inode); 320 struct user_namespace *ns = inode_userns(inode);
321 int mask = MAY_EXEC;
322 if (flags & IPERM_FLAG_RCU)
323 mask |= MAY_NOT_BLOCK;
324 321
325 if (inode->i_op->permission) { 322 if (inode->i_op->permission) {
326 ret = inode->i_op->permission(inode, mask); 323 ret = inode->i_op->permission(inode, mask);
@@ -338,7 +335,7 @@ static inline int exec_permission(struct inode *inode, unsigned int flags)
338 } 335 }
339 return ret; 336 return ret;
340ok: 337ok:
341 return security_inode_exec_permission(inode, flags); 338 return security_inode_permission(inode, mask);
342} 339}
343 340
344/** 341/**
@@ -1214,13 +1211,13 @@ retry:
1214static inline int may_lookup(struct nameidata *nd) 1211static inline int may_lookup(struct nameidata *nd)
1215{ 1212{
1216 if (nd->flags & LOOKUP_RCU) { 1213 if (nd->flags & LOOKUP_RCU) {
1217 int err = exec_permission(nd->inode, IPERM_FLAG_RCU); 1214 int err = exec_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
1218 if (err != -ECHILD) 1215 if (err != -ECHILD)
1219 return err; 1216 return err;
1220 if (unlazy_walk(nd, NULL)) 1217 if (unlazy_walk(nd, NULL))
1221 return -ECHILD; 1218 return -ECHILD;
1222 } 1219 }
1223 return exec_permission(nd->inode, 0); 1220 return exec_permission(nd->inode, MAY_EXEC);
1224} 1221}
1225 1222
1226static inline int handle_dots(struct nameidata *nd, int type) 1223static inline int handle_dots(struct nameidata *nd, int type)
@@ -1495,7 +1492,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1495 if (!S_ISDIR(dentry->d_inode->i_mode)) 1492 if (!S_ISDIR(dentry->d_inode->i_mode))
1496 goto fput_fail; 1493 goto fput_fail;
1497 1494
1498 retval = exec_permission(dentry->d_inode, 0); 1495 retval = exec_permission(dentry->d_inode, MAY_EXEC);
1499 if (retval) 1496 if (retval)
1500 goto fput_fail; 1497 goto fput_fail;
1501 } 1498 }
@@ -1652,7 +1649,7 @@ static struct dentry *__lookup_hash(struct qstr *name,
1652 struct dentry *dentry; 1649 struct dentry *dentry;
1653 int err; 1650 int err;
1654 1651
1655 err = exec_permission(inode, 0); 1652 err = exec_permission(inode, MAY_EXEC);
1656 if (err) 1653 if (err)
1657 return ERR_PTR(err); 1654 return ERR_PTR(err);
1658 1655