Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>, kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH v3 02/12] KVM: s390: Fix potential leak in kvm_s390_get_io_int()
Date: Thu, 03 Dec 2026 16:49:07 +0000	[thread overview]
Message-ID: <sashiko-outbox-248219@kernel.org> (raw)
In-Reply-To: <20261203161527.188235-3-imbrenda@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: s390: missing vCPU wakeup after gisa_set_ipm_gisc()
  rollback
--

commit f5328eb608a4958f3ba6e17facc3c8bfabc5afa0
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>

KVM: s390: Fix potential leak in kvm_s390_get_io_int()

This commit handles kvm_s390_reinject_io_int() failure in
kvm_s390_get_io_int() by freeing tmp_inti, restoring the GISA IPM bit,
and returning the lower-priority classic interrupt instead of leaking it.

> diff --git a/arch/s390/kvm/s390/interrupt.c b/arch/s390/kvm/s390/interrupt.c
> index 31a6074feffcb..8612d2e96205d 100644
> --- a/arch/s390/kvm/s390/interrupt.c
> +++ b/arch/s390/kvm/s390/interrupt.c
> @@ -1775,8 +1775,21 @@ struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
>  	if (tmp_inti) {
>  		tmp_inti->type = KVM_S390_INT_IO(1, 0, 0, 0);
>  		tmp_inti->io.io_int_word = isc_to_int_word(isc);
> -		if (inti)
> -			kvm_s390_reinject_io_int(kvm, inti);
> +		if (inti && kvm_s390_reinject_io_int(kvm, inti)) {
> +			/*
> +			 * The maximum number of pending interrupts is so
> +			 * high that this is impossible in practice during
> +			 * normal guest operation.
> +			 * If this happens anyway, deliver the lower
> +			 * priority interrupt, instead of discarding it. It
> +			 * is still technically a violation of the
> +			 * architecture, but it's not as bad as dropping an
> +			 * interrupt entirely.
> +			 */
> +			kfree(tmp_inti);
> +			gisa_set_ipm_gisc(gi->origin, isc);
> +			goto out;
> +		}

[Severity: Medium]
Can this rollback strand the GISA adapter interrupt without waking an
idle vCPU?

get_top_gisa_isc() clears bit isc in gisa->ipm before the sleepable
kzalloc_obj() and kvm_s390_reinject_io_int() calls.  While that bit is
cleared, another vCPU can enter enabled wait and halt:

CPU0                                  CPU1
kvm_s390_get_io_int()
  get_top_gisa_isc()
    gisa_tac_ipm_gisc(..., isc)
  kzalloc_obj(...)
                                      kvm_s390_handle_wait()
                                        gisa_get_ipm_or_restore_iam()
                                          /* observes IPM == 0 */
                                        kvm_vcpu_halt()
  kvm_s390_reinject_io_int() -> -EBUSY
  gisa_set_ipm_gisc(..., isc)         <-- no wakeup or timer restart

A software set_bit_inv() to gisa->ipm does not place the GISA on the GIB
alert list or raise a host GAL interrupt.  Unlike __inject_io(), which
pairs gisa_set_ipm_gisc() with __floating_irq_kick() in __inject_vm(),
this rollback neither kicks idle vCPUs nor restarts gi->timer.

If gisa_vcpu_kicker() also fired during the cleared window and stopped
gi->timer, the restored interrupt stays pending while eligible vCPUs
remain halted until an unrelated wakeup or new hardware GIB alert
arrives.

The existing gisa_set_ipm_gisc() rollback paths in kvm_s390_get_io_int()
have the same gap.  Calling __floating_irq_kick() or restarting
gi->timer after restoring the IPM bit would prevent the lost wakeup.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203161527.188235-1-imbrenda@linux.ibm.com?part=2

  reply	other threads:[~2026-12-03 16:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:15 [PATCH v3 00/12] KVM: s390: More fixes Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 01/12] KVM: s390: ucontrol: Do not mask -ENOMEM when translating Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 02/12] KVM: s390: Fix potential leak in kvm_s390_get_io_int() Claudio Imbrenda
2026-12-03 16:49   ` sashiko-bot [this message]
2026-12-03 16:15 ` [PATCH v3 03/12] KVM: s390: Small miscellaneous CMMA fixes Claudio Imbrenda
2026-12-03 17:24   ` sashiko-bot
2026-12-03 16:15 ` [PATCH v3 04/12] KVM: s390: Fix dat_entry_walk() with DAT_WALK_CONTINUE Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 05/12] KVM: s390: Fix soft-dirty handling in _gmap_link() Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 06/12] KVM: s390: Fix race in gmap_clear_young_pte() Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 07/12] KVM: s390: Properly adjust page size before calling _gmap_link() Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 08/12] KVM: s390: Fix *_test_and_clear_softdirty() functions Claudio Imbrenda
2026-12-03 17:49   ` sashiko-bot
2026-12-03 16:15 ` [PATCH v3 09/12] KVM: s390: Do not unnecessarily drop the soft-dirty bit Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 10/12] KVM: s390: Disallow 2G pages for guests up to 2G Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 11/12] KVM: s390: vsie: Fix improper shadowing of non-present host ptes Claudio Imbrenda
2026-12-03 16:15 ` [PATCH v3 12/12] KVM: s390: vsie: Drop shadow gmaps when a memslot is deleted or moved Claudio Imbrenda

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=sashiko-outbox-248219@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=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