Skip to content

Commit

Permalink
KVM: arm64: Ensure user_mem_abort() return value is initialised
Browse files Browse the repository at this point in the history
If a change in the MMU notifier sequence number forces user_mem_abort()
to return early when attempting to handle a stage-2 fault, we return
uninitialised stack to kvm_handle_guest_abort(), which could potentially
result in the injection of an external abort into the guest or a spurious
return to userspace. Neither or these are what we want to do.

Initialise 'ret' to 0 in user_mem_abort() so that bailing due to a
change in the MMU notrifier sequence number is treated as though the
fault was handled.

Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Reviewed-by: Alexandru Elisei <[email protected]>
Reviewed-by: Gavin Shan <[email protected]>
Cc: Gavin Shan <[email protected]>
Cc: Alexandru Elisei <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
willdeacon authored and Marc Zyngier committed Oct 2, 2020
1 parent b259d13 commit ffd1b63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/arm64/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
struct kvm_memory_slot *memslot, unsigned long hva,
unsigned long fault_status)
{
int ret;
int ret = 0;
bool write_fault, writable, force_pte = false;
bool exec_fault;
bool device = false;
Expand Down

0 comments on commit ffd1b63

Please sign in to comment.