linux-stable/arch/arm64/kvm
Dave Martin df205b5c63 KVM: arm64: Filter out invalid core register IDs in KVM_GET_REG_LIST
Since commit d26c25a9d1 ("arm64: KVM: Tighten guest core register
access from userspace"), KVM_{GET,SET}_ONE_REG rejects register IDs
that do not correspond to a single underlying architectural register.

KVM_GET_REG_LIST was not changed to match however: instead, it
simply yields a list of 32-bit register IDs that together cover the
whole kvm_regs struct.  This means that if userspace tries to use
the resulting list of IDs directly to drive calls to KVM_*_ONE_REG,
some of those calls will now fail.

This was not the intention.  Instead, iterating KVM_*_ONE_REG over
the list of IDs returned by KVM_GET_REG_LIST should be guaranteed
to work.

This patch fixes the problem by splitting validate_core_offset()
into a backend core_reg_size_from_offset() which does all of the
work except for checking that the size field in the register ID
matches, and kvm_arm_copy_reg_indices() and num_core_regs() are
converted to use this to enumerate the valid offsets.

kvm_arm_copy_reg_indices() now also sets the register ID size field
appropriately based on the value returned, so the register ID
supplied to userspace is fully qualified for use with the register
access ioctls.

Cc: stable@vger.kernel.org
Fixes: d26c25a9d1 ("arm64: KVM: Tighten guest core register access from userspace")
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
2019-06-12 15:53:55 +01:00
..
hyp KVM: arm/arm64: Move cc/it checks under hyp's Makefile to avoid instrumentation 2019-05-24 14:53:20 +01:00
debug.c arm/arm64: KVM: Introduce kvm_call_hyp_ret() 2019-02-19 21:05:24 +00:00
fpsimd.c KVM: arm64/sve: Context switch the SVE registers 2019-03-29 14:41:53 +00:00
guest.c KVM: arm64: Filter out invalid core register IDs in KVM_GET_REG_LIST 2019-06-12 15:53:55 +01:00
handle_exit.c KVM: arm/arm64: Context-switch ptrauth registers 2019-04-24 15:30:40 +01:00
hyp-init.S arm64: KVM: Enable Common Not Private translations 2018-09-18 12:03:34 +01:00
hyp.S arm64: KVM: Drop VHE-specific HYP call stub 2019-02-19 21:05:28 +00:00
inject_fault.c arm/arm64: KVM: Add KVM_GET/SET_VCPU_EVENTS 2018-07-21 16:02:30 +01:00
irq.h KVM: arm/arm64: Enable irqchip routing 2016-07-22 18:52:01 +01:00
Kconfig Make anon_inodes unconditional 2019-04-19 14:03:11 +02:00
Makefile arm64: KVM: Add accessors to track guest/host only counters 2019-04-24 15:35:30 +01:00
pmu.c KVM: arm64: Move pmu hyp code under hyp's Makefile to avoid instrumentation 2019-05-24 14:53:20 +01:00
regmap.c kvm/arm: use PSR_AA32 definitions 2018-07-05 17:24:15 +01:00
reset.c KVM/arm updates for 5.2 2019-05-15 23:41:43 +02:00
sys_regs.c KVM: arm64: Fix ptrauth ID register masking logic 2019-05-01 17:21:51 +01:00
sys_regs.h KVM: arm64: Support runtime sysreg visibility filtering 2019-03-29 14:41:53 +00:00
sys_regs_generic_v8.c KVM: arm64: Rewrite system register accessors to read/write functions 2018-03-19 10:53:16 +00:00
trace.h arm64: KVM: Add trapped system register access tracepoint 2018-12-19 17:47:08 +00:00
va_layout.c arm64: KVM: Allow mapping of vectors outside of the RAM region 2018-03-19 13:06:46 +00:00
vgic-sys-reg-v3.c KVM: arm/arm64: Extract GICv3 max APRn index calculation 2017-09-05 17:33:39 +02:00