File 0149-cpu-assert-host-pointer-offset-with.patch of Package qemu.3217
From 54f63358704f11eb9a5b29c230a1097f7e7e33a3 Mon Sep 17 00:00:00 2001
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Wed, 12 Nov 2014 11:44:44 +0200
Subject: [PATCH] cpu: assert host pointer offset within block
Make accesses safer in case we missed some
check somewhere.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amos Kong <akong@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
(cherry picked from commit fd5f3b636788f79843d42188ed843c0416643326)
Signed-off-by: Alexander Graf <agraf@suse.de>
---
include/exec/cpu-all.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 8097763..8df6e20 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -435,6 +435,7 @@ typedef struct RAMBlock {
static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset)
{
+ assert(offset < block->length);
return (char *)block->host + offset;
}