From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 08/10] KVM: s390: Prevent memslots outside the ASCE range
Date: Tue, 02 Jun 2026 14:40:53 +0000 [thread overview]
Message-ID: <20260602144053.C759A1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602142356.169458-9-imbrenda@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Asymmetric and Order-Dependent Limit Validation
--
commit 7a66168c52b7a30030450cbbdcd5db0e9145bbfe
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
KVM: s390: Prevent memslots outside the ASCE range
This patch aims to prevent userspace from creating memslots above the
maximum allowed VM address, and prevents reducing the maximum address
below existing memslots.
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index e09960c2e6ed1..ffb20a64d328f 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -999,7 +999,10 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
> break;
> }
> case KVM_S390_VM_MEM_LIMIT_SIZE: {
> + struct kvm_memslots *slots;
> + struct kvm_memory_slot *ms;
> unsigned long new_limit;
> + int bkt;
[ ... ]
> + ret = 0;
> + scoped_guard(mutex, &kvm->slots_lock) {
> + slots = kvm_memslots(kvm);
> + if (slots && !kvm_memslots_empty(slots)) {
> + kvm_for_each_memslot(ms, bkt, slots) {
> + if (gpa_to_gfn(new_limit) < ms->base_gfn + ms->npages) {
> + ret = -EBUSY;
> + break;
> + }
> + }
> + }
> + if (!ret)
> + ret = gmap_set_limit(kvm->arch.gmap, gpa_to_gfn(new_limit));
> + }
[ ... ]
> @@ -5672,6 +5693,8 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
> return -EINVAL;
> if ((new->base_gfn + new->npages) * PAGE_SIZE > kvm->arch.mem_limit)
> return -EINVAL;
> + if (!asce_contains_gfn(kvm->arch.gmap->asce, new->base_gfn + new->npages - 1))
> + return -EINVAL;
> }
[Severity: Medium]
Is this creating an asymmetric and order-dependent limit validation?
When KVM_S390_VM_MEM_LIMIT_SIZE is called, the exact new_limit is strictly
checked against existing memslots (e.g., rejecting a 4GB limit if a 3TB
memslot exists). However, new_limit is never saved back to
kvm->arch.mem_limit.
When a new memslot is added later, it is only validated against the old
kvm->arch.mem_limit and the rounded-up ASCE capacity here in
asce_contains_gfn().
For example, setting a 4GB limit configures a TABLE_TYPE_REGION3 ASCE with
a 4TB capacity. Because the exact 4GB limit was not saved, userspace can
successfully add a 3TB memslot later since 3TB < 4TB.
Should kvm->arch.mem_limit be updated during KVM_S390_VM_MEM_LIMIT_SIZE to
enforce the exact limit symmetrically?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260602142356.169458-1-imbrenda@linux.ibm.com?part=8
next prev parent reply other threads:[~2026-06-02 14:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 14:23 [PATCH v3 00/10] KVM: s390: More gmap and vsie fixes Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 01/10] KVM: s390: Fix _gmap_unmap_crste() Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 02/10] KVM: s390: Fix _gmap_crstep_xchg_atomic() Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 03/10] KVM: s390: Avoid potentially sleeping while atomic when zapping pages Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 04/10] KVM: s390: Fix guest / virtual address confusion in _essa_clear_cbrl() Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 05/10] KVM: s390: vsie: Fix rmap handling in _do_shadow_crste() Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 06/10] KVM: s390: Fix fault-in code Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 07/10] KVM: s390: Lock pte when making page secure Claudio Imbrenda
2026-06-02 14:44 ` sashiko-bot
2026-06-02 14:23 ` [PATCH v3 08/10] KVM: s390: Prevent memslots outside the ASCE range Claudio Imbrenda
2026-06-02 14:40 ` sashiko-bot [this message]
2026-06-02 14:23 ` [PATCH v3 09/10] KVM: s390: Fix possible reference leak in fault-in code Claudio Imbrenda
2026-06-02 14:23 ` [PATCH v3 10/10] KVM: s390: Remove ptep_zap_softleaf_entry() 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=20260602144053.C759A1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.