diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-27 10:46:47 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-27 10:50:24 +0200 |
commit | f4090d46de6e7b10d817aa67add21c37e26f4c9a (patch) | |
tree | 50df136ba56b29746942e5688ef261a1adafecae /Kernel | |
parent | a9906cfcd166e67305bc95f0a5a9b54a53e9afec (diff) | |
download | serenity-f4090d46de6e7b10d817aa67add21c37e26f4c9a.zip |
Kernel: Don't kmalloc() for small (<=1024) dbgputstr() syscalls
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Syscalls/debug.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Kernel/Syscalls/debug.cpp b/Kernel/Syscalls/debug.cpp index 9f17265148..38bf5591f9 100644 --- a/Kernel/Syscalls/debug.cpp +++ b/Kernel/Syscalls/debug.cpp @@ -28,10 +28,18 @@ KResultOr<size_t> Process::sys$dbgputstr(Userspace<const u8*> characters, size_t if (size == 0) return 0; + if (size <= 1024) { + char buffer[1024]; + if (!copy_from_user(buffer, characters, size)) + return EFAULT; + dbgputstr(buffer, size); + return size; + } + auto result = try_copy_kstring_from_user(reinterpret_cast<char const*>(characters.unsafe_userspace_ptr()), size); if (result.is_error()) return result.error(); - dbgputstr(reinterpret_cast<const char*>(result.value()->characters()), size); + dbgputstr(result.value()->characters(), size); return size; } |