From: Prasad J Pandit Date: Wed, 12 Jul 2017 12:38:40 +0000 (+0530) Subject: exec: use qemu_ram_ptr_length to access guest ram X-Git-Tag: v2.9.1~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15d8f91446fe922ccabb20b7e4ab4b32d8f7b5a7;p=thirdparty%2Fqemu.git exec: use qemu_ram_ptr_length to access guest ram 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) Signed-off-by: Michael Roth --- diff --git a/exec.c b/exec.c index c97ef4a8da4..72d636a4fb4 100644 --- a/exec.c +++ b/exec.c @@ -2765,7 +2765,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); } @@ -2856,7 +2856,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); }