]> git.baikalelectronics.ru Git - kernel.git/commit
ptp: Fix ptp_kvm_getcrosststamp issue for x86 ptp_kvm
authorZelin Deng <zelin.deng@linux.alibaba.com>
Wed, 29 Sep 2021 05:13:49 +0000 (13:13 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 30 Sep 2021 08:08:15 +0000 (04:08 -0400)
commit8b7e95b13f2f587134e21f639c3387c280ed4a15
tree21f02e8fab3cd99d60b240830e0b7e2897ada3df
parent0f2ad099e01af166c7cd33e07f83b2629df1c1b4
ptp: Fix ptp_kvm_getcrosststamp issue for x86 ptp_kvm

hv_clock is preallocated to have only HVC_BOOT_ARRAY_SIZE (64) elements;
if the PTP_SYS_OFFSET_PRECISE ioctl is executed on vCPUs whose index is
64 of higher, retrieving the struct pvclock_vcpu_time_info pointer with
"src = &hv_clock[cpu].pvti" will result in an out-of-bounds access and
a wild pointer.  Change it to "this_cpu_pvti()" which is guaranteed to
be valid.

Fixes: e43c1f615a16 ("Switch kvmclock data to a PER_CPU variable")
Signed-off-by: Zelin Deng <zelin.deng@linux.alibaba.com>
Cc: <stable@vger.kernel.org>
Message-Id: <1632892429-101194-3-git-send-email-zelin.deng@linux.alibaba.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
drivers/ptp/ptp_kvm_x86.c