From: sashiko-bot@kernel.org
To: "Christian Borntraeger" <borntraeger@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH 2/3] KVM: s390: zero initialize irq for inject_pfault_token
Date: Tue, 04 Aug 2026 12:31:55 +0000 [thread overview]
Message-ID: <20260804123156.601E01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260804120631.736919-3-borntraeger@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Calling kfree() on a stack-allocated pointer during floating machine check reinjection.
- [High] Uninitialized kernel stack memory in the `fixed_logout` array is leaked to host userspace via the KVM_GET_IRQ_STATE ioctl.
--
--- Patch [2]: [PATCH 2/3] KVM: s390: zero initialize irq for inject_pfault_token ---
commit f6de66eb1335bc1e8dc54d73ed3ad8d7b39ac810
Author: Christian Borntraeger <borntraeger@linux.ibm.com>
KVM: s390: zero initialize irq for inject_pfault_token
This commit fixes a potential stack information leak to userspace via
migration ioctls. It zero-initializes the irq structure in
__kvm_inject_pfault_token() to ensure stale stack values are not copied.
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 518a69c55e85c..4f4ac6a8d1ad3 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -4475,7 +4475,7 @@ static void __kvm_inject_pfault_token(struct kvm_vcpu *vcpu, bool start_token,
> unsigned long token)
> {
> struct kvm_s390_interrupt inti;
> - struct kvm_s390_irq irq;
> + struct kvm_s390_irq irq = {};
[Severity: High]
This isn't a bug introduced by this patch, but while looking at stack memory
leaks, does a similar uninitialized stack leak happen in
kvm_s390_reinject_machine_check() in arch/s390/kvm/interrupt.c?
arch/s390/kvm/interrupt.c:kvm_s390_reinject_machine_check() {
...
struct kvm_s390_irq irq;
...
}
If the machine check is injected into the vCPU (mci.ck is false), several
fields are populated, but the fixed_logout array might be left
uninitialized.
When passed to kvm_s390_inject_vcpu() -> __inject_mchk(), the uninitialized
fixed_logout array is copied into the vCPU's pending interrupt state:
arch/s390/kvm/interrupt.c:__inject_mchk() {
...
memcpy(&mchk->fixed_logout, &irq->u.mchk.fixed_logout,
sizeof(mchk->fixed_logout));
...
}
Later, if a host user calls the KVM_S390_GET_IRQ_STATE ioctl, this state
could be copied to userspace:
arch/s390/kvm/interrupt.c:kvm_s390_get_irq_state() {
...
if (copy_to_user(&buf[n], &irq, sizeof(irq)))
...
}
Could this leak kernel stack memory in the fixed_logout array to userspace?
[Severity: Critical]
This is another pre-existing issue, but while looking at
kvm_s390_reinject_machine_check(), can a stack pointer be incorrectly freed?
It allocates struct kvm_s390_interrupt_info inti on the kernel stack:
arch/s390/kvm/interrupt.c:kvm_s390_reinject_machine_check() {
...
struct kvm_s390_interrupt_info inti;
...
}
If mci.ck is true, it attempts to inject a floating machine check by passing
the stack-allocated struct by reference:
arch/s390/kvm/interrupt.c:kvm_s390_reinject_machine_check() {
...
rc = __inject_vm(vcpu->kvm, &inti);
...
}
The injection routes KVM_S390_MCHK to __inject_float_mchk(), which
unconditionally calls kfree() on the passed pointer:
arch/s390/kvm/interrupt.c:__inject_float_mchk() {
...
kfree(inti);
...
}
Would calling kfree() on this stack pointer cause a kernel panic?
> struct kvm_s390_interrupt_info *inti_mem = NULL;
> int ret = 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804120631.736919-1-borntraeger@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-08-04 12:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 12:06 [PATCH 0/3] KVM: s390: more fixes Christian Borntraeger
2026-08-04 12:06 ` [PATCH 1/3] KVM: s390: remove user triggerable WARN_ON Christian Borntraeger
2026-08-04 12:16 ` sashiko-bot
2026-08-04 13:24 ` Matthew Rosato
2026-08-04 12:06 ` [PATCH 2/3] KVM: s390: zero initialize irq for inject_pfault_token Christian Borntraeger
2026-08-04 12:31 ` sashiko-bot [this message]
2026-08-04 13:28 ` Matthew Rosato
2026-08-04 12:06 ` [PATCH 3/3] KVM: s390: memory leak in guest debug handling Christian Borntraeger
2026-08-04 12:29 ` sashiko-bot
2026-08-04 14:52 ` 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=20260804123156.601E01F00A3A@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;
as well as URLs for NNTP newsgroup(s).