linux-stable/include
Michal Luczaj 61242001d6 KVM: Initialize gfn_to_pfn_cache locks in dedicated helper
commit 52491a38b2 upstream.

Move the gfn_to_pfn_cache lock initialization to another helper and
call the new helper during VM/vCPU creation.  There are race
conditions possible due to kvm_gfn_to_pfn_cache_init()'s
ability to re-initialize the cache's locks.

For example: a race between ioctl(KVM_XEN_HVM_EVTCHN_SEND) and
kvm_gfn_to_pfn_cache_init() leads to a corrupted shinfo gpc lock.

                (thread 1)                |           (thread 2)
                                          |
 kvm_xen_set_evtchn_fast                  |
  read_lock_irqsave(&gpc->lock, ...)      |
                                          | kvm_gfn_to_pfn_cache_init
                                          |  rwlock_init(&gpc->lock)
  read_unlock_irqrestore(&gpc->lock, ...) |

Rename "cache_init" and "cache_destroy" to activate+deactivate to
avoid implying that the cache really is destroyed/freed.

Note, there more races in the newly named kvm_gpc_activate() that will
be addressed separately.

Fixes: 982ed0de47 ("KVM: Reinstate gfn_to_pfn_cache with invalidation support")
Cc: stable@vger.kernel.org
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
[sean: call out that this is a bug fix]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221013211234.1318131-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-10 18:17:38 +01:00
..
acpi ACPI: APEI: Fix integer overflow in ghes_estatus_pool_init() 2022-11-10 18:17:24 +01:00
asm-generic arm64 fixes for -rc7 2022-09-23 15:28:51 -07:00
clocksource
crypto
drm drm/edid: Handle EDID 1.4 range descriptor h/vfreq offsets 2022-09-02 16:38:51 +03:00
dt-bindings dt-bindings: clock: exynosautov9: correct clock numbering of peric0/c1 2022-10-21 12:38:32 +02:00
keys
kunit kunit: fix assert_type for comparison macros 2022-09-01 13:00:32 -06:00
kvm
linux KVM: Initialize gfn_to_pfn_cache locks in dedicated helper 2022-11-10 18:17:38 +01:00
math-emu
media media: v4l: subdev: Fail graciously when getting try data for NULL state 2022-11-10 18:17:24 +01:00
memory
misc
net net: remove SOCK_SUPPORT_ZC from sockmap 2022-11-10 18:17:35 +01:00
pcmcia
ras
rdma
rv
scsi scsi: stex: Properly zero out the passthrough command structure 2022-10-15 08:02:56 +02:00
soc AT91 fixes for 6.0 2022-09-02 11:29:03 +02:00
sound ASoC: Intel: common: add ACPI matching tables for Raptor Lake 2022-11-04 00:00:28 +09:00
target
trace ARM: SoC fixes for 6.0-rc6 2022-09-22 11:10:11 -07:00
uapi media: videodev2.h: V4L2_DV_BT_BLANKING_HEIGHT should check 'interlaced' 2022-11-04 00:00:32 +09:00
ufs
vdso
video
xen