mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
Kernel: Remove checks for signed numbers in the prctl syscall
When doing PR_{SET,GET}_PROCESS_NAME, it's not expected to pass a signed integer for the buffer size (in arg2). Therefore, cast it immediately to a size_t integer type, and let the FixedStringBuffer StdLib memory copy functions in such cases to worry about possible overflows.
This commit is contained in:
parent
13e2ca6b59
commit
6cb88e224e
Notes:
sideshowbarker
2024-07-16 22:34:39 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/6cb88e224e Pull-request: https://github.com/SerenityOS/serenity/pull/20666 Reviewed-by: https://github.com/timschumi ✅
1 changed files with 1 additions and 7 deletions
|
@ -52,10 +52,7 @@ ErrorOr<FlatPtr> Process::sys$prctl(int option, FlatPtr arg1, FlatPtr arg2)
|
|||
case PR_SET_PROCESS_NAME: {
|
||||
TRY(require_promise(Pledge::proc));
|
||||
Userspace<char const*> buffer = arg1;
|
||||
int user_buffer_size = static_cast<int>(arg2);
|
||||
if (user_buffer_size < 0)
|
||||
return EINVAL;
|
||||
size_t buffer_size = static_cast<size_t>(user_buffer_size);
|
||||
size_t buffer_size = static_cast<size_t>(arg2);
|
||||
Process::Name process_name {};
|
||||
TRY(try_copy_name_from_user_into_fixed_string_buffer<32>(buffer, process_name, buffer_size));
|
||||
// NOTE: Reject empty and whitespace-only names, as they only confuse users.
|
||||
|
@ -67,9 +64,6 @@ ErrorOr<FlatPtr> Process::sys$prctl(int option, FlatPtr arg1, FlatPtr arg2)
|
|||
case PR_GET_PROCESS_NAME: {
|
||||
TRY(require_promise(Pledge::stdio));
|
||||
Userspace<char*> buffer = arg1;
|
||||
int user_buffer_size = arg2;
|
||||
if (user_buffer_size < 0)
|
||||
return EINVAL;
|
||||
size_t buffer_size = static_cast<size_t>(arg2);
|
||||
TRY(m_name.with([&buffer, buffer_size](auto& name) -> ErrorOr<void> {
|
||||
auto view = name.representable_view();
|
||||
|
|
Loading…
Add table
Reference in a new issue