From: sashiko-bot@kernel.org
To: "Shivansh Dhiman" <shivansh.dhiman@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/7] KVM: SVM: Add VMCB fields for LBR v2 virtualization
Date: Fri, 24 Jul 2026 20:08:19 +0000 [thread overview]
Message-ID: <20260724200819.9D22F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724195040.630468-2-shivansh.dhiman@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The `svm_get_nested_state` function writes out-of-bounds to userspace memory if `user_data_size` is exactly `sizeof(struct kvm_nested_state)`.
--
--- Patch [1]: [PATCH 1/7] KVM: SVM: Add VMCB fields for LBR v2 virtualization ---
commit 91df21ca3dd4f3f8277b9ddd8eb84059e0bca6d1
Author: Sandipan Das <sandipan.das@amd.com>
KVM: SVM: Add VMCB fields for LBR v2 virtualization
Define the new VMCB fields that will be used to save and restore the
state of the Last Branch Record Extension Version 2 (LbrExtV2) related
MSRs.
> diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
> index aa63431ba92c3..fbcf6c4dbb92a 100644
> --- a/arch/x86/include/asm/svm.h
> +++ b/arch/x86/include/asm/svm.h
> @@ -552,7 +559,7 @@ struct vmcb {
> };
> } __packed;
>
> -#define EXPECTED_VMCB_SAVE_AREA_SIZE 744
> +#define EXPECTED_VMCB_SAVE_AREA_SIZE 1912
> #define EXPECTED_GHCB_SAVE_AREA_SIZE 1032
> #define EXPECTED_SEV_ES_SAVE_AREA_SIZE 1648
[ ... ]
[Severity: High]
This is a pre-existing issue, but can svm_get_nested_state() write
out-of-bounds to userspace memory if user_data_size is exactly
sizeof(struct kvm_nested_state)?
When user_data_size == kvm_state.size, this initial check evaluates to false:
arch/x86/kvm/svm/nested.c:svm_get_nested_state() {
...
if (user_data_size < kvm_state.size)
goto out;
...
}
The function then proceeds, expanding kvm_state.size, but never re-checks if
the user-provided buffer is large enough before clearing the memory:
arch/x86/kvm/svm/nested.c:svm_get_nested_state() {
...
if (clear_user(user_vmcb, KVM_STATE_NESTED_SVM_VMCB_SIZE))
return -EFAULT;
...
}
Can this corrupt the VMM's memory by writing 4096 bytes past the end of the
user's 120-byte allocation if a VMM dynamically probes the required size?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724195040.630468-1-shivansh.dhiman@amd.com?part=1
next prev parent reply other threads:[~2026-07-24 20:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 19:50 [PATCH 0/7] KVM: SVM: Add support for AMD LBR Extension v2 Shivansh Dhiman
2026-07-24 19:50 ` [PATCH 1/7] KVM: SVM: Add VMCB fields for LBR v2 virtualization Shivansh Dhiman
2026-07-24 20:08 ` sashiko-bot [this message]
2026-07-24 19:50 ` [PATCH 2/7] KVM: SVM: Add capability for LbrExtV2 Shivansh Dhiman
2026-07-24 19:50 ` [PATCH 3/7] KVM: SVM: Emulate guest accesses to LBR v2 MSRs Shivansh Dhiman
2026-07-24 20:13 ` sashiko-bot
2026-07-24 19:50 ` [PATCH 4/7] KVM: SVM: Enable hardware-assisted LBR v2 virtualization Shivansh Dhiman
2026-07-24 20:17 ` sashiko-bot
2026-07-24 19:50 ` [PATCH 5/7] KVM: SVM: Advertise LbrExtV2 to userspace Shivansh Dhiman
2026-07-24 20:06 ` sashiko-bot
2026-07-24 19:50 ` [PATCH 6/7] KVM: SVM: Add LBR/PMC freeze support Shivansh Dhiman
2026-07-24 20:13 ` sashiko-bot
2026-07-24 19:50 ` [PATCH 7/7] KVM: x86: Use SCATTERED_F() for PERFMON_V2 Shivansh Dhiman
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=20260724200819.9D22F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shivansh.dhiman@amd.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 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.