From: CAI Qian <caiqian@redhat.com>
To: Eric B Munson <emunson@mgebm.net>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, mel@csn.ul.ie,
mhocko@suse.cz, akpm@linux-foundation.org
Subject: Re: [PATCH V2] Do not allow pagesize >= MAX_ORDER pool adjustment
Date: Wed, 5 Jan 2011 21:51:44 -0500 (EST) [thread overview]
Message-ID: <2116525479.149526.1294282304830.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <1294259397-15553-1-git-send-email-emunson@mgebm.net>
----- Original Message -----
> Huge pages with order >= MAX_ORDER must be allocated at boot via
> the kernel command line, they cannot be allocated or freed once
> the kernel is up and running. Currently we allow values to be
> written to the sysfs and sysctl files controling pool size for these
> huge page sizes. This patch makes the store functions for nr_hugepages
> and nr_overcommit_hugepages return -EINVAL when the pool for a
> page size >= MAX_ORDER is changed.
>
> Reported-by: CAI Qian <caiqian@redhat.com>
>
> Signed-off-by: Eric B Munson <emunson@mgebm.net>
> ---
> Changes from V1:
> Add check to sysctl handler
>
> mm/hugetlb.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 5cb71a9..15bd633 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1443,6 +1443,12 @@ static ssize_t nr_hugepages_store_common(bool
> obey_mempolicy,
> return -EINVAL;
>
> h = kobj_to_hstate(kobj, &nid);
> +
> + if (h->order >= MAX_ORDER) {
> + NODEMASK_FREE(nodes_allowed);
> + return -EINVAL;
> + }
> +
> if (nid == NUMA_NO_NODE) {
> /*
> * global hstate attribute
> @@ -1517,6 +1523,9 @@ static ssize_t
> nr_overcommit_hugepages_store(struct kobject *kobj,
> unsigned long input;
> struct hstate *h = kobj_to_hstate(kobj, NULL);
>
> + if (h->order >= MAX_ORDER)
> + return -EINVAL;
> +
> err = strict_strtoul(buf, 10, &input);
> if (err)
> return -EINVAL;
> @@ -1926,6 +1935,9 @@ static int hugetlb_sysctl_handler_common(bool
> obey_mempolicy,
> if (!write)
> tmp = h->max_huge_pages;
>
> + if (write && h->order >= MAX_ORDER)
> + return -EINVAL;
> +
> table->data = &tmp;
> table->maxlen = sizeof(unsigned long);
> proc_doulongvec_minmax(table, write, buffer, length, ppos);
> --
> 1.7.1
I believe this is still not enough. hugetlb_overcommit_handler() does not use
hugetlb_sysctl_handler_common() which also need this. Otherwise, people can
still abuse /proc/sys/vm/nr_overcommit_pages.
CAI Qian
--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2011-01-06 2:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-05 20:29 [PATCH V2] Do not allow pagesize >= MAX_ORDER pool adjustment Eric B Munson
2011-01-05 21:11 ` Andrew Morton
2011-01-06 6:54 ` CAI Qian
2011-01-06 2:51 ` CAI Qian [this message]
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=2116525479.149526.1294282304830.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com \
--to=caiqian@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=emunson@mgebm.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mhocko@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).