diff options
author | Andreas Kling <kling@serenityos.org> | 2020-01-30 21:55:49 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-01-30 21:55:49 +0100 |
commit | 6634da31d962dcca96b580dad3626980fb064791 (patch) | |
tree | f869581250146548ada0e559e7a65dfd986c4a83 /Kernel | |
parent | bf5b7c32d8435dedd9f80029c454e472b3e16f4b (diff) | |
download | serenity-6634da31d962dcca96b580dad3626980fb064791.zip |
Kernel: Disallow empty ranges in munmap/mprotect/madvise
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 6c933a4d9a..644de98500 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -458,6 +458,9 @@ int Process::sys$munmap(void* addr, size_t size) { REQUIRE_PROMISE(stdio); + if (!size) + return -EINVAL; + if (!is_user_range(VirtualAddress(addr), size)) return -EFAULT; @@ -499,6 +502,9 @@ int Process::sys$mprotect(void* addr, size_t size, int prot) { REQUIRE_PROMISE(stdio); + if (!size) + return -EINVAL; + if (!is_user_range(VirtualAddress(addr), size)) return -EFAULT; @@ -566,6 +572,9 @@ int Process::sys$madvise(void* address, size_t size, int advice) { REQUIRE_PROMISE(stdio); + if (!size) + return -EINVAL; + if (!is_user_range(VirtualAddress(address), size)) return -EFAULT; |