From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
kvm@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [GIT PULL v1 06/12] KVM: s390: Do not set special large pages dirty
Date: Wed, 24 Jun 2026 11:37:16 +0000 [thread overview]
Message-ID: <20260624113717.3CC951F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260624111928.144283-7-imbrenda@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Missing validation for special pages in KVM GMAP unmap and destroy paths leads to host kernel crash on invalid folio pointer dereference.
- [Critical] Missing check for a valid `struct page` before folio conversion during PV guest secure page creation causes host crash.
--
commit 5f6958e6ac1a501221bda61b5fd8d27af20f157d
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
KVM: s390: Do not set special large pages dirty
Special pages / folios should not be set dirty. This also applies to
large pages.
> diff --git a/arch/s390/kvm/gmap.c b/arch/s390/kvm/gmap.c
> index 52d55ddea8d4f..3192f610f6962 100644
> --- a/arch/s390/kvm/gmap.c
> +++ b/arch/s390/kvm/gmap.c
> @@ -327,7 +327,7 @@ static long gmap_clear_young_crste(union crste *crstep, gfn_t gfn, gfn_t end, st
> new.h.i = 1;
> new.s.fc1.y = 0;
> new.s.fc1.prefix_notif = 0;
> - if (new.s.fc1.d || !new.h.p)
> + if ((new.s.fc1.d || !new.h.p) && !new.s.fc1.s)
> folio_set_dirty(phys_to_folio(crste_origin_large(crste)));
> new.s.fc1.d = 0;
> new.h.p = 1;
[Severity: Critical]
This isn't a bug introduced by this patch, but since you are fixing the
special page check here, do we need similar checks in other places?
For instance, in _gmap_unmap_pte(), does this code safely handle special
pages when calling pfn_folio() on the PTE's PFN?
arch/s390/kvm/gmap.c:_gmap_unmap_pte() {
...
if (ptep->s.pr && test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &priv->gmap->flags))
folio = pfn_folio(ptep->h.pfra);
...
}
Similarly, in _gmap_unmap_crste(), does this code need a check for
!old.s.fc1.s before calling phys_to_folio() on a large page origin?
arch/s390/kvm/gmap.c:_gmap_unmap_crste() {
...
if (old.s.fc1.pr && test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &priv->gmap->flags))
folio = phys_to_folio(crste_origin_large(old));
...
}
And in _destroy_pages_pte(), does it need a check for !ptep->s.s to avoid
an invalid struct page dereference?
arch/s390/kvm/gmap.c:_destroy_pages_pte() {
...
__kvm_s390_pv_destroy_page(phys_to_page(pte_origin(*ptep)));
...
}
Also in _destroy_pages_crste(), should there be a check for !crstep->s.fc1.s
before calling phys_to_page()?
arch/s390/kvm/gmap.c:_destroy_pages_crste() {
...
for ( ; cur < end; cur += PAGE_SIZE)
__kvm_s390_pv_destroy_page(phys_to_page(cur));
...
}
Can unprivileged userspace trigger a host kernel crash by mapping a memory
region backed by special PFNs without struct pages, converting it to a
protected VM, and then tearing it down or unmapping it?
[Severity: Critical]
This is also a pre-existing issue, but does _kvm_s390_pv_make_secure()
need a check for a valid struct page before converting the folio and
attempting to acquire its lock?
arch/s390/kvm/pv.c:_kvm_s390_pv_make_secure() {
...
folio = pfn_folio(f->pfn);
...
if (folio_trylock(folio)) {
...
}
Could unprivileged userspace map PFNMAP memory without a backing struct
page into a PV guest and cause a host crash when this path is triggered
during guest memory fault?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624111928.144283-1-imbrenda@linux.ibm.com?part=6
next prev parent reply other threads:[~2026-06-24 11:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 11:19 [GIT PULL v1 00/12] KVM: s390: Fix S390_USER_OPEREXEC and more gmap fixes Claudio Imbrenda
2026-06-24 11:19 ` [GIT PULL v1 01/12] KVM: s390: Fix S390_USER_OPEREXEC enablement without STFLE 74 Claudio Imbrenda
2026-06-24 11:40 ` sashiko-bot
2026-06-24 11:19 ` [GIT PULL v1 02/12] KVM: s390: selftests: Extended user_operexec tests Claudio Imbrenda
2026-06-24 11:19 ` [GIT PULL v1 03/12] KVM: s390: Fix typo in UCONTROL documentation Claudio Imbrenda
2026-06-24 11:19 ` [GIT PULL v1 04/12] s390/mm: Fix handling of _PAGE_UNUSED pte bit Claudio Imbrenda
2026-06-24 11:42 ` sashiko-bot
2026-06-24 11:19 ` [GIT PULL v1 05/12] KVM: s390: Fix dat_peek_cmma() overflow Claudio Imbrenda
2026-06-24 11:38 ` sashiko-bot
2026-06-24 11:19 ` [GIT PULL v1 06/12] KVM: s390: Do not set special large pages dirty Claudio Imbrenda
2026-06-24 11:37 ` sashiko-bot [this message]
2026-06-24 11:19 ` [GIT PULL v1 07/12] KVM: s390: Fix code typo in gmap_protect_asce_top_level() Claudio Imbrenda
2026-06-24 11:19 ` [GIT PULL v1 08/12] KVM: s390: Fix handle_{sske,pfmf} under memory pressure Claudio Imbrenda
2026-06-24 11:19 ` [GIT PULL v1 09/12] KVM: s390: Fix locking in kvm_s390_set_mem_control() Claudio Imbrenda
2026-06-24 11:19 ` [GIT PULL v1 10/12] KVM: s390: Fix cmma dirty tracking Claudio Imbrenda
2026-06-24 11:46 ` sashiko-bot
2026-06-24 11:19 ` [GIT PULL v1 11/12] KVM: s390: selftests: Fix cmma selftest Claudio Imbrenda
2026-06-24 11:19 ` [GIT PULL v1 12/12] KVM: s390: Return failure in case of failure in kvm_s390_set_cmma_bits() Claudio Imbrenda
2026-06-24 16:56 ` [GIT PULL v1 00/12] KVM: s390: Fix S390_USER_OPEREXEC and more gmap fixes Paolo Bonzini
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=20260624113717.3CC951F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@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