]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: arm64: Fix off-by-one in range_is_memory
authorDavid Brazdil <dbrazdil@google.com>
Wed, 28 Jul 2021 15:32:31 +0000 (15:32 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Aug 2021 07:07:03 +0000 (09:07 +0200)
[ Upstream commit facee1be7689f8cf573b9ffee6a5c28ee193615e ]

Hyp checks whether an address range only covers RAM by checking the
start/endpoints against a list of memblock_region structs. However,
the endpoint here is exclusive but internally is treated as inclusive.
Fix the off-by-one error that caused valid address ranges to be
rejected.

Cc: Quentin Perret <qperret@google.com>
Fixes: 90134ac9cabb6 ("KVM: arm64: Protect the .hyp sections from the host")
Signed-off-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210728153232.1018911-2-dbrazdil@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm64/kvm/hyp/nvhe/mem_protect.c

index 4b60c0056c041521ffba9b9f0505ca605404aed2..fa1b77fe629dc2838e187ab3fb7e53504660dac3 100644 (file)
@@ -190,7 +190,7 @@ static bool range_is_memory(u64 start, u64 end)
 {
        struct kvm_mem_range r1, r2;
 
-       if (!find_mem_range(start, &r1) || !find_mem_range(end, &r2))
+       if (!find_mem_range(start, &r1) || !find_mem_range(end - 1, &r2))
                return false;
        if (r1.start != r2.start)
                return false;