usermem: fix dumb error where some out of range addresses were not errorred
authorAlan Cox <alan@linux.intel.com>
Sat, 19 Jan 2019 19:14:56 +0000 (19:14 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 19 Jan 2019 19:14:56 +0000 (19:14 +0000)
Kernel/usermem.c

index 6a96664..4490247 100644 (file)
@@ -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;