diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-05-02 20:08:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-05-05 20:47:38 +0200 |
commit | 098af0f846a87b651731780ff48420205fd33754 (patch) | |
tree | 13ef406325e5bac0f442c1e942c23bc683126d8f | |
parent | 6d59d4d3d9e76e39112842ec487840828f1c9bfe (diff) | |
download | serenity-098af0f846a87b651731780ff48420205fd33754.zip |
Kernel: Properly define `IOV_MAX`
-rw-r--r-- | Kernel/API/POSIX/sys/uio.h | 3 | ||||
-rw-r--r-- | Kernel/Syscalls/read.cpp | 3 | ||||
-rw-r--r-- | Kernel/Syscalls/write.cpp | 3 |
3 files changed, 5 insertions, 4 deletions
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<FlatPtr> Process::sys$readv(int fd, Userspace<const struct iovec*> 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<FlatPtr> Process::sys$writev(int fd, Userspace<const struct iovec*> 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; |