From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>,
Jan Kiszka <jan.kiszka@web.de>,
qemu-devel@nongnu.org, agraf@suse.de, kvm <kvm@vger.kernel.org>,
Paul Mackerras <paulus@samba.org>
Subject: Re: [Qemu-devel] [PATCH] Permit -mem-path without sync mmu
Date: Wed, 10 Aug 2011 12:01:04 +0300 [thread overview]
Message-ID: <4E4248D0.6070209@redhat.com> (raw)
In-Reply-To: <20110810051002.GM23511@yookeroo.fritz.box>
On 08/10/2011 08:10 AM, David Gibson wrote:
> On Mon, Aug 08, 2011 at 11:24:09AM +0300, Avi Kivity wrote:
> > On 08/08/2011 09:03 AM, David Gibson wrote:
> > >Second, if userspace qemu passing hugepages to kvm can cause (host)
> > >kernel memory corruption, that is clearly a host kernel bug. So am I
> > >correct in thinking this is basically just a safety feature if qemu is
> > >run on a buggy kernel.
> >
> > Seems so, yes. 2.6.2[456] are exploitable. We only found out after
> > these were all released.
> >
> > >Presumably this bug was corrected at some
> > >point? Is the presence of the SYNC_MMU feature just being used as a
> > >proxy for "is this kernel recent enough to have the corruption bug
> > >fixed"?
> >
> > SYNC_MMU actually fixes the bug.
>
> Ah, so SYNC_MMU fixed the bug on x86, and all the other archs without
> SYNC_MMU were left with a serious memory corruption bug, under a
> userspace bandaid. Thanks for that.
Unfortunately it's all too easy to ignore non-x86.
It may be considered that not implementing SYNC_MMU is a bug in itself,
as it allows userspace to pin arbitrary amounts of user memory. At
least on x86 we had shrinkers that kill off shadow page tables under
memory pressure, unpinning memory, but I don't see it on ppc.
> As I understand the bug that causes the problem, it's because removing
> all the hugepage VMAs from userspace will cause the inode (and
> therefore address_space) for the hugepage file to be freed, but not
> the pages (because another ref is held by kvm). Then when kvm
> releases the pages, the address_space will be touched after free from
> free_huge_page().
>
> This would seem to be a genuine bug in the hugepage code, which has
> just been hidden by SYNC_MMU. It should be quite easy to fix - the
> mapping is only stored in the struct page to get to the hugetlbfs
> superblock, so we could just store a direct superblock pointer
> instead, and bump it's refcount when we put that in the page private
> pointer.
>
> But then I'm not sure how qemu would detect that it's on a kernel
> where the bug is fixed and allow -mem-path to be used again. Any
> ideas?
If it's just a kernel bug, the fix belongs in the kernel, not in qemu.
We used to have KVM_CAPs to declare this sort of thing
(KVM_CAP_HUGETLBFS_WORKS_EVEN_WITHOUT_SYNC_MMU) but I don't think it was
a good idea.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-08-10 9:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1312516970-26606-1-git-send-email-david@gibson.dropbear.id.au>
2011-08-05 6:16 ` [PATCH] Permit -mem-path without sync mmu Jan Kiszka
2011-08-05 15:30 ` Marcelo Tosatti
2011-08-08 6:03 ` David Gibson
2011-08-08 8:24 ` Avi Kivity
2011-08-10 5:10 ` David Gibson
2011-08-10 9:01 ` Avi Kivity [this message]
2011-08-11 6:09 ` [Qemu-devel] " David Gibson
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=4E4248D0.6070209@redhat.com \
--to=avi@redhat.com \
--cc=agraf@suse.de \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=paulus@samba.org \
--cc=qemu-devel@nongnu.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