Skip to content

Commit

Permalink
hugetlbfs: do not call user_shm_lock() for MAP_HUGETLB fix
Browse files Browse the repository at this point in the history
Commit 6bfde05 ("hugetlbfs: allow the creation of files suitable for
MAP_PRIVATE on the vfs internal mount") altered can_do_hugetlb_shm() to
check if a file is being created for shared memory or mmap().  If this
returns false, we then unconditionally call user_shm_lock() triggering a
warning.  This block should never be entered for MAP_HUGETLB.  This
patch partially reverts the problem and fixes the check.

Signed-off-by: Eric B Munson <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Adam Litke <[email protected]>
Cc: David Gibson <[email protected]>
Cc: Lee Schermerhorn <[email protected]>
Cc: Nick Piggin <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
gormanm authored and torvalds committed Sep 24, 2009
1 parent 2c6854f commit ef1ff6b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,15 +936,9 @@ static struct file_system_type hugetlbfs_fs_type = {

static struct vfsmount *hugetlbfs_vfsmount;

static int can_do_hugetlb_shm(int creat_flags)
static int can_do_hugetlb_shm(void)
{
if (creat_flags != HUGETLB_SHMFS_INODE)
return 0;
if (capable(CAP_IPC_LOCK))
return 1;
if (in_group_p(sysctl_hugetlb_shm_group))
return 1;
return 0;
return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
}

struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
Expand All @@ -960,7 +954,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
if (!hugetlbfs_vfsmount)
return ERR_PTR(-ENOENT);

if (!can_do_hugetlb_shm(creat_flags)) {
if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) {
*user = current_user();
if (user_shm_lock(size, *user)) {
WARN_ONCE(1,
Expand Down

0 comments on commit ef1ff6b

Please sign in to comment.