[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20d4f3fc-7491-dbab-392b-8b914332cafe@linux.intel.com>
Date: Tue, 24 Oct 2023 10:52:03 +0800
From: Binbin Wu <binbin.wu@...ux.intel.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH gmem] KVM: Fix off-by-one error when querying attributes
in xarray
On 10/24/2023 4:35 AM, Sean Christopherson wrote:
> Subtract -1 from kvm_range_has_memory_attributes()'s @end when using
> xas_find(), as "end" is exclusive whereas xas_find() takes an inclusive
> "max" as the maximal index to find/return.
>
> Reported-by: Binbin Wu <binbin.wu@...ux.intel.com>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
Reviewed-by: Binbin Wu<binbin.wu@...ux.intel.com>
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 959e866c84f0..12458959dd25 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2447,7 +2447,7 @@ bool kvm_range_has_memory_attributes(struct kvm *kvm, gfn_t start, gfn_t end,
> rcu_read_lock();
>
> if (!attrs) {
> - has_attrs = !xas_find(&xas, end);
> + has_attrs = !xas_find(&xas, end - 1);
> goto out;
> }
>
>
> base-commit: 911b515af3ec5f53992b9cc162cf7d3893c2fbe2
Powered by blists - more mailing lists