Skip to content
Commit fa1fb556 authored by Dave Martin's avatar Dave Martin
Browse files

KVM: arm64: Filter out invalid core register IDs in KVM_GET_REG_LIST



Since commit d26c25a9 ("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 marking each core register ID with
the appropriate size, and by filtering out any misaligned IDs using
validate_core_reg_id().

The number of core register IDs resulting from the process is now
not trivial to determine (even though it is still theoretically
compile-time constant).  In order to avoid implementing complex
logic twice, copy_core_reg_indices() is now used both to count and
copy the indices.  This will add a small runtime cost, but this is
deemed acceptable since KVM_GET_REG_LIST is not performance-
critical for userspace.

Fixes: d26c25a9 ("arm64: KVM: Tighten guest core register access from userspace")
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
parent 5e7c29a7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment