From: aglitke <agl@us.ibm.com>
To: ciju@linux.vnet.ibm.com
Cc: linux-kernel@vger.kernel.org, wli@holomorphy.com
Subject: Re: [RFC] [PATCH] hugetlbfs :shmget with SHM_HUGETLB only works as root
Date: Wed, 14 Nov 2007 09:31:41 -0600 [thread overview]
Message-ID: <1195054301.18047.20.camel@localhost.localdomain> (raw)
In-Reply-To: <473B0317.6010603@linux.vnet.ibm.com>
Hi Ciju:
I am still not exactly sure why this patch is needed. As I read
user_shm_lock():
> lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
> if (lock_limit == RLIM_INFINITY)
> allowed = 1;
> lock_limit >>= PAGE_SHIFT;
> spin_lock(&shmlock_user_lock);
> if (!allowed &&
> locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK))
> goto out;
... if the user's locked limit (ulimit -l) is set to unlimited, allowed
(above) is set to 1. In that case, the second part of that if() is
bypassed, and the function grants permission. Therefore, the easy
solution is to make sure your user's lock_limit is RLIM_INFINITY.
On Wed, 2007-11-14 at 19:45 +0530, Ciju Rajan K wrote:
<snip>
> @@ -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))))
This will allow any user in hugetlb_shm_group to make unlimited use of
huge page shm segments _and_ normal page shm segments. Definitely not
what you want.
> +#else
> if (!allowed &&
> locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK))
> +#endif
> goto out;
> get_uid(user);
> user->locked_shm += locked;
>
Please don't add new #ifdefs into .c files, headers only.
--
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center
next prev parent reply other threads:[~2007-11-14 15:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-14 14:15 [RFC] [PATCH] hugetlbfs :shmget with SHM_HUGETLB only works as root Ciju Rajan K
2007-11-14 15:31 ` aglitke [this message]
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=1195054301.18047.20.camel@localhost.localdomain \
--to=agl@us.ibm.com \
--cc=ciju@linux.vnet.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