Kernel: Harden sys$readv / sys$writev Vector usage against OOM.

This commit is contained in:
Brian Gianforcaro 2021-04-29 01:20:24 -07:00 committed by Andreas Kling
parent cd29eb7867
commit 454d2fd42a
Notes: sideshowbarker 2024-07-18 18:54:11 +09:00
2 changed files with 4 additions and 2 deletions

View file

@ -24,7 +24,8 @@ KResultOr<ssize_t> Process::sys$readv(int fd, Userspace<const struct iovec*> iov
u64 total_length = 0;
Vector<iovec, 32> vecs;
vecs.resize(iov_count);
if (!vecs.try_resize(iov_count))
return ENOMEM;
if (!copy_n_from_user(vecs.data(), iov, iov_count))
return EFAULT;
for (auto& vec : vecs) {

View file

@ -23,7 +23,8 @@ KResultOr<ssize_t> Process::sys$writev(int fd, Userspace<const struct iovec*> io
u64 total_length = 0;
Vector<iovec, 32> vecs;
vecs.resize(iov_count);
if (!vecs.try_resize(iov_count))
return ENOMEM;
if (!copy_n_from_user(vecs.data(), iov, iov_count))
return EFAULT;
for (auto& vec : vecs) {