aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-20 18:59:02 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:43:18 -0400
commit1fc0f78ca9f311c6277e2f1b7655bb4d43ceb311 (patch)
tree9c6a5879558b7a189f94eae97ac80268e63fe29b
parent178ea73521d64ba41d7aa5488fb9f549c6d4507d (diff)
->permission() sanitizing: MAY_NOT_BLOCK
Duplicate the flags argument into mask bitmap. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/namei.c7
-rw-r--r--fs/proc/proc_sysctl.c2
-rw-r--r--include/linux/fs.h1
3 files changed, 7 insertions, 3 deletions
diff --git a/fs/namei.c b/fs/namei.c
index c5af0f37e67d..723a3fe4bc40 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -318,13 +318,16 @@ static inline int exec_permission(struct inode *inode, unsigned int flags)
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;
321 324
322 if (inode->i_op->permission) { 325 if (inode->i_op->permission) {
323 ret = inode->i_op->permission(inode, MAY_EXEC, flags); 326 ret = inode->i_op->permission(inode, mask, flags);
324 if (likely(!ret)) 327 if (likely(!ret))
325 goto ok; 328 goto ok;
326 } else { 329 } else {
327 ret = acl_permission_check(inode, MAY_EXEC, flags); 330 ret = acl_permission_check(inode, mask, flags);
328 if (likely(!ret)) 331 if (likely(!ret))
329 goto ok; 332 goto ok;
330 if (ret != -EACCES) 333 if (ret != -EACCES)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index d167de365a8d..349b22f434d8 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -316,7 +316,7 @@ static int proc_sys_permission(struct inode *inode, int mask,unsigned int flags)
316 if (!table) /* global root - r-xr-xr-x */ 316 if (!table) /* global root - r-xr-xr-x */
317 error = mask & MAY_WRITE ? -EACCES : 0; 317 error = mask & MAY_WRITE ? -EACCES : 0;
318 else /* Use the permissions on the sysctl table entry */ 318 else /* Use the permissions on the sysctl table entry */
319 error = sysctl_perm(head->root, table, mask); 319 error = sysctl_perm(head->root, table, mask & ~MAY_NOT_BLOCK);
320 320
321 sysctl_head_finish(head); 321 sysctl_head_finish(head);
322 return error; 322 return error;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 0c15d5e459d5..60c1fe65bb2d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -63,6 +63,7 @@ struct inodes_stat_t {
63#define MAY_ACCESS 16 63#define MAY_ACCESS 16
64#define MAY_OPEN 32 64#define MAY_OPEN 32
65#define MAY_CHDIR 64 65#define MAY_CHDIR 64
66#define MAY_NOT_BLOCK 128 /* called from RCU mode, don't block */
66 67
67/* 68/*
68 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond 69 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond