Patch "KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-s390-diag-fix-racy-access-of-physical-cpu-number.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 50ba6e152ba2f09c969d4a6c1bed037ede37af40
Author: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>
Date:   Mon May 15 10:42:34 2023 +0200

    KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler
    
    [ Upstream commit 0bc380beb78aa352eadbc21d934dd9606fcee808 ]
    
    We do check for target CPU == -1, but this might change at the time we
    are going to use it. Hold the physical target CPU in a local variable to
    avoid out-of-bound accesses to the cpu arrays.
    
    Cc: Pierre Morel <pmorel@xxxxxxxxxxxxx>
    Fixes: 87e28a15c42c ("KVM: s390: diag9c (directed yield) forwarding")
    Reported-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
    Reviewed-by: Nico Boehr <nrb@xxxxxxxxxxxxx>
    Reviewed-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
    Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>
    Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 807fa9da1e721..3c65b8258ae67 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -166,6 +166,7 @@ static int diag9c_forwarding_overrun(void)
 static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
 {
 	struct kvm_vcpu *tcpu;
+	int tcpu_cpu;
 	int tid;
 
 	tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
@@ -181,14 +182,15 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
 		goto no_yield;
 
 	/* target guest VCPU already running */
-	if (READ_ONCE(tcpu->cpu) >= 0) {
+	tcpu_cpu = READ_ONCE(tcpu->cpu);
+	if (tcpu_cpu >= 0) {
 		if (!diag9c_forwarding_hz || diag9c_forwarding_overrun())
 			goto no_yield;
 
 		/* target host CPU already running */
-		if (!vcpu_is_preempted(tcpu->cpu))
+		if (!vcpu_is_preempted(tcpu_cpu))
 			goto no_yield;
-		smp_yield_cpu(tcpu->cpu);
+		smp_yield_cpu(tcpu_cpu);
 		VCPU_EVENT(vcpu, 5,
 			   "diag time slice end directed to %d: yield forwarded",
 			   tid);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux