linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ravikiran G Thirumalai <kiran@scalex86.org>
To: akpm@linux-foundation.org
Cc: wli@movementarian.org, mel@csn.ul.ie, linux-mm@kvack.org,
	shai@scalex86.org, linux-kernel@vger.kernel.org
Subject: [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group
Date: Fri, 20 Feb 2009 17:54:57 -0800	[thread overview]
Message-ID: <20090221015457.GA32674@localdomain> (raw)

This is a two patch series to fix a long standing inconsistency with the
mechanism to allow non root users allocate hugetlb shm.  The patch changelog
is self explanatory.  Here's a link to the previous discussion as well:

	http://lkml.org/lkml/2009/2/10/89

---
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>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Wli <wli@movementarian.org>

Index: linux-2.6-tip/fs/hugetlbfs/inode.c
===================================================================
--- linux-2.6-tip.orig/fs/hugetlbfs/inode.c	2009-02-10 13:24:56.000000000 -0800
+++ linux-2.6-tip/fs/hugetlbfs/inode.c	2009-02-10 13:30:05.000000000 -0800
@@ -942,9 +942,7 @@ static struct vfsmount *hugetlbfs_vfsmou
 
 static int can_do_hugetlb_shm(void)
 {
-	return likely(capable(CAP_IPC_LOCK) ||
-			in_group_p(sysctl_hugetlb_shm_group) ||
-			can_do_mlock());
+	return (capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group));
 }
 
 struct file *hugetlb_file_setup(const char *name, size_t size)
@@ -962,9 +960,6 @@ struct file *hugetlb_file_setup(const ch
 	if (!can_do_hugetlb_shm())
 		return ERR_PTR(-EPERM);
 
-	if (!user_shm_lock(size, user))
-		return ERR_PTR(-ENOMEM);
-
 	root = hugetlbfs_vfsmount->mnt_root;
 	quick_string.name = name;
 	quick_string.len = strlen(quick_string.name);
@@ -1002,7 +997,6 @@ out_inode:
 out_dentry:
 	dput(dentry);
 out_shm_unlock:
-	user_shm_unlock(size, user);
 	return ERR_PTR(error);
 }
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2009-02-21  1:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-21  1:54 Ravikiran G Thirumalai [this message]
2009-02-21  1:57 ` [patch 2/2] mm: Reintroduce and deprecate rlimit based access for SHM_HUGETLB Ravikiran G Thirumalai
2009-02-23 11:21   ` Mel Gorman
2009-02-23 11:04 ` [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Mel Gorman
2009-02-23 19:21   ` Ravikiran G Thirumalai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090221015457.GA32674@localdomain \
    --to=kiran@scalex86.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=shai@scalex86.org \
    --cc=wli@movementarian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox