From: sashiko-bot@kernel.org
To: "SeungJu Cheon" <suunj1331@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: riscv: Set Accessed bit in dirty-log write fault fast path
Date: Fri, 16 Oct 2026 10:26:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-174168@kernel.org> (raw)
In-Reply-To: <20261016101458.221648-1-suunj1331@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] kvm: riscv: host memory corruption via dirty logging fast path
--
commit b1648eda48b2a005ceca6ca39f80fd20aed60966
Author: SeungJu Cheon <suunj1331@gmail.com>
KVM: riscv: Set Accessed bit in dirty-log write fault fast path
This patch fixes an issue where the fast path for dirty logging write
faults loops indefinitely on hardware that faults when the Accessed bit
is clear. It ensures the accessed bit is set alongside write and dirty
bits.
Cc: stable@vger.kernel.org # 7.2+
> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> index 371fccaf9df08..21637b7959730 100644
> --- a/arch/riscv/kvm/mmu.c
> +++ b/arch/riscv/kvm/mmu.c
[ ... ]
> @@ -591,14 +591,15 @@ static bool kvm_riscv_mmu_dirty_log_write_fault_fast(struct kvm *kvm,
[ ... ]
> - new_pte = pte_mkdirty(pte_mkwrite_novma(old_pte));
> + new_pte = pte_mkyoung(pte_mkdirty(pte_mkwrite_novma(old_pte)));
[Severity: Critical]
Does this unconditionally set the _PAGE_WRITE bit on the stage-2 PTE
without verifying if the original mapping was host-writable?
When dirty logging is enabled, a guest write to a previously read-only
mapped page can trigger kvm_riscv_mmu_map() with logging enabled:
kvm_riscv_mmu_map()
if (is_write && logging &&
kvm_riscv_mmu_dirty_log_write_fault_fast(kvm, memslot, gpa, out_map))
return 0;
If we unconditionally add _PAGE_WRITE here via pte_mkwrite_novma(),
could an unprivileged guest bypass host write-protection by reading an
unallocated page (like the shared zero page) and then writing to it
during live migration?
This appears to bypass the host writability checks in the slow path's
__kvm_faultin_pfn(), which might allow a guest to write directly into
host read-only pages, such as CoW mappings or the shared zero page.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016101458.221648-1-suunj1331@gmail.com?part=1
prev parent reply other threads:[~2026-10-16 10:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 10:14 [PATCH] KVM: riscv: Set Accessed bit in dirty-log write fault fast path SeungJu Cheon
2026-10-16 10:26 ` sashiko-bot [this message]
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=sashiko-outbox-174168@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=suunj1331@gmail.com \
/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