From 9a3b936aee427652849705ed9e820aa7cb3045ab Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 19 Jan 2019 19:14:56 +0000 Subject: [PATCH] usermem: fix dumb error where some out of range addresses were not errorred --- Kernel/usermem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Kernel/usermem.c b/Kernel/usermem.c index 6a966645..4490247b 100644 --- a/Kernel/usermem.c +++ b/Kernel/usermem.c @@ -16,7 +16,8 @@ /* This checks to see if a user-supplied address is legitimate */ usize_t valaddr(const char *base, usize_t size) { - if (!base || base < (const char *)PROGBASE || base + size < base) + if (!base || base < (const char *)PROGBASE || base + size < base || + base > (const char *)(size_t)udata.u_top) size = 0; else if (base + size > (const char *)(size_t)udata.u_top) size = (char *)(size_t)udata.u_top - base; -- 2.34.1