All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dongli Zhang" <dongli.zhang@oracle.com>
Cc: "Marc Zyngier" <maz@kernel.org>,
	kvm@vger.kernel.org, "Oliver Upton" <oupton@kernel.org>,
	kvmarm@lists.linux.dev
Subject: Re: [PATCH v2 1/4] KVM: Move last_steal to common struct kvm_vcpu
Date: Fri, 04 Sep 2026 18:07:15 +0000	[thread overview]
Message-ID: <20260904180715.E5CD51F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260904175550.430266-2-dongli.zhang@oracle.com>

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

Pre-existing issues:
- [High] Host-userspace reachable WARN_ON can cause a host crash when updating guest steal time.
--

commit 8f2f1662b1b75cda859eddacb4ef288871960d3d
Author: Dongli Zhang <dongli.zhang@oracle.com>

KVM: Move last_steal to common struct kvm_vcpu

This commit moves the last_steal cache field for the per-vCPU host task's
run_delay from architecture-specific structures into the common struct
kvm_vcpu. It updates x86, arm64, riscv, and loongarch to use this unified
field and introduces the HAVE_KVM_PV_STEAL_TIME config option.

[ ... ]

> diff --git a/arch/riscv/kvm/vcpu_sbi_sta.c b/arch/riscv/kvm/vcpu_sbi_sta.c
> index 60e50296a0085..9a77d3bde7c72 100644
> --- a/arch/riscv/kvm/vcpu_sbi_sta.c
> +++ b/arch/riscv/kvm/vcpu_sbi_sta.c
[ ... ]
> @@ -67,8 +67,8 @@ void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu)
>  
>  	if (!WARN_ON(get_user(steal_le, steal_ptr))) {
>  		steal = le64_to_cpu(steal_le);
> -		vcpu->arch.sta.last_steal = READ_ONCE(current->sched_info.run_delay);
> -		steal += vcpu->arch.sta.last_steal - last_steal;
> +		vcpu->last_steal = READ_ONCE(current->sched_info.run_delay);
> +		steal += vcpu->last_steal - last_steal;
>  		WARN_ON(put_user(cpu_to_le64(steal), steal_ptr));
>  	}
>  

[Severity: High]
This is a pre-existing issue, but I noticed these WARN_ON() macros wrapping
get_user() and put_user() accesses to host-userspace memory in 
kvm_riscv_vcpu_record_steal_time() (as well as the sequence_ptr accesses
just above this block).

Could a malicious host-userspace process trigger these kernel warnings by
unmapping the shared memory area or protecting it with mprotect(PROT_NONE)
before this function runs?

If the virtual memory area is made inaccessible, get_user() or put_user()
will fail with -EFAULT, causing the WARN_ON() to fire. This allows
unprivileged host userspace to trigger a host kernel panic if panic_on_warn
is enabled.

Would it be better to handle these user-memory access checks as normal error
paths without the WARN_ON() wrappers?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904175550.430266-1-dongli.zhang@oracle.com?part=1

  reply	other threads:[~2026-09-04 18:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 17:55 [PATCH v2 0/4] KVM: Reset steal time accounting on vCPU pid change Dongli Zhang
2026-09-04 17:55 ` Dongli Zhang
2026-09-04 17:55 ` [PATCH v2 1/4] KVM: Move last_steal to common struct kvm_vcpu Dongli Zhang
2026-09-04 17:55   ` Dongli Zhang
2026-09-04 18:07   ` sashiko-bot [this message]
2026-09-04 20:22     ` Dongli Zhang
2026-09-04 20:22       ` Dongli Zhang
2026-09-06 17:13   ` Fuad Tabba
2026-09-06 17:13     ` Fuad Tabba
2026-09-04 17:55 ` [PATCH v2 2/4] KVM: Reset last_steal on vCPU pid change Dongli Zhang
2026-09-04 17:55   ` Dongli Zhang
2026-09-06 17:19   ` Fuad Tabba
2026-09-06 17:19     ` Fuad Tabba
2026-09-04 17:55 ` [PATCH v2 3/4] KVM: selftests: Test steal time across vCPU pid changes on x86 Dongli Zhang
2026-09-04 17:55   ` Dongli Zhang
2026-09-04 18:11   ` sashiko-bot
2026-09-04 20:27     ` Dongli Zhang
2026-09-06 17:27   ` Fuad Tabba
2026-09-06 17:27     ` Fuad Tabba
2026-09-04 17:55 ` [PATCH v2 4/4] KVM: selftests: Add arm64 coverage for steal time pid changes Dongli Zhang
2026-09-04 17:55   ` Dongli Zhang
2026-09-06 17:04 ` [PATCH v2 0/4] KVM: Reset steal time accounting on vCPU pid change Fuad Tabba
2026-09-06 17:04   ` Fuad Tabba

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=20260904180715.E5CD51F00A3E@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dongli.zhang@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@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.