* [GIT PULL 0/2] KVM: s390: pci: fix array indexing for master
@ 2026-05-04 15:20 Christian Borntraeger
2026-05-04 15:20 ` [GIT PULL 1/2] KVM: s390: pci: fix GAIT table indexing due to double-scaling pointer arithmetic Christian Borntraeger
2026-05-04 15:20 ` [GIT PULL 2/2] KVM: s390: pci: Fix aisb calculation Christian Borntraeger
0 siblings, 2 replies; 3+ messages in thread
From: Christian Borntraeger @ 2026-05-04 15:20 UTC (permalink / raw)
To: Paolo Bonzini
Cc: KVM, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
linux-s390, Christian Borntraeger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Thomas Huth, Sven Schnelle, Junrui Luo,
Yuhao Jiang, Matthew Rosato, Niklas Schnelle
Paolo,
The following changes since commit 028ef9c96e96197026887c0f092424679298aae8:
Linux 7.0 (2026-04-12 13:48:06 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-master-7.1-1
for you to fetch changes up to 0cfe660559e857d7c00ab86c73e4510ce069086f:
KVM: s390: pci: Fix aisb calculation (2026-04-27 11:14:45 +0200)
----------------------------------------------------------------
KVM: s390: pci: fix array indexing
For large amounts of PCI devices its possible to overrun the arrays as
the index was miscalculated in 2 places.
----------------------------------------------------------------
Junrui Luo (1):
KVM: s390: pci: fix GAIT table indexing due to double-scaling pointer arithmetic
Matthew Rosato (1):
KVM: s390: pci: Fix aisb calculation
arch/s390/kvm/interrupt.c | 3 +--
arch/s390/kvm/pci.c | 10 ++++------
2 files changed, 5 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [GIT PULL 1/2] KVM: s390: pci: fix GAIT table indexing due to double-scaling pointer arithmetic
2026-05-04 15:20 [GIT PULL 0/2] KVM: s390: pci: fix array indexing for master Christian Borntraeger
@ 2026-05-04 15:20 ` Christian Borntraeger
2026-05-04 15:20 ` [GIT PULL 2/2] KVM: s390: pci: Fix aisb calculation Christian Borntraeger
1 sibling, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2026-05-04 15:20 UTC (permalink / raw)
To: Paolo Bonzini
Cc: KVM, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
linux-s390, Christian Borntraeger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Thomas Huth, Sven Schnelle, Junrui Luo,
Yuhao Jiang, Matthew Rosato, Niklas Schnelle, stable
From: Junrui Luo <moonafterrain@outlook.com>
kvm_s390_pci_aif_enable(), kvm_s390_pci_aif_disable(), and
aen_host_forward() index the GAIT by manually multiplying the index
with sizeof(struct zpci_gaite).
Since aift->gait is already a struct zpci_gaite pointer, this
double-scales the offset, accessing element aisb*16 instead of aisb.
This causes out-of-bounds accesses when aisb >= 32 (with
ZPCI_NR_DEVICES=512)
Fix by removing the erroneous sizeof multiplication.
Fixes: 3c5a1b6f0a18 ("KVM: s390: pci: provide routines for enabling/disabling interrupt forwarding")
Fixes: 73f91b004321 ("KVM: s390: pci: enable host forwarding of Adapter Event Notifications")
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Tested-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
arch/s390/kvm/interrupt.c | 3 +--
arch/s390/kvm/pci.c | 6 ++----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 7cb8ce833b62..f48f25c7dc8f 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -3307,8 +3307,7 @@ static void aen_host_forward(unsigned long si)
struct zpci_gaite *gaite;
struct kvm *kvm;
- gaite = (struct zpci_gaite *)aift->gait +
- (si * sizeof(struct zpci_gaite));
+ gaite = aift->gait + si;
if (gaite->count == 0)
return;
if (gaite->aisb != 0)
diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
index 86d93e8dddae..eed45af1a92d 100644
--- a/arch/s390/kvm/pci.c
+++ b/arch/s390/kvm/pci.c
@@ -290,8 +290,7 @@ static int kvm_s390_pci_aif_enable(struct zpci_dev *zdev, struct zpci_fib *fib,
phys_to_virt(fib->fmt0.aibv));
spin_lock_irq(&aift->gait_lock);
- gaite = (struct zpci_gaite *)aift->gait + (zdev->aisb *
- sizeof(struct zpci_gaite));
+ gaite = aift->gait + zdev->aisb;
/* If assist not requested, host will get all alerts */
if (assist)
@@ -357,8 +356,7 @@ static int kvm_s390_pci_aif_disable(struct zpci_dev *zdev, bool force)
if (zdev->kzdev->fib.fmt0.aibv == 0)
goto out;
spin_lock_irq(&aift->gait_lock);
- gaite = (struct zpci_gaite *)aift->gait + (zdev->aisb *
- sizeof(struct zpci_gaite));
+ gaite = aift->gait + zdev->aisb;
isc = gaite->gisc;
gaite->count--;
if (gaite->count == 0) {
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [GIT PULL 2/2] KVM: s390: pci: Fix aisb calculation
2026-05-04 15:20 [GIT PULL 0/2] KVM: s390: pci: fix array indexing for master Christian Borntraeger
2026-05-04 15:20 ` [GIT PULL 1/2] KVM: s390: pci: fix GAIT table indexing due to double-scaling pointer arithmetic Christian Borntraeger
@ 2026-05-04 15:20 ` Christian Borntraeger
1 sibling, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2026-05-04 15:20 UTC (permalink / raw)
To: Paolo Bonzini
Cc: KVM, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
linux-s390, Christian Borntraeger, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Thomas Huth, Sven Schnelle, Junrui Luo,
Yuhao Jiang, Matthew Rosato, Niklas Schnelle
From: Matthew Rosato <mjrosato@linux.ibm.com>
The current implementation of aisb calculation will erroneously index
via an unsigned long * as well as multiply by 8B for every 64-bits in
the offset; only one or the other is required. This throws off aisb
calculations once the number of devices exceeds 64, and can result
in out-of-bounds access as well as failure to indicate summary bits
associated with those devices in guests.
Fix this by converting to a physical address before applying the
offset, as is already done in arch/s390/pci/pci_irq.c.
Fixes: 3c5a1b6f0a18 ("KVM: s390: pci: provide routines for enabling/disabling interrupt forwarding")
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
arch/s390/kvm/pci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
index eed45af1a92d..5b075c38998e 100644
--- a/arch/s390/kvm/pci.c
+++ b/arch/s390/kvm/pci.c
@@ -166,7 +166,7 @@ static int kvm_zpci_set_airq(struct zpci_dev *zdev)
fib.fmt0.noi = airq_iv_end(zdev->aibv);
fib.fmt0.aibv = virt_to_phys(zdev->aibv->vector);
fib.fmt0.aibvo = 0;
- fib.fmt0.aisb = virt_to_phys(aift->sbv->vector + (zdev->aisb / 64) * 8);
+ fib.fmt0.aisb = virt_to_phys(aift->sbv->vector) + (zdev->aisb / 64) * 8;
fib.fmt0.aisbo = zdev->aisb & 63;
fib.gd = zdev->gisa;
@@ -308,7 +308,7 @@ static int kvm_s390_pci_aif_enable(struct zpci_dev *zdev, struct zpci_fib *fib,
/* Update guest FIB for re-issue */
fib->fmt0.aisbo = zdev->aisb & 63;
- fib->fmt0.aisb = virt_to_phys(aift->sbv->vector + (zdev->aisb / 64) * 8);
+ fib->fmt0.aisb = virt_to_phys(aift->sbv->vector) + (zdev->aisb / 64) * 8;
fib->fmt0.isc = gisc;
/* Save some guest fib values in the host for later use */
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-04 15:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 15:20 [GIT PULL 0/2] KVM: s390: pci: fix array indexing for master Christian Borntraeger
2026-05-04 15:20 ` [GIT PULL 1/2] KVM: s390: pci: fix GAIT table indexing due to double-scaling pointer arithmetic Christian Borntraeger
2026-05-04 15:20 ` [GIT PULL 2/2] KVM: s390: pci: Fix aisb calculation Christian Borntraeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox