From: sashiko-bot@kernel.org
To: "Farhan Ali" <alifm@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 v3 3/4] KVM: s390: pci: Fix NULL dereference on AIBV allocation failure
Date: Mon, 20 Jul 2026 18:25:58 +0000 [thread overview]
Message-ID: <20260720182558.A29C91F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260720175819.1723-4-alifm@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unbounded resource and memory leak on duplicate AEN registrations due to missing state check.
--
--- Patch [3]: [PATCH v3 3/4] KVM: s390: pci: Fix NULL dereference on AIBV allocation failure ---
commit 9b0515651fd32d61d1da226af14173f1630435f4
Author: Farhan Ali <alifm@linux.ibm.com>
KVM: s390: pci: Fix NULL dereference on AIBV allocation failure
The airq_iv_create() can return NULL on failure, but the return value was
never checked. If it fails, zdev->aibv will be NULL and fail when
derefenced in kvm_zpci_set_airq(). Add a NULL check and free the previously
allocated AISB bit and zdev->aisb on failure.
> diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
> index 9fdb6e383b189..85f4fb5d36b38 100644
> --- a/arch/s390/kvm/pci.c
> +++ b/arch/s390/kvm/pci.c
> @@ -310,6 +310,11 @@ static int kvm_s390_pci_aif_enable(struct zpci_dev *zdev, struct zpci_fib *fib,
> AIRQ_IV_GUESTVEC,
> phys_to_virt(fib->fmt0.aibv));
>
> + if (!zdev->aibv) {
> + rc = -ENOMEM;
> + goto free_aisb;
> + }
> +
[Severity: High]
This isn't a bug introduced by this patch, but does kvm_s390_pci_aif_enable()
lack a state check to prevent duplicate registrations?
If a guest VM or userspace process issues the KVM_S390_ZPCIOP_REG_AEN ioctl
multiple times for the same device, it appears we proceed through the
function and allocate new resources without freeing previous ones.
Could this result in overwriting pointers like zdev->aibv and zdev->aisb,
along with overwriting account info in account_mem():
arch/s390/kvm/pci.c:account_mem() {
...
kzdev->user_account = user;
kzdev->mm_account = current->mm;
...
}
If the pointers are overwritten on a duplicate call, does this permanently
leak the host resources, including previously pinned pages,
mm_struct/user_struct reference counts, and airq_iv structures?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720175819.1723-1-alifm@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-07-20 18:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 17:58 [PATCH v3 0/4] KVM s390x PCI fixes Farhan Ali
2026-07-20 17:58 ` [PATCH v3 1/4] KVM: s390: pci: Fix memory accounting for pinned/unpinned pages Farhan Ali
2026-07-20 18:18 ` sashiko-bot
2026-07-20 17:58 ` [PATCH v3 2/4] KVM: s390: pci: Fix missing error codes and memory unaccounting Farhan Ali
2026-07-20 18:13 ` sashiko-bot
2026-07-20 17:58 ` [PATCH v3 3/4] KVM: s390: pci: Fix NULL dereference on AIBV allocation failure Farhan Ali
2026-07-20 18:25 ` sashiko-bot [this message]
2026-07-20 17:58 ` [PATCH v3 4/4] KVM: s390: pci: Fix resource leak on IRQ registration failure Farhan Ali
2026-07-20 18:42 ` 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=20260720182558.A29C91F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=alifm@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