Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH v3 5/6] s390/mm: Remove folio handling for kernel faults in do_secure_storage_access()
Date: Sun, 19 Jul 2026 13:14:30 +0000	[thread overview]
Message-ID: <20260719131431.172401F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260719130006.3882764-6-hca@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Kernel accesses with exception fixups (e.g., speculative reads or probe reads) unconditionally destroy active secure guest pages because uv_convert_from_secure() is executed before checking fixup_exception().
--

--- Patch [5]: [PATCH v3 5/6] s390/mm: Remove folio handling for kernel faults in do_secure_storage_access() ---
commit 475be2dbf4868b390a06f3b6bd78b394674a341a
Author: Heiko Carstens <hca@linux.ibm.com>

s390/mm: Remove folio handling for kernel faults in do_secure_storage_access()

This commit removes folio handling and reference counting for secure
storage access exceptions triggered via the kernel mapping. It replaces
the folio_to_phys() conversion with a direct __pa(addr) translation to
avoid data corruption from a known race condition.

> diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
> index e650cdfa25231..776549d55c94a 100644
> --- a/arch/s390/mm/fault.c
> +++ b/arch/s390/mm/fault.c
> @@ -440,13 +440,7 @@ void do_secure_storage_access(struct pt_regs *regs)
>  	if (is_kernel_fault(regs)) {
>  		if (is_vmalloc_addr((void *)addr))
>  			return handle_fault_error_nolock(regs, 0);
> -		folio = virt_to_folio((void *)addr);
> -		if (unlikely(!folio_try_get(folio)))
> -			return;
> -		rc = uv_convert_from_secure(folio_to_phys(folio));
> -		if (!rc)
> -			clear_bit(PG_arch_1, &folio->flags.f);
> -		folio_put(folio);
> +		rc = uv_convert_from_secure(__pa(addr));

[Severity: Critical]
This is a pre-existing issue, but does this unconditionally destroy active
secure guest pages on speculative reads?

Looking at do_secure_storage_access(), uv_convert_from_secure() is called
here before checking fixup_exception(). Because the Ultravisor allows the
host to reclaim active guest memory, uv_convert_from_secure() succeeds for
guest memory, scrubs the page, and returns 0.

Since the conversion succeeds, the code skips calling
handle_fault_error_nolock() where the fixup is actually evaluated:

arch/s390/mm/fault.c:do_secure_storage_access() {
        ...
        rc = uv_convert_from_secure(__pa(addr));
        /*
         * There are some valid fixup types for kernel
         * accesses to donated secure memory. zeropad is one
         * of them.
         */
        if (rc)
                return handle_fault_error_nolock(regs, 0);
        ...
}

If a speculative kernel read (like the mentioned load_unaligned_zeropad)
or an eBPF probe read targets an address in the direct map belonging to a
secure guest, wouldn't this silently destroy the guest's memory instead of
safely executing the fixup?

>  		/*
>  		 * There are some valid fixup types for kernel
>  		 * accesses to donated secure memory. zeropad is one

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260719130006.3882764-1-hca@linux.ibm.com?part=5

  reply	other threads:[~2026-07-19 13:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-19 13:00 [PATCH v3 0/6] s390: Reintroduce support for DCACHE_WORD_ACCESS Heiko Carstens
2026-07-19 13:00 ` [PATCH v3 1/6] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area Heiko Carstens
2026-07-19 13:27   ` sashiko-bot
2026-07-19 13:00 ` [PATCH v3 2/6] s390/mm: Add missing mm check to do_secure_storage_access() Heiko Carstens
2026-07-19 13:13   ` sashiko-bot
2026-07-19 13:00 ` [PATCH v3 3/6] s390/mm: Use lock_mm_and_find_vma() in do_secure_storage_access() Heiko Carstens
2026-07-19 13:06   ` sashiko-bot
2026-07-19 13:00 ` [PATCH v3 4/6] s390/mm: Fix handling of vmalloc area " Heiko Carstens
2026-07-19 13:10   ` sashiko-bot
2026-07-19 13:00 ` [PATCH v3 5/6] s390/mm: Remove folio handling for kernel faults " Heiko Carstens
2026-07-19 13:14   ` sashiko-bot [this message]
2026-07-19 13:00 ` [PATCH v3 6/6] s390: Add support for DCACHE_WORD_ACCESS (again) Heiko Carstens
2026-07-19 13:08   ` 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=20260719131431.172401F000E9@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