From 9572f94eb75f27bed9ba6d147e06cfa9d6b2af76 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 10 Nov 2017 10:08:25 +0100 Subject: [PATCH 1/2] exec: use qemu_ram_ptr_length to access guest ram RH-Author: Paolo Bonzini Message-id: <20171110100825.6843-1-pbonzini@redhat.com> Patchwork-id: 77646 O-Subject: [RHEL7.4.z qemu-kvm-rhev/qemu-kvm-ma PATCH] exec: use qemu_ram_ptr_length to access guest ram Bugzilla: 1472185 RH-Acked-by: Maxime Coquelin RH-Acked-by: Laszlo Ersek RH-Acked-by: Peter Xu From: Prasad J Pandit Bugzilla: 1472185 Brew build: 14525190 When accessing guest's ram block during DMA operation, use 'qemu_ram_ptr_length' to get ram block pointer. It ensures that DMA operation of given length is possible; And avoids any OOB memory access situations. Reported-by: Alex Signed-off-by: Prasad J Pandit Message-Id: <20170712123840.29328-1-ppandit@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit 04bf2526ce87f21b32c9acba1c5518708c243ad0) [Introduced by commit 149f54b53b ("memory: add address_space_translate", 2013-05-29) in 1.6.0, therefore qemu-kvm is not affected. - Paolo] Signed-off-by: Miroslav Rezanina --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index a9e4bfc..d773a70 100644 --- a/exec.c +++ b/exec.c @@ -2800,7 +2800,7 @@ static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr, } } else { /* RAM case */ - ptr = qemu_map_ram_ptr(mr->ram_block, addr1); + ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l); memcpy(ptr, buf, l); invalidate_and_set_dirty(mr, addr1, l); } @@ -2891,7 +2891,7 @@ MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr, } } else { /* RAM case */ - ptr = qemu_map_ram_ptr(mr->ram_block, addr1); + ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l); memcpy(buf, ptr, l); } -- 1.8.3.1