From: sashiko-bot@kernel.org
To: "Christian Borntraeger" <borntraeger@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
kvm@vger.kernel.org, "Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v2 3/7] KVM: s390: Zero initialize irq in reinject_machine_check
Date: Tue, 04 Aug 2026 17:20:51 +0000 [thread overview]
Message-ID: <20260804172052.7626C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804162435.28617-4-borntraeger@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Injecting a floating machine check causes a host kernel panic because kfree() is unconditionally called on a stack-allocated variable.
- [High] Memory leak in kvm_s390_get_io_int() when I/O interrupt reinjection fails.
--
--- Patch [3]: [PATCH v2 3/7] KVM: s390: Zero initialize irq in reinject_machine_check ---
commit c87188fae3993586a5800e7440b273a7c1c85398
Author: Christian Borntraeger <borntraeger@linux.ibm.com>
Subject: KVM: s390: Zero initialize irq in reinject_machine_check
This commit zeroes out the stack-allocated kvm_s390_irq structure in
kvm_s390_reinject_machine_check() to prevent leaking uninitialized stack
data via the fixed_logout array.
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index 23f0e0821474a..009d6a845d598 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -3109,7 +3109,7 @@ void kvm_s390_reinject_machine_check(struct kvm_vcpu *vcpu,
> struct mcck_volatile_info *mcck_info)
> {
> struct kvm_s390_interrupt_info inti;
[Severity: Critical]
This is a pre-existing issue, but does this lead to a kernel panic when
injecting a floating machine check?
If a hardware machine check occurs while the CPU is in SIE and it is a
floating machine check, we pass the address of this stack-allocated inti
variable into __inject_vm():
kvm_s390_reinject_machine_check() {
...
if (mci.ck) {
inti.type = KVM_S390_MCHK;
rc = __inject_vm(vcpu->kvm, &inti);
...
}
Inside __inject_vm(), the call chain reaches __inject_float_mchk(), which
unconditionally frees the pointer:
__inject_float_mchk() {
...
kfree(inti);
}
Could this result in a host crash due to freeing a stack address?
> - struct kvm_s390_irq irq;
> + struct kvm_s390_irq irq = {};
> struct kvm_s390_mchk_info *mchk;
> union mci mci;
> __u64 cr14 = 0; /* upper bits are not used */
While reviewing the interrupt code, I noticed another pre-existing issue in
a different path.
[Severity: High]
This isn't a bug introduced by this patch, but does kvm_s390_get_io_int()
leak memory when I/O interrupt reinjection fails?
When kvm_s390_get_io_int() dequeues a classical I/O interrupt, it takes
ownership of a dynamically allocated struct kvm_s390_interrupt_info object.
If it detects a higher-priority GISA interrupt concurrently, it attempts to
reinject it:
kvm_s390_get_io_int() {
...
kvm_s390_reinject_io_int(kvm, inti);
...
}
If the floating interrupt queue is full, __inject_io() returns -EBUSY:
__inject_io() {
...
if (fi->counters[FIRQ_CNTR_IO] >= KVM_S390_MAX_FLOAT_IRQS)
return -EBUSY;
...
}
The return value of the reinjection is ignored in kvm_s390_get_io_int(), and
the original pointer is overwritten immediately after without freeing it on
error, which appears to leak the object.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804162435.28617-1-borntraeger@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-08-04 17:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 16:24 [PATCH v2 0/7] KVM: s390: more fixes Christian Borntraeger
2026-08-04 16:24 ` [PATCH v2 1/7] KVM: s390: Remove user triggerable WARN_ON Christian Borntraeger
2026-08-04 16:33 ` sashiko-bot
2026-08-04 17:47 ` Douglas Freimuth
2026-08-04 16:24 ` [PATCH v2 2/7] KVM: s390: Zero initialize data structures for inject_pfault_token Christian Borntraeger
2026-08-04 17:05 ` sashiko-bot
2026-08-04 16:24 ` [PATCH v2 3/7] KVM: s390: Zero initialize irq in reinject_machine_check Christian Borntraeger
2026-08-04 17:18 ` Matthew Rosato
2026-08-04 17:20 ` sashiko-bot [this message]
2026-08-04 16:24 ` [PATCH v2 4/7] KVM: s390: Fix memory leak in guest debug handling Christian Borntraeger
2026-08-04 18:00 ` sashiko-bot
2026-08-04 16:24 ` [PATCH v2 5/7] KVM: s390: Fix old_data leak in guest debug error path Christian Borntraeger
2026-08-04 17:19 ` Matthew Rosato
2026-08-04 18:19 ` sashiko-bot
2026-08-04 16:24 ` [PATCH v2 6/7] KVM: s390: Take srcu when importing watchpoint data Christian Borntraeger
2026-08-04 18:40 ` sashiko-bot
2026-08-05 8:21 ` Christian Borntraeger
2026-08-04 16:24 ` [PATCH v2 7/7] KVM: s390: Free guest debug data on vcpu destroy Christian Borntraeger
2026-08-04 18:47 ` sashiko-bot
2026-08-04 20:03 ` Matthew Rosato
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=20260804172052.7626C1F000E9@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=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