Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Matthew Rosato <mjrosato@linux.ibm.com>
To: Farhan Ali <alifm@linux.ibm.com>, sashiko-reviews@lists.linux.dev
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	linux-s390@vger.kernel.org, kvm@vger.kernel.org,
	Christian Borntraeger <borntraeger@linux.ibm.com>
Subject: Re: [PATCH v5 6/6] KVM: s390: pci: Validate AIBV and AISB before pinning guest pages
Date: Thu, 23 Jul 2026 16:14:08 -0400	[thread overview]
Message-ID: <0dae69e7-8161-46e7-bef2-edabefd93fea@linux.ibm.com> (raw)
In-Reply-To: <fea9882a-b41f-42a3-b30b-37d6a40af127@linux.ibm.com>


>> [Severity: Critical]
>> Does this calculation underestimate the true byte footprint of the bit
>> vector
>> when aibvo is non-zero?
>>
>> If a guest provides msi_vecs = 64, aibvo = 63, and an aibv GPA with a
>> page
>> offset of 4081, the calculated size is 15 bytes instead of 16. The npages
>> calculation yields DIV_ROUND_UP(4081 + 15, 4096) = 1, which incorrectly
>> passes the npages > 1 boundary check.
>>
>> This would result in KVM pinning only one page, but the hardware could
>> access
>> the 16th byte, writing to the first byte of the next unpinned host
>> physical
>> page, which could lead to host memory corruption.
> 
> I think Sashiko does have a valid point here (sigh...). The right fix
> would be to correctly round up both msi_vecs and aibvo bits so:
> 
> size = BITS_TO_LONGS(msi_vecs + fib->fmt0.aibvo) * sizeof(unsigned long);
> 
> and remove size += (fib->fmt0.aibvo / 8);
>
Yeah, that sounds right to me.

      reply	other threads:[~2026-07-23 20:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 18:34 [PATCH v5 0/6] KVM s390x PCI fixes Farhan Ali
2026-07-23 18:34 ` [PATCH v5 1/6] KVM: s390: pci: Reject adapter interrupt forwarding if already enabled Farhan Ali
2026-07-23 18:49   ` sashiko-bot
2026-07-23 18:34 ` [PATCH v5 2/6] KVM: s390: pci: Fix memory accounting for pinned/unpinned pages Farhan Ali
2026-07-23 18:49   ` sashiko-bot
2026-07-23 20:26   ` Matthew Rosato
2026-07-23 18:34 ` [PATCH v5 3/6] KVM: s390: pci: Fix missing error codes and memory unaccounting Farhan Ali
2026-07-23 18:43   ` sashiko-bot
2026-07-23 18:34 ` [PATCH v5 4/6] KVM: s390: pci: Fix NULL dereference on AIBV allocation failure Farhan Ali
2026-07-23 18:47   ` sashiko-bot
2026-07-23 18:34 ` [PATCH v5 5/6] KVM: s390: pci: Fix resource leak on IRQ registration failure Farhan Ali
2026-07-23 18:42   ` sashiko-bot
2026-07-23 18:34 ` [PATCH v5 6/6] KVM: s390: pci: Validate AIBV and AISB before pinning guest pages Farhan Ali
2026-07-23 18:48   ` sashiko-bot
2026-07-23 19:50     ` Farhan Ali
2026-07-23 20:14       ` Matthew Rosato [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0dae69e7-8161-46e7-bef2-edabefd93fea@linux.ibm.com \
    --to=mjrosato@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox