The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Dave Hansen <haveblue@us.ibm.com>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Anton Blanchard <anton@samba.org>,
	Paul Mackerras <paulus@samba.org>,
	PPC64 External List <linuxppc64-dev@lists.linuxppc.org>
Subject: Re: RFC: COW for hugepages
Date: Thu, 8 Apr 2004 13:22:27 +1000	[thread overview]
Message-ID: <20040408032227.GB29551@zax> (raw)
In-Reply-To: <1081351270.9207.3551.camel@nighthawk>

On Wed, Apr 07, 2004 at 08:21:11AM -0700, Dave Hansen wrote:
> On Wed, 2004-04-07 at 00:42, David Gibson wrote:
> > +	/* XXX are there races with checking cpu_vm_mask? - Anton */
> > +	tmp = cpumask_of_cpu(smp_processor_id());
> > +	if (cpus_equal(vma->vm_mm->cpu_vm_mask, tmp))
> > +		local = 1;
> > +
> > +	cow = (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
> 
> You're under the pagetable lock for that mm, so you at least don't have
> to worry about preemption.  But, that definitely at least deserves a
> comment on why you didn't disable preemption.
> 
> Also, for racing with other users of cpu_vm_mask, there aren't any other
> users that clear other cpus' bits other than initialization.  

Yes.  That comment was actually copied from code in the analagous
normal page path (from where it has since been removed).  I've altered
it appropriately.

> One thing that's I didn't see in this patch is any check of capabilities
> or permissions.  What if a privileged user sets up a single page huge
> page, then does a setuid() to a lower privilege level?  Is that not a
> valid way to get hugetlb pages to an unprivileged user?  That other user
> is free to go fork and write to the pages to their heart's content,
> consuming as many huge pages as are present in the system.

That seems to me like a "don't do that" situation (you can avoid the
security problem by only giving MAP_SHARED pages to the unprivileged
process).  I don't see a better way to solve this without implementing
some sort of rlimit system for hugepages, which seems like overkill:
As far as I can tell all the real applications (huge databases, HPC,
benchmarks) for hugepages tend to be the sorts of cases where the
hugepage-using program is the only thing you really care about on the
system .

> It looks to me like dup_mmap() drops VM_LOCKED on mlock()'d VMAs at fork
> time.  Do we need to do the same for hugetlb pages?  

Given that all huge pages are unswappable and therefore effectively
mlock()ed, I don't think so.

-- 
David Gibson			| For every complex problem there is a
david AT gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson

      reply	other threads:[~2004-04-08  3:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-07  7:42 RFC: COW for hugepages David Gibson
2004-04-07  7:53 ` Andrew Morton
2004-04-07  8:03   ` Anton Blanchard
2004-04-07  8:29   ` Benjamin Herrenschmidt
2004-04-08  1:57     ` David Gibson
2004-04-07  9:00 ` Zoltan Menyhart
2004-04-08  1:53   ` David Gibson
2004-04-08 11:10     ` Zoltan Menyhart
2004-04-08 14:19       ` David Gibson
2004-04-07 12:34 ` Andi Kleen
2004-04-07 14:27   ` Anton Blanchard
2004-04-07 14:50     ` Andi Kleen
2004-04-07 21:41       ` Anton Blanchard
2004-04-07 21:47         ` Andi Kleen
2004-04-08  1:11   ` Benjamin Herrenschmidt
2004-04-08  2:01     ` Andrew Morton
2004-04-08  3:09       ` David Gibson
2004-04-08  3:24         ` Andrew Morton
2004-04-08  3:56           ` David Gibson
2004-04-08  1:50   ` David Gibson
2004-04-07 15:21 ` Dave Hansen
2004-04-08  3:22   ` David Gibson [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=20040408032227.GB29551@zax \
    --to=david@gibson.dropbear.id.au \
    --cc=akpm@osdl.org \
    --cc=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc64-dev@lists.linuxppc.org \
    --cc=paulus@samba.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