diff options
Diffstat (limited to 'fs/hugetlbfs/inode.c')
-rw-r--r-- | fs/hugetlbfs/inode.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9b800d97a687..23a3c76711e0 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -943,14 +943,13 @@ 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) |
952 | { | 950 | { |
953 | int error = -ENOMEM; | 951 | int error = -ENOMEM; |
952 | int unlock_shm = 0; | ||
954 | struct file *file; | 953 | struct file *file; |
955 | struct inode *inode; | 954 | struct inode *inode; |
956 | struct dentry *dentry, *root; | 955 | struct dentry *dentry, *root; |
@@ -960,11 +959,14 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) | |||
960 | if (!hugetlbfs_vfsmount) | 959 | if (!hugetlbfs_vfsmount) |
961 | return ERR_PTR(-ENOENT); | 960 | return ERR_PTR(-ENOENT); |
962 | 961 | ||
963 | if (!can_do_hugetlb_shm()) | 962 | if (!can_do_hugetlb_shm()) { |
964 | return ERR_PTR(-EPERM); | 963 | if (user_shm_lock(size, user)) { |
965 | 964 | unlock_shm = 1; | |
966 | if (!user_shm_lock(size, user)) | 965 | WARN_ONCE(1, |
967 | return ERR_PTR(-ENOMEM); | 966 | "Using mlock ulimits for SHM_HUGETLB deprecated\n"); |
967 | } else | ||
968 | return ERR_PTR(-EPERM); | ||
969 | } | ||
968 | 970 | ||
969 | root = hugetlbfs_vfsmount->mnt_root; | 971 | root = hugetlbfs_vfsmount->mnt_root; |
970 | quick_string.name = name; | 972 | quick_string.name = name; |
@@ -1004,7 +1006,8 @@ out_inode: | |||
1004 | out_dentry: | 1006 | out_dentry: |
1005 | dput(dentry); | 1007 | dput(dentry); |
1006 | out_shm_unlock: | 1008 | out_shm_unlock: |
1007 | user_shm_unlock(size, user); | 1009 | if (unlock_shm) |
1010 | user_shm_unlock(size, user); | ||
1008 | return ERR_PTR(error); | 1011 | return ERR_PTR(error); |
1009 | } | 1012 | } |
1010 | 1013 | ||