mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +00:00
Kernel: Harden sys$poll Vector usage against OOM.
This commit is contained in:
parent
119b7be249
commit
b3096276bb
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