From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v4 1/8] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area
Date: Mon, 20 Jul 2026 09:14:18 +0000 [thread overview]
Message-ID: <20260720091419.499CE1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260720085834.898025-2-hca@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Physical pages are returned to the buddy allocator while their page table entries (PTEs) are left valid, creating a Use-After-Free / Map-After-Free window.
- [Medium] Sleeping memory allocation within a `pte_fn_t` callback violates the `lazy_mmu_mode` API contract.
--
--- Patch [1]: [PATCH v4 1/8] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area ---
commit 66226034e9e83eee2fe85a1e6e86baa666a0331b
Author: Heiko Carstens <hca@linux.ibm.com>
KVM: s390: pv: Use VM_SPARSE area for guest variable storage area
The patch replaces a standard vmalloc allocation for the guest variable
storage area with a custom VM_SPARSE area allocated via get_vm_area(). It
populates and tears down this memory using apply_to_page_range() and
apply_to_existing_page_range() callbacks.
> diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
> --- a/arch/s390/kernel/uv.c
> +++ b/arch/s390/kernel/uv.c
[ ... ]
> +static int uv_free_range_cb(pte_t *ptep, unsigned long addr, void *data)
> +{
> + pte_t pte = ptep_get(ptep);
> +
> + if (!pte_present(pte))
> + return 0;
> + /*
> + * Note: do not update the pte here, since there is no code which
> + * accesses the memory range, besides bugs. The invalidation of ptes
> + * and TLB flushing is deferred like for regular vfree() calls.
> + */
> + __free_page(pte_page(pte));
[Severity: High]
Does freeing the physical page without clearing the page table entry introduce
a regression where the memory could be reallocated while the kernel retains
a valid mapping to it?
The comment mentions that vfree() defers PTE invalidation, but standard
vfree() clears PTEs synchronously and only defers the TLB flush.
Because apply_to_existing_page_range() returns before free_vm_area() is
called to unmap the area, could speculative execution or a hardware page
table walk access the new owner's memory after it has been returned to the
buddy allocator?
> + return 0;
> +}
[ ... ]
> +static int uv_alloc_range_cb(pte_t *ptep, unsigned long addr, void *data)
> +{
> + struct page *page;
> + pte_t pte;
> +
> + page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
[Severity: Medium]
Is it safe to use sleeping allocation flags during this page table walk?
The apply_to_page_range() function wraps iteration in lazy_mmu_mode_enable()
and lazy_mmu_mode_disable(). The MM page table guidelines state that lazy
MMU mode implies a possible atomic context because it disables preemption on
some architectures, meaning pte_fn_t callbacks must not sleep.
Could this cause a regression if the callback blocks, and would it be better
to use a non-sleeping allocation flag to conform to the apply_to_page_range()
contract?
> + if (!page)
> + return -ENOMEM;
> + pte = __pte(page_to_phys(page) | pgprot_val(PAGE_KERNEL));
> + set_pte(ptep, pte);
> + return 0;
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720085834.898025-1-hca@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-07-20 9:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 8:58 [PATCH v4 0/8] s390: Reintroduce support for DCACHE_WORD_ACCESS Heiko Carstens
2026-07-20 8:58 ` [PATCH v4 1/8] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area Heiko Carstens
2026-07-20 9:14 ` sashiko-bot [this message]
2026-07-20 9:56 ` Christian Borntraeger
2026-07-20 10:15 ` Heiko Carstens
2026-07-20 8:58 ` [PATCH v4 2/8] s390/mm: Add missing mm check to do_secure_storage_access() Heiko Carstens
2026-07-20 9:12 ` sashiko-bot
2026-07-20 10:44 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 3/8] s390/mm: Use lock_mm_and_find_vma() in do_secure_storage_access() Heiko Carstens
2026-07-20 9:19 ` sashiko-bot
2026-07-20 10:45 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 4/8] s390/mm: Fix handling of vmalloc area " Heiko Carstens
2026-07-20 9:23 ` sashiko-bot
2026-07-20 10:22 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 5/8] s390/mm: Remove folio handling for kernel faults " Heiko Carstens
2026-07-20 9:30 ` sashiko-bot
2026-07-20 10:53 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 6/8] s390/mm: Use handle_fault_error() " Heiko Carstens
2026-07-20 9:26 ` sashiko-bot
2026-07-20 8:58 ` [PATCH v4 7/8] s390/mm: Use goto statement " Heiko Carstens
2026-07-20 9:36 ` sashiko-bot
2026-07-20 10:36 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 8/8] s390: Add support for DCACHE_WORD_ACCESS (again) Heiko Carstens
2026-07-20 9:48 ` sashiko-bot
2026-07-21 9:59 ` Sven Schnelle
2026-07-20 9:03 ` [PATCH v4 0/8] s390: Reintroduce support for DCACHE_WORD_ACCESS Christian Borntraeger
2026-07-20 9:40 ` Heiko Carstens
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=20260720091419.499CE1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@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