From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: linux-s390@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
kvm@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v4 7/8] s390/mm: Use goto statement in do_secure_storage_access()
Date: Mon, 20 Jul 2026 09:36:19 +0000 [thread overview]
Message-ID: <20260720093619.9D8371F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720085834.898025-8-hca@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Stale TLB / Premature Page Freeing in VM_SPARSE area teardown
- [High] Invalid physical address translation for module addresses
--
--- Patch [7]: [PATCH v4 7/8] s390/mm: Use goto statement in do_secure_storage_access() ---
commit e37b9a92584a0cc071d6b45d285a37b7eb5137cc
Author: Heiko Carstens <hca@linux.ibm.com>
s390/mm: Use goto statement in do_secure_storage_access()
This patch refactors do_secure_storage_access() to use a goto statement
for unlocking mmap_read_unlock. It removes an open-coded unlock to make
it look more like do_exception().
> diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
> index 2a9b9fb30d09c..666fe8e994801 100644
> --- a/arch/s390/mm/fault.c
> +++ b/arch/s390/mm/fault.c
> @@ -453,10 +453,8 @@ void do_secure_storage_access(struct pt_regs *regs)
[ ... ]
> folio_walk_end(&fw, vma);
> if (rc)
> return handle_fault_error(regs, SEGV_ACCERR);
> +out:
> mmap_read_unlock(mm);
> }
> }
While reviewing the changes in do_secure_storage_access(), I noticed a
potential regression earlier in the same function:
arch/s390/mm/fault.c:do_secure_storage_access() {
...
if (is_vmalloc_addr((void *)addr))
return handle_fault_error_nolock(regs, 0);
rc = uv_convert_from_secure(__pa(addr));
...
}
[Severity: High]
Does this incomplete vmalloc check allow module addresses to fall through
to the invalid __pa() translation?
On s390, module memory resides outside the VMALLOC_START..VMALLOC_END
range, so the is_vmalloc_addr() check returns false for module addresses.
The code then falls through to uv_convert_from_secure(__pa(addr)).
Since module addresses are not direct-mapped, __pa(addr) generates a
garbage physical address.
If this garbage address aligns with a valid physical page currently donated
to another guest as secure memory, would the Ultravisor erroneously convert
it, destroying the unrelated guest's secure state?
Should this check use is_vmalloc_or_module_addr() instead?
Also, looking at the VM_SPARSE area teardown sequence:
arch/s390/kernel/uv.c:uv_free_stor_var() {
...
apply_to_existing_page_range(&init_mm, addr, size, uv_free_range_cb, NULL);
free_vm_area(area);
...
}
arch/s390/kernel/uv.c:uv_free_range_cb() {
...
__free_page(pte_page(*pte));
return 0;
...
}
[Severity: High]
Can this sequence cause a stale TLB or premature page freeing during
VM_SPARSE area teardown?
This sequence frees the physical pages to the buddy allocator while
intentionally leaving the kernel PTEs valid. The PTEs are only cleared
and the TLB flushed later by free_vm_area().
During this window, could any speculative or stray access to the vmalloc
address access the physical page through the valid PTE/TLB, even though
the page may have already been reallocated to another subsystem or guest,
corrupting memory?
Should the teardown sequence clear the PTEs and flush the TLB before
freeing the physical pages, as is normally done during standard vfree()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720085834.898025-1-hca@linux.ibm.com?part=7
next prev parent reply other threads:[~2026-07-20 9:36 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
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 [this message]
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=20260720093619.9D8371F000E9@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