aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-20 19:57:03 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:43:32 -0400
commit4ad5abb3d01a2c10854969b00982fadb130784a6 (patch)
tree757ad9baeab65982e8c8ed61b222c8969b3dbf43 /fs/namei.c
parentd594e7ec4da6c1a527dea4965eee37cd785792b8 (diff)
no reason to keep exec_permission() separate now
cache footprint alone makes it a bad idea... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 758bae739305..b3c1a975c834 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -311,43 +311,6 @@ int inode_permission(struct inode *inode, int mask)
311} 311}
312 312
313/** 313/**
314 * exec_permission - check for right to do lookups in a given directory
315 * @inode: inode to check permission on
316 * @mask: MAY_EXEC and possibly MAY_NOT_BLOCK flags.
317 *
318 * Short-cut version of inode_permission(), for calling on directories
319 * during pathname resolution. Combines parts of inode_permission()
320 * and generic_permission(), and tests ONLY for MAY_EXEC permission.
321 *
322 * If appropriate, check DAC only. If not appropriate, or
323 * short-cut DAC fails, then call ->permission() to do more
324 * complete permission check.
325 */
326static inline int exec_permission(struct inode *inode, int mask)
327{
328 int ret;
329 struct user_namespace *ns = inode_userns(inode);
330
331 if (inode->i_op->permission) {
332 ret = inode->i_op->permission(inode, mask);
333 if (likely(!ret))
334 goto ok;
335 } else {
336 ret = acl_permission_check(inode, mask);
337 if (likely(!ret))
338 goto ok;
339 if (ret != -EACCES)
340 return ret;
341 if (ns_capable(ns, CAP_DAC_OVERRIDE) ||
342 ns_capable(ns, CAP_DAC_READ_SEARCH))
343 goto ok;
344 }
345 return ret;
346ok:
347 return security_inode_permission(inode, mask);
348}
349
350/**
351 * path_get - get a reference to a path 314 * path_get - get a reference to a path
352 * @path: path to get the reference to 315 * @path: path to get the reference to
353 * 316 *
@@ -1220,13 +1183,13 @@ retry:
1220static inline int may_lookup(struct nameidata *nd) 1183static inline int may_lookup(struct nameidata *nd)
1221{ 1184{
1222 if (nd->flags & LOOKUP_RCU) { 1185 if (nd->flags & LOOKUP_RCU) {
1223 int err = exec_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK); 1186 int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
1224 if (err != -ECHILD) 1187 if (err != -ECHILD)
1225 return err; 1188 return err;
1226 if (unlazy_walk(nd, NULL)) 1189 if (unlazy_walk(nd, NULL))
1227 return -ECHILD; 1190 return -ECHILD;
1228 } 1191 }
1229 return exec_permission(nd->inode, MAY_EXEC); 1192 return inode_permission(nd->inode, MAY_EXEC);
1230} 1193}
1231 1194
1232static inline int handle_dots(struct nameidata *nd, int type) 1195static inline int handle_dots(struct nameidata *nd, int type)
@@ -1501,7 +1464,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1501 if (!S_ISDIR(dentry->d_inode->i_mode)) 1464 if (!S_ISDIR(dentry->d_inode->i_mode))
1502 goto fput_fail; 1465 goto fput_fail;
1503 1466
1504 retval = exec_permission(dentry->d_inode, MAY_EXEC); 1467 retval = inode_permission(dentry->d_inode, MAY_EXEC);
1505 if (retval) 1468 if (retval)
1506 goto fput_fail; 1469 goto fput_fail;
1507 } 1470 }
@@ -1658,7 +1621,7 @@ static struct dentry *__lookup_hash(struct qstr *name,
1658 struct dentry *dentry; 1621 struct dentry *dentry;
1659 int err; 1622 int err;
1660 1623
1661 err = exec_permission(inode, MAY_EXEC); 1624 err = inode_permission(inode, MAY_EXEC);
1662 if (err) 1625 if (err)
1663 return ERR_PTR(err); 1626 return ERR_PTR(err);
1664 1627