[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <72bf0b09-6383-d5cd-e719-dcd036b49834@redhat.com>
Date: Mon, 13 Dec 2021 15:22:07 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sasha Levin <sashal@...nel.org>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: kvm@...r.kernel.org
Subject: Re: [PATCH MANUALSEL 5.10 4/4] KVM: downgrade two BUG_ONs to
WARN_ON_ONCE
On 12/13/21 15:20, Sasha Levin wrote:
> From: Paolo Bonzini <pbonzini@...hat.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@...hat.com>
> Signed-off-by: Sasha Levin <sashal@...nel.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 97ac3c6fd4441..4a7d377b3a500 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2590,7 +2590,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))
> @@ -2627,7 +2628,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@...hat.com>
Powered by blists - more mailing lists