find_vma() will continue to search upwards until the end of the virtual
memory space.  This means the si_code would almost never be set to
SEGV_MAPERR even when the address falls outside of any VMA.

Using find_vma_intersection() allows for what is intended by only
returning a VMA if it falls within the range provided, in this case a
window of 1.

Signed-off-by: Liam R. Howlett <liam.howl...@oracle.com>
---
 arch/alpha/kernel/traps.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index 921d4b6e4d95..7f51386c06d0 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -957,8 +957,10 @@ do_entUnaUser(void __user * va, unsigned long opcode,
                si_code = SEGV_ACCERR;
        else {
                struct mm_struct *mm = current->mm;
+               unsigned long addr = (unsigned long)va;
+
                mmap_read_lock(mm);
-               if (find_vma(mm, (unsigned long)va))
+               if (find_vma_intersection(mm, addr, addr + 1))
                        si_code = SEGV_ACCERR;
                else
                        si_code = SEGV_MAPERR;
-- 
2.30.0

Reply via email to