From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>
Cc: kvm@vger.kernel.org, "Alexander Gordeev" <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org,
"Christian Borntraeger" <borntraeger@linux.ibm.vom>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v3 8/9] KVM: s390: vsie: Fix guest page tables protection
Date: Thu, 13 Aug 2026 23:01:07 +0000 [thread overview]
Message-ID: <20260813230107.99CA11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260324174301.232921-9-imbrenda@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Uninitialized variable 'gl' used in condition, leading to skipped allocation and host kernel NULL pointer dereference.
--
--- Patch [8]: [PATCH v3 8/9] KVM: s390: vsie: Fix guest page tables protection ---
commit ff58b599b812f86d2edff5eab1c005a2ef716cc7
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
KVM: s390: vsie: Fix guest page tables protection
This patch adjusts the levels of guest page tables that are write-protected
when shadowing, and avoids double protecting the last level. It also skips
attempting to shadow the DAT tables when the nested guest is running in a
real address space.
> diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
> index 0ac2d775d4c05..93a757749a6ee 100644
> --- a/arch/s390/kvm/gaccess.c
> +++ b/arch/s390/kvm/gaccess.c
> @@ -1518,6 +1518,13 @@ static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg,
> (!ptep && crste_leaf(*table) && !table->h.i && table->h.p == w->p))
> return 0;
>
> + /* In case of a real address space */
> + if (w->level <= LEVEL_MEM) {
> + l = TABLE_TYPE_PAGE_TABLE;
> + hl = TABLE_TYPE_REGION1;
> + goto real_address_space;
> + }
> +
> gl = get_level(table, ptep);
[ ... ]
> @@ -1542,6 +1549,7 @@ static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg,
> /* Get the smallest granularity */
> l = min3(gl, hl, w->level);
>
> +real_address_space:
> flags = DAT_WALK_SPLIT_ALLOC | (uses_skeys(sg->parent) ? DAT_WALK_USES_SKEYS : 0);
> /* If necessary, create the shadow mapping */
> if (l < gl) {
^^
[Severity: Critical]
Does this leave the variable gl uninitialized when taking the goto?
When a nested guest is running in a real address space, the new goto
statement bypasses the initialization of gl:
_gaccess_do_shadow() {
...
if (w->level <= LEVEL_MEM) {
l = TABLE_TYPE_PAGE_TABLE;
hl = TABLE_TYPE_REGION1;
goto real_address_space;
}
gl = get_level(table, ptep);
...
real_address_space:
...
if (l < gl) {
If the uninitialized stack value for gl causes the if (l < gl) condition
to evaluate to false, the dat_entry_walk() call is skipped.
Since ptep was initialized to NULL at the start of _gaccess_do_shadow()
and the initial dat_entry_walk() may have stopped early without setting it,
ptep can remain NULL.
Later in the function, _do_shadow_pte() is called with this NULL ptep,
which could lead to a NULL pointer dereference in pgste_get_trylock() and
a host kernel panic.
Is there a way to ensure gl is initialized before the jump, or provide a
safe default when running in a real address space?
> rc = dat_entry_walk(mc, gpa_to_gfn(saddr), sg->asce, flags, l, &table, &ptep);
> if (rc)
> return rc;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260324174301.232921-1-imbrenda@linux.ibm.com?part=8
next prev parent reply other threads:[~2026-08-13 23:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 17:42 [PATCH v3 0/9] KVM: s390: More memory management fixes Claudio Imbrenda
2026-03-24 17:42 ` [PATCH v3 1/9] KVM: s390: vsie: Fix dat_split_ste() Claudio Imbrenda
2026-03-24 17:42 ` [PATCH v3 2/9] KVM: s390: Remove non-atomic dat_crstep_xchg() Claudio Imbrenda
2026-03-24 17:42 ` [PATCH v3 3/9] KVM: s390: vsie: Fix check for pre-existing shadow mapping Claudio Imbrenda
2026-03-24 17:42 ` [PATCH v3 4/9] KVM: s390: vsie: Fix nested guest memory shadowing Claudio Imbrenda
2026-03-24 17:42 ` [PATCH v3 5/9] KVM: s390: Fix gmap_link() Claudio Imbrenda
2026-03-24 17:42 ` [PATCH v3 6/9] KVM: s390: vsie: Fix refcount overflow for shadow gmaps Claudio Imbrenda
2026-03-24 17:42 ` [PATCH v3 7/9] KVM: s390: vsie: Fix unshadowing while shadowing Claudio Imbrenda
2026-08-13 22:43 ` sashiko-bot
2026-03-24 17:43 ` [PATCH v3 8/9] KVM: s390: vsie: Fix guest page tables protection Claudio Imbrenda
2026-03-25 12:30 ` kernel test robot
2026-08-13 23:01 ` sashiko-bot [this message]
2026-03-24 17:43 ` [PATCH v3 9/9] KVM: s390: Fix KVM_S390_VCPU_FAULT ioctl Claudio Imbrenda
2026-08-13 23:08 ` sashiko-bot
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=20260813230107.99CA11F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.vom \
--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