From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
kvm@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v3 02/10] KVM: s390: Fix leaking of PGM_ADDRESSING to userspace
Date: Mon, 27 Jul 2026 15:33:20 +0000 [thread overview]
Message-ID: <20260727153320.6828E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260727150254.236021-3-imbrenda@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the `kvm_s390_set_skeys` ioctl handler contains an O(N^2) retry loop that executes with preemption disabled, which can trigger a hard lockup or RCU stall.
--
--- Patch [2]: [PATCH v3 02/10] KVM: s390: Fix leaking of PGM_ADDRESSING to userspace ---
commit 175d33190557729485ae32f46f8a61bb29680d52
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
KVM: s390: Fix leaking of PGM_ADDRESSING to userspace
This commit fixes an issue where kvm_s390_set_cmma_bits() and several
storage key operations return positive error values (like PGM_ADDRESSING)
to userspace instead of standard negative error codes. It updates the
return logic to convert these positive values to -EFAULT.
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index eff0644b8517d..8b7e7da354a25 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
[ ... ]
> @@ -2274,7 +2274,7 @@ static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
[Severity: High]
This isn't a bug introduced by this patch, but looking at the loop just
above this return statement in kvm_s390_set_skeys():
do {
r = kvm_s390_mmu_cache_topup(mc);
if (r == -ENOMEM)
break;
scoped_guard(read_lock, &kvm->mmu_lock) {
for (i = 0 ; i < args->count; i++) {
r = dat_set_storage_key(mc, kvm->arch.gmap->asce,
args->start_gfn + i, keys[i], 0);
if (r)
break;
}
}
} while (r == -ENOMEM);
Can this loop trigger a hard lockup or RCU stall?
When dat_set_storage_key() depletes the MMU cache and returns -ENOMEM, the
inner loop breaks. The outer loop will then refill the cache and restart
the inner loop completely from i = 0.
For large unmapped memory ranges, does this result in O(N^2) behavior where
the kernel re-traverses previously mapped pages over and over?
Since this entire process happens under scoped_guard(read_lock, &kvm->mmu_lock)
which disables preemption, an unprivileged guest calling KVM_S390_SET_SKEYS
with a large count could potentially cause a local denial of service.
> kvm_s390_free_mmu_cache(mc);
> out:
> kvfree(keys);
> - return r;
> + return r <= 0 ? r : -EFAULT;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727150254.236021-1-imbrenda@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-07-27 15:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 15:02 [PATCH v3 00/10] KVM: s390: Misc fixes Claudio Imbrenda
2026-07-27 15:02 ` [PATCH v3 01/10] KVM: s390: Fix unlikely NULL gmap dereference Claudio Imbrenda
2026-07-27 15:24 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 02/10] KVM: s390: Fix leaking of PGM_ADDRESSING to userspace Claudio Imbrenda
2026-07-27 15:33 ` sashiko-bot [this message]
2026-07-27 15:02 ` [PATCH v3 03/10] KVM: s390: Fix race in __do_essa() Claudio Imbrenda
2026-07-27 15:43 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 04/10] KVM: s390: cmma: Fix dirty tracking when removing memslot Claudio Imbrenda
2026-07-27 16:03 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 05/10] KVM: s390: ucontrol: Add missing locking around gmap_remove_child() Claudio Imbrenda
2026-07-27 16:14 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 06/10] KVM: s390: Fix overclearing ESCA in case of error Claudio Imbrenda
2026-07-27 16:33 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 07/10] KVM: s390: Return -EINTR if a signal was pending while faulting-in Claudio Imbrenda
2026-07-27 16:59 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 08/10] KVM: s390: Free the mmu cache when kvm_arch_vcpu_create() fails Claudio Imbrenda
2026-07-27 17:06 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 09/10] KVM: s390: Fix ordering when adding to SCA Claudio Imbrenda
2026-07-27 17:12 ` sashiko-bot
2026-07-27 15:02 ` [PATCH v3 10/10] KVM: s390: Fix cleanup in kvm_s390_pv_create_cpu() Claudio Imbrenda
2026-07-27 17:18 ` 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=20260727153320.6828E1F00A3A@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