From: Ciju Rajan K <ciju@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: wli@holomorphy.com, agl@us.ibm.com
Subject: [RFC] [PATCH] hugetlbfs :shmget with SHM_HUGETLB only works as root
Date: Wed, 14 Nov 2007 19:45:51 +0530 [thread overview]
Message-ID: <473B0317.6010603@linux.vnet.ibm.com> (raw)
When a normal user is trying to allocate huge pages using shmget(), the
user is not able to get the memory even if the gid is present in
/proc/sys/vm/hugetlb_shm_group. The function user_shm_lock() is not
successful. The user does not have the capability to perform a
CAP_IPC_LOCK. A check is added here to see whether the gid is present in
hugetlb_shm_group. Please review the patch.
Signed-off-by: Ciju Rajan (ciju@linux.vnet.ibm.com)
---
--- linux-2.6.23/mm/mlock.c.orig 2007-11-14 17:35:02.000000000 +0530
+++ linux-2.6.23/mm/mlock.c 2007-11-14 17:50:31.000000000 +0530
@@ -8,6 +8,7 @@
#include <linux/capability.h>
#include <linux/mman.h>
#include <linux/mm.h>
+#include <linux/hugetlb.h>
#include <linux/mempolicy.h>
#include <linux/syscalls.h>
#include <linux/sched.h>
@@ -248,8 +249,14 @@ int user_shm_lock(size_t size, struct us
allowed = 1;
lock_limit >>= PAGE_SHIFT;
spin_lock(&shmlock_user_lock);
+#ifdef CONFIG_HUGETLB_PAGE
+ if (!allowed &&
+ locked + user->locked_shm > lock_limit &&
+ (!(capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group))))
+#else
if (!allowed &&
locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK))
+#endif
goto out;
get_uid(user);
user->locked_shm += locked;
next reply other threads:[~2007-11-14 14:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-14 14:15 Ciju Rajan K [this message]
2007-11-14 15:31 ` [RFC] [PATCH] hugetlbfs :shmget with SHM_HUGETLB only works as root aglitke
2007-11-14 22:00 ` William Lee Irwin III
2007-11-29 18:32 ` Ciju Rajan K
2007-11-29 23:11 ` William Lee Irwin III
2008-01-29 14:58 ` Ciju Rajan K
2008-01-30 9:32 ` Ciju Rajan K
2007-11-16 13:59 ` Ciju Rajan K
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=473B0317.6010603@linux.vnet.ibm.com \
--to=ciju@linux.vnet.ibm.com \
--cc=agl@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wli@holomorphy.com \
/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