mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Harden sys$poll Vector usage against OOM.
This commit is contained in:
parent
119b7be249
commit
b3096276bb
Notes:
sideshowbarker
2024-07-18 18:54:03 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/b3096276bba Pull-request: https://github.com/SerenityOS/serenity/pull/6733
1 changed files with 4 additions and 2 deletions
|
@ -154,7 +154,8 @@ KResultOr<int> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_
|
|||
nfds_checked *= params.nfds;
|
||||
if (nfds_checked.has_overflow())
|
||||
return EFAULT;
|
||||
fds_copy.resize(params.nfds);
|
||||
if (!fds_copy.try_resize(params.nfds))
|
||||
return ENOMEM;
|
||||
if (!copy_from_user(fds_copy.data(), ¶ms.fds[0], nfds_checked.value()))
|
||||
return EFAULT;
|
||||
}
|
||||
|
@ -174,7 +175,8 @@ KResultOr<int> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_
|
|||
block_flags |= BlockFlags::Write;
|
||||
if (pfd.events & POLLPRI)
|
||||
block_flags |= BlockFlags::ReadPriority;
|
||||
fds_info.append({ description.release_nonnull(), block_flags });
|
||||
if (!fds_info.try_append({ description.release_nonnull(), block_flags }))
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
auto current_thread = Thread::current();
|
||||
|
|
Loading…
Reference in a new issue