From ad0c1e15e0fcfa09d9d74845f09eca537e9341ac Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Thu, 27 Mar 2025 16:41:58 +0000 Subject: [PATCH] fix(kernel/syscalls): add null check for argp in linux_ioctl function Signed-off-by: EnderIce2 --- Kernel/subsystem/linux/syscall.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Kernel/subsystem/linux/syscall.cpp b/Kernel/subsystem/linux/syscall.cpp index 7d474c28..3c5df14e 100644 --- a/Kernel/subsystem/linux/syscall.cpp +++ b/Kernel/subsystem/linux/syscall.cpp @@ -1146,9 +1146,13 @@ static int linux_ioctl(SysFrm *, int fd, unsigned long request, void *argp) vfs::FileDescriptorTable *fdt = pcb->FileDescriptors; Memory::VirtualMemoryArea *vma = pcb->vma; - auto pArgp = vma->UserCheckAndGetAddress(argp); - if (pArgp == nullptr) - return -linux_EFAULT; + void *pArgp = nullptr; + if (argp != nullptr) + { + pArgp = vma->UserCheckAndGetAddress(argp); + if (pArgp == nullptr) + return -linux_EFAULT; + } int ret = ConvertErrnoToLinux(fdt->usr_ioctl(fd, request, pArgp)); return ret;