From: sashiko-bot@kernel.org
To: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v2 3/4] KVM: s390: Replace get_zeroed_page() with kzalloc() for the GIB
Date: Sun, 06 Sep 2026 08:37:21 +0000 [thread overview]
Message-ID: <20260906083721.B9D531F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260906-s390-kvm-v2-3-2cf6434e6646@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing hardware teardown (chsc_sgib(0)) on PCI AEN initialization failure, causing a hardware Use-After-Free.
- [High] Premature free and nullification of `gib` creates a race condition leading to a NULL pointer dereference in the adapter interrupt handler.
--
commit 507ef89f01184c6a51cfce1ef86dd6ded4bac518
Author: Mike Rapoport (Microsoft) <rppt@kernel.org>
KVM: s390: Replace get_zeroed_page() with kzalloc() for the GIB
This patch replaces get_zeroed_page() with kzalloc() for the guest
information block (GIB) allocation, as the size is a page and it does not
strictly require the page allocator directly. It also updates the cleanup
paths to use kfree() instead of free_page().
Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com
> diff --git a/arch/s390/kvm/s390/interrupt.c b/arch/s390/kvm/s390/interrupt.c
> index 0381ae9817035..02065fb8d053e 100644
> --- a/arch/s390/kvm/s390/interrupt.c
> +++ b/arch/s390/kvm/s390/interrupt.c
[ ... ]
> @@ -3722,7 +3722,7 @@ int __init kvm_s390_gib_init(u8 nisc)
> gib_origin = virt_to_phys(gib);
> if (chsc_sgib(gib_origin)) {
> pr_err("Associating the GIB with the AIV facility failed\n");
> - free_page((unsigned long)gib);
> + kfree(gib);
> gib = NULL;
> rc = -EIO;
> goto out_unreg_gal;
[Severity: High]
This is a pre-existing issue, but does nullifying gib here before
unregistering the adapter interrupt create a race condition?
If the chsc_sgib() call fails, the error path prematurely frees gib and
sets it to NULL before jumping to out_unreg_gal to unregister the interrupt.
Between setting gib to NULL and the completion of
unregister_adapter_interrupt() (which waits for active handlers via RCU),
the interrupt handler remains active.
If an adapter interrupt fires on the shared ISC during this window,
gib_alert_irq_handler() is invoked and calls process_gib_alert_list().
This function unconditionally executes xchg(&gib->alert_list_origin, ...),
which would dereference the NULL pointer.
[ ... ]
> @@ -3742,7 +3742,7 @@ int __init kvm_s390_gib_init(u8 nisc)
> out_unreg_gal:
> unregister_adapter_interrupt(&gib_alert_irq);
> out_free_gib:
> - free_page((unsigned long)gib);
> + kfree(gib);
> gib = NULL;
> out:
> return rc;
[Severity: High]
This isn't a bug introduced by this patch, but does the error path here
forget to detach the GIB from the hardware?
In kvm_s390_gib_init(), if chsc_sgib(gib_origin) successfully registers the
GIB with the hardware, but kvm_s390_pci_aen_init() subsequently fails, the
error path jumps to out_unreg_gal.
This path frees the gib memory but fails to call chsc_sgib(0) to revoke
hardware access (unlike kvm_s390_gib_destroy() which correctly does so).
The hardware retains the physical address of the freed memory and might
continue to access it, resulting in a hardware use-after-free and potential
memory corruption.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260906-s390-kvm-v2-0-2cf6434e6646@kernel.org?part=3
next prev parent reply other threads:[~2026-09-06 8:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 8:27 [PATCH v2 0/4] KVM: s390: replace page allocator calls with kzalloc() Mike Rapoport (Microsoft)
2026-09-06 8:27 ` [PATCH v2 1/4] KVM: s390: Replace get_zeroed_page() with kzalloc() for the STHYI buffer Mike Rapoport (Microsoft)
2026-09-06 8:31 ` sashiko-bot
2026-09-06 8:27 ` [PATCH v2 2/4] KVM: s390: Replace get_zeroed_page() with kzalloc() for the STSI buffer Mike Rapoport (Microsoft)
2026-09-06 8:34 ` sashiko-bot
2026-09-06 8:27 ` [PATCH v2 3/4] KVM: s390: Replace get_zeroed_page() with kzalloc() for the GIB Mike Rapoport (Microsoft)
2026-09-06 8:37 ` sashiko-bot [this message]
2026-09-06 8:27 ` [PATCH v2 4/4] KVM: s390: Replace get_zeroed_page() with kzalloc() for sie_page2 and CMMA Mike Rapoport (Microsoft)
2026-09-06 8:34 ` 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=20260906083721.B9D531F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@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=rppt@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