diff options
author | Ravikiran G Thirumalai <kiran@scalex86.org> | 2009-03-31 18:19:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-01 11:59:12 -0400 |
commit | 8a0bdec194c21c8fdef840989d0d7b742bb5d4bc (patch) | |
tree | 0185e4cfa29f18a2f7b9d297e049a1de5314d0ec /fs/hugetlbfs | |
parent | e3a7cca1ef4c1af9b0acef9bd66eff6582a737b5 (diff) |
mm: fix SHM_HUGETLB to work with users in hugetlb_shm_group
Fix hugetlb subsystem so that non root users belonging to
hugetlb_shm_group can actually allocate hugetlb backed shm.
Currently non root users cannot even map one large page using SHM_HUGETLB
when they belong to the gid in /proc/sys/vm/hugetlb_shm_group. This is
because allocation size is verified against RLIMIT_MEMLOCK resource limit
even if the user belongs to hugetlb_shm_group.
This patch
1. Fixes hugetlb subsystem so that users with CAP_IPC_LOCK and users
belonging to hugetlb_shm_group don't need to be restricted with
RLIMIT_MEMLOCK resource limits
2. This patch also disables mlock based rlimit checking (which will
be reinstated and marked deprecated in a subsequent patch).
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Reviewed-by: Mel Gorman <mel@csn.ul.ie>
Cc: William Lee Irwin III <wli@holomorphy.com>
Cc: Adam Litke <agl@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hugetlbfs')
-rw-r--r-- | fs/hugetlbfs/inode.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9b800d97a68..bc56df8ce00 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -943,9 +943,7 @@ static struct vfsmount *hugetlbfs_vfsmount; | |||
943 | 943 | ||
944 | static int can_do_hugetlb_shm(void) | 944 | static int can_do_hugetlb_shm(void) |
945 | { | 945 | { |
946 | return likely(capable(CAP_IPC_LOCK) || | 946 | return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group); |
947 | in_group_p(sysctl_hugetlb_shm_group) || | ||
948 | can_do_mlock()); | ||
949 | } | 947 | } |
950 | 948 | ||
951 | struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) | 949 | struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) |
@@ -963,9 +961,6 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) | |||
963 | if (!can_do_hugetlb_shm()) | 961 | if (!can_do_hugetlb_shm()) |
964 | return ERR_PTR(-EPERM); | 962 | return ERR_PTR(-EPERM); |
965 | 963 | ||
966 | if (!user_shm_lock(size, user)) | ||
967 | return ERR_PTR(-ENOMEM); | ||
968 | |||
969 | root = hugetlbfs_vfsmount->mnt_root; | 964 | root = hugetlbfs_vfsmount->mnt_root; |
970 | quick_string.name = name; | 965 | quick_string.name = name; |
971 | quick_string.len = strlen(quick_string.name); | 966 | quick_string.len = strlen(quick_string.name); |
@@ -1004,7 +999,6 @@ out_inode: | |||
1004 | out_dentry: | 999 | out_dentry: |
1005 | dput(dentry); | 1000 | dput(dentry); |
1006 | out_shm_unlock: | 1001 | out_shm_unlock: |
1007 | user_shm_unlock(size, user); | ||
1008 | return ERR_PTR(error); | 1002 | return ERR_PTR(error); |
1009 | } | 1003 | } |
1010 | 1004 | ||