* [PATCH] qemu-kvm: Work around borken MSR_GET_INDEX_LIST
@ 2009-07-02 19:50 Jan Kiszka
2009-07-06 7:50 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2009-07-02 19:50 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 920 bytes --]
Allocate enough memory for KVM_GET_MSR_INDEX_LIST as older kernels shot
far beyond their limits, corrupting user space memory.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
qemu-kvm-x86.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index d6735c1..e528acb 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -349,7 +349,10 @@ struct kvm_msr_list *kvm_get_msr_list(kvm_context_t kvm)
r = ioctl(kvm->fd, KVM_GET_MSR_INDEX_LIST, &sizer);
if (r == -1 && errno != E2BIG)
return NULL;
- msrs = malloc(sizeof *msrs + sizer.nmsrs * sizeof *msrs->indices);
+ /* Old kernel modules had a bug and could write beyond the provided
+ memory. Allocate at least a safe amount of 1K. */
+ msrs = malloc(MAX(1024, sizeof(*msrs) +
+ sizer.nmsrs * sizeof(*msrs->indices)));
if (!msrs) {
errno = ENOMEM;
return NULL;
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] qemu-kvm: Work around borken MSR_GET_INDEX_LIST
2009-07-02 19:50 [PATCH] qemu-kvm: Work around borken MSR_GET_INDEX_LIST Jan Kiszka
@ 2009-07-06 7:50 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2009-07-06 7:50 UTC (permalink / raw)
To: Jan Kiszka; +Cc: kvm-devel
On 07/02/2009 10:50 PM, Jan Kiszka wrote:
> Allocate enough memory for KVM_GET_MSR_INDEX_LIST as older kernels shot
> far beyond their limits, corrupting user space memory.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-06 7:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-02 19:50 [PATCH] qemu-kvm: Work around borken MSR_GET_INDEX_LIST Jan Kiszka
2009-07-06 7:50 ` Avi Kivity
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).