ANDROID: KVM: arm64: Ensure vCPU is initialised before bumping 'nr_vcpus'
When initialising a new vCPU, a pointer to the vCPU is inserted into the relevant index of 'hyp_vm->vcpus[]' and 'hyp_vm->nr_vcpus' is incremented to publish the new entry. However, this is done without sufficient memory barriers, allowing a concurrent attempt to load the new vCPU to succeed with a partially initialised object. Ensure that 'hyp_vm->nr_vcpus' is incremented with release semantics and loaded with acquire semantics when 'hyp_vm->vcpus_lock' is not held on the vCPU loading path. Bug: 396117524 Fixes: d4abeb0b ("ANDROID: KVM: arm64: Introduce new spinlock for hypervisor VM vCPUs[] array") Reported-by:Ben Simner <ben.simner@cl.cam.ac.uk> Change-Id: I8c33a81fb5f0e5868781d8f28f266e94d08e8265 Signed-off-by:
Will Deacon <willdeacon@google.com>
Loading
Please register or sign in to comment