Skip to content

Commit

Permalink
arm/arm64: KVM: Feed initialized memory to MMIO accesses
Browse files Browse the repository at this point in the history
On an MMIO access, we always copy the on-stack buffer info
the shared "run" structure, even if this is a read access.
This ends up leaking up to 8 bytes of uninitialized memory
into userspace, depending on the size of the access.

An obvious fix for this one is to only perform the copy if
this is an actual write.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
  • Loading branch information
Marc Zyngier committed Feb 24, 2016
1 parent 236cf17 commit 1d6a821
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/arm/kvm/mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
run->mmio.is_write = is_write;
run->mmio.phys_addr = fault_ipa;
run->mmio.len = len;
memcpy(run->mmio.data, data_buf, len);
if (is_write)
memcpy(run->mmio.data, data_buf, len);

if (!ret) {
/* We handled the access successfully in the kernel. */
Expand Down

0 comments on commit 1d6a821

Please sign in to comment.