KVM: Fix off-by-one error when querying attributes in xarray
Sean Christopherson
reviewerPATCH 1/1 KVM: Fix off-by-one error when querying attributes in xarray
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 <[email protected]>
Signed-off-by Sean Christopherson <[email protected]>
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -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
Signature · 1 line
2.42.0.758.gaed0368e0e-goog
Quoted 6 lines · Sean Christopherson
Subtract -1 from kvm_range_has_memory_attributes()'s @end when using
xas_find(), as "end" is exclusive whereasxas_find()takes an inclusive "max" as the maximal index to find/return.Reported-by Binbin Wu <[email protected]>Signed-off-by Sean Christopherson <[email protected]>
Reviewed-by Binbin Wu<[email protected]>
Quoted 19 lines
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)virt/kvm/kvm_main.c +1
-1@@ -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