mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 20:57:41 +00:00
Kernel: Harden sys$readv / sys$writev Vector usage against OOM.
This commit is contained in:
parent
cd29eb7867
commit
454d2fd42a
2 changed files with 4 additions and 2 deletions
|
@ -24,7 +24,8 @@ KResultOr<ssize_t> Process::sys$readv(int fd, Userspace<const struct iovec*> iov
|
||||||
|
|
||||||
u64 total_length = 0;
|
u64 total_length = 0;
|
||||||
Vector<iovec, 32> vecs;
|
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))
|
if (!copy_n_from_user(vecs.data(), iov, iov_count))
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
for (auto& vec : vecs) {
|
for (auto& vec : vecs) {
|
||||||
|
|
|
@ -23,7 +23,8 @@ KResultOr<ssize_t> Process::sys$writev(int fd, Userspace<const struct iovec*> io
|
||||||
|
|
||||||
u64 total_length = 0;
|
u64 total_length = 0;
|
||||||
Vector<iovec, 32> vecs;
|
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))
|
if (!copy_n_from_user(vecs.data(), iov, iov_count))
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
for (auto& vec : vecs) {
|
for (auto& vec : vecs) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue