From 098af0f846a87b651731780ff48420205fd33754 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 2 May 2022 20:08:17 +0200 Subject: Kernel: Properly define `IOV_MAX` --- Kernel/API/POSIX/sys/uio.h | 3 +++ Kernel/Syscalls/read.cpp | 3 +-- Kernel/Syscalls/write.cpp | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Kernel') diff --git a/Kernel/API/POSIX/sys/uio.h b/Kernel/API/POSIX/sys/uio.h index cbad45055f..be8922ef4f 100644 --- a/Kernel/API/POSIX/sys/uio.h +++ b/Kernel/API/POSIX/sys/uio.h @@ -12,6 +12,9 @@ extern "C" { #endif +// Arbitrary pain threshold. +#define IOV_MAX 1024 + struct iovec { void* iov_base; size_t iov_len; diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp index 1e51933e7c..4392e1f5d9 100644 --- a/Kernel/Syscalls/read.cpp +++ b/Kernel/Syscalls/read.cpp @@ -45,8 +45,7 @@ ErrorOr Process::sys$readv(int fd, Userspace iov, if (iov_count < 0) return EINVAL; - // Arbitrary pain threshold. - if (iov_count > (int)MiB) + if (iov_count > IOV_MAX) return EFAULT; u64 total_length = 0; diff --git a/Kernel/Syscalls/write.cpp b/Kernel/Syscalls/write.cpp index c51e949a3d..d105761ffb 100644 --- a/Kernel/Syscalls/write.cpp +++ b/Kernel/Syscalls/write.cpp @@ -18,8 +18,7 @@ ErrorOr Process::sys$writev(int fd, Userspace iov, if (iov_count < 0) return EINVAL; - // Arbitrary pain threshold. - if (iov_count > (int)MiB) + if (iov_count > IOV_MAX) return EFAULT; u64 total_length = 0; -- cgit v1.2.3