aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2021-05-18 00:56:56 -0700
committerAndrew Waterman <andrew@sifive.com>2021-05-18 00:56:56 -0700
commitc72467e151ac258ba1b8ed24ad8abea7151ffebf (patch)
tree4a677ed436db0c1da63243da15cb6361fa0a5d7d /pk
parent4f1e33558559831d178f7cb73e6c3b21276ef650 (diff)
downloadpk-c72467e151ac258ba1b8ed24ad8abea7151ffebf.zip
pk-c72467e151ac258ba1b8ed24ad8abea7151ffebf.tar.gz
pk-c72467e151ac258ba1b8ed24ad8abea7151ffebf.tar.bz2
Fix range check
Diffstat (limited to 'pk')
-rw-r--r--pk/mmap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pk/mmap.c b/pk/mmap.c
index 3bcfbbe..3d4326c 100644
--- a/pk/mmap.c
+++ b/pk/mmap.c
@@ -277,9 +277,10 @@ static inline pte_t prot_to_type(int prot, int user)
int __valid_user_range(uintptr_t vaddr, size_t len)
{
- if (vaddr + len < vaddr)
+ uintptr_t last_vaddr = vaddr + len - 1;
+ if (last_vaddr < vaddr)
return 0;
- return vaddr + len <= current.mmap_max;
+ return last_vaddr < current.mmap_max;
}
static void flush_tlb_entry(uintptr_t vaddr)