From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
kvm@vger.kernel.org, "Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v2 5/7] KVM: s390: ucontrol: Add missing locking around gmap_remove_child()
Date: Mon, 13 Jul 2026 15:29:59 +0000 [thread overview]
Message-ID: <20260713153000.AB5C71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713150857.269954-6-imbrenda@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [Low] The patch introduces a scoped_guard() into a function that already uses goto-based error handling.
Pre-existing issues:
- [High] Missing cleanup for vcpu->arch.mc in the error paths of kvm_arch_vcpu_create().
- [High] Preexisting memory leak of vcpu->arch.pv.stor_base and sida_addr in kvm_s390_pv_create_cpu() on UV call failure.
--
--- Patch [5]: [PATCH v2 5/7] KVM: s390: ucontrol: Add missing locking around gmap_remove_child() ---
commit 08ba9ce959b1a049a33ef520bb8230d16cec1943
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
KVM: s390: ucontrol: Add missing locking around gmap_remove_child()
This commit adds missing locking for the parent gmap's children_lock when
calling gmap_remove_child(). This fixes an issue in the error handling path
of kvm_arch_vcpu_create() for UCONTROL guests.
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
[ ... ]
> @@ -3866,7 +3866,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
>
> out_ucontrol_uninit:
> if (kvm_is_ucontrol(vcpu->kvm)) {
> - gmap_remove_child(vcpu->arch.gmap);
> + scoped_guard(spinlock, &vcpu->kvm->arch.gmap->children_lock)
> + gmap_remove_child(vcpu->arch.gmap);
[Severity: Low]
Does this mix scoped_guard() with goto-based error handling?
The cleanup guidelines suggest converting all resources that need a goto
cleanup to scope-based cleanup, or converting none of them, rather than
mixing them in the same function.
> vcpu->arch.gmap = gmap_put(vcpu->arch.gmap);
> }
> out_free_sie_block:
> free_page((unsigned long)(vcpu->arch.sie_block));
> return rc;
> }
[Severity: High]
This is a pre-existing issue, but does this error path leak vcpu->arch.mc?
When kvm_arch_vcpu_create() allocates vcpu->arch.mc via
kvm_s390_new_mmu_cache(), does the out_free_sie_block path miss freeing it
before returning rc?
Since kvm_arch_vcpu_destroy() isn't invoked on creation failure, it seems
vcpu->arch.mc might remain permanently allocated.
[Severity: High]
This is a pre-existing issue, but does kvm_s390_pv_create_cpu() leak
vcpu->arch.pv.stor_base and sida_addr if uv_call() fails?
In arch/s390/kvm/pv.c:kvm_s390_pv_create_cpu():
if (cc) {
...
kvm_s390_pv_destroy_cpu(vcpu, &dummy, &dummy);
return -EIO;
}
If this fails, it calls kvm_s390_pv_destroy_cpu():
arch/s390/kvm/pv.c:kvm_s390_pv_destroy_cpu():
if (!kvm_s390_pv_cpu_get_handle(vcpu))
return 0;
Since vcpu->arch.pv.handle is only populated on the uv_call() success path,
will this return early and skip cleaning up stor_base and sida_addr?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713150857.269954-1-imbrenda@linux.ibm.com?part=5
next prev parent reply other threads:[~2026-07-13 15:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 15:08 [PATCH v2 0/7] KVM: s390: Misc fixes Claudio Imbrenda
2026-07-13 15:08 ` [PATCH v2 1/7] KVM: s390: Fix unlikely NULL gmap dereference Claudio Imbrenda
2026-07-13 15:47 ` sashiko-bot
2026-07-14 8:32 ` Steffen Eiden
2026-07-13 15:08 ` [PATCH v2 2/7] KVM: s390: Return -EFAULT instead of PGM_ADDRESSING Claudio Imbrenda
2026-07-13 15:27 ` sashiko-bot
2026-07-14 8:44 ` Steffen Eiden
2026-07-13 15:08 ` [PATCH v2 3/7] KVM: s390: Fix race in __do_essa() Claudio Imbrenda
2026-07-13 15:31 ` sashiko-bot
2026-07-13 15:08 ` [PATCH v2 4/7] KVM: s390: cmma: Fix dirty tracking when removing memslot Claudio Imbrenda
2026-07-13 15:58 ` sashiko-bot
2026-07-13 15:08 ` [PATCH v2 5/7] KVM: s390: ucontrol: Add missing locking around gmap_remove_child() Claudio Imbrenda
2026-07-13 15:29 ` sashiko-bot [this message]
2026-07-13 15:08 ` [PATCH v2 6/7] KVM: s390: Fix overclearing ESCA in case of error Claudio Imbrenda
2026-07-13 15:31 ` sashiko-bot
2026-07-14 12:48 ` Janosch Frank
2026-07-14 12:51 ` Christian Borntraeger
2026-07-13 15:08 ` [PATCH v2 7/7] KVM: s390: Return -EINTR if a signal was pending while faulting-in Claudio Imbrenda
2026-07-13 15:33 ` 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=20260713153000.AB5C71F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@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