mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +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: b3096276bb
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;
|
nfds_checked *= params.nfds;
|
||||||
if (nfds_checked.has_overflow())
|
if (nfds_checked.has_overflow())
|
||||||
return EFAULT;
|
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()))
|
if (!copy_from_user(fds_copy.data(), ¶ms.fds[0], nfds_checked.value()))
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +175,8 @@ KResultOr<int> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_
|
||||||
block_flags |= BlockFlags::Write;
|
block_flags |= BlockFlags::Write;
|
||||||
if (pfd.events & POLLPRI)
|
if (pfd.events & POLLPRI)
|
||||||
block_flags |= BlockFlags::ReadPriority;
|
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();
|
auto current_thread = Thread::current();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue