lkml.org 
[lkml]   [2021]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH MANUALSEL 5.15 8/9] KVM: downgrade two BUG_ONs to WARN_ON_ONCE
From
On 12/13/21 15:19, Sasha Levin wrote:
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> [ Upstream commit 5f25e71e311478f9bb0a8ef49e7d8b95316491d7 ]
>
> This is not an unrecoverable situation. Users of kvm_read_guest_offset_cached
> and kvm_write_guest_offset_cached must expect the read/write to fail, and
> therefore it is possible to just return early with an error value.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> virt/kvm/kvm_main.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index ce1847bc898b2..c6bfd4e15d28a 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3001,7 +3001,8 @@ int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
> int r;
> gpa_t gpa = ghc->gpa + offset;
>
> - BUG_ON(len + offset > ghc->len);
> + if (WARN_ON_ONCE(len + offset > ghc->len))
> + return -EINVAL;
>
> if (slots->generation != ghc->generation) {
> if (__kvm_gfn_to_hva_cache_init(slots, ghc, ghc->gpa, ghc->len))
> @@ -3038,7 +3039,8 @@ int kvm_read_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
> int r;
> gpa_t gpa = ghc->gpa + offset;
>
> - BUG_ON(len + offset > ghc->len);
> + if (WARN_ON_ONCE(len + offset > ghc->len))
> + return -EINVAL;
>
> if (slots->generation != ghc->generation) {
> if (__kvm_gfn_to_hva_cache_init(slots, ghc, ghc->gpa, ghc->len))
>

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

\
 
 \ /
  Last update: 2021-12-13 15:28    [W:0.107 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site