mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 16:15:11 +00:00
KVM: arm64: Fix buffer overflow in kvm_arm_set_fw_reg()
commita25bc8486f
upstream. The KVM_REG_SIZE() comes from the ioctl and it can be a power of two between 0-32768 but if it is more than sizeof(long) this will corrupt memory. Fixes:99adb56763
("KVM: arm/arm64: Add save/restore support for firmware workaround state") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/4efbab8c-640f-43b2-8ac6-6d68e08280fe@kili.mountain Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7a7d89a089
commit
9762e58cbd
1 changed files with 2 additions and 0 deletions
|
@ -397,6 +397,8 @@ int kvm_arm_set_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
|
||||||
u64 val;
|
u64 val;
|
||||||
int wa_level;
|
int wa_level;
|
||||||
|
|
||||||
|
if (KVM_REG_SIZE(reg->id) != sizeof(val))
|
||||||
|
return -ENOENT;
|
||||||
if (copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id)))
|
if (copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue