From af28a8ad117924f00b227418a2d4a3040bc47dad Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 29 Dec 2020 13:32:08 +0100 Subject: [PATCH] Kernel: Hold InodeVMObject reference while inspecting it in sys$mmap() --- Kernel/Syscalls/mmap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index a647cf2020..a5209cb476 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -68,10 +68,10 @@ static bool validate_inode_mmap_prot(const Process& process, int prot, const Ino if ((prot & PROT_WRITE) && !metadata.may_write(process)) return false; InterruptDisabler disabler; - if (inode.shared_vmobject()) { - if ((prot & PROT_EXEC) && inode.shared_vmobject()->writable_mappings()) + if (auto shared_vmobject = inode.shared_vmobject()) { + if ((prot & PROT_EXEC) && shared_vmobject->writable_mappings()) return false; - if ((prot & PROT_WRITE) && inode.shared_vmobject()->executable_mappings()) + if ((prot & PROT_WRITE) && shared_vmobject->executable_mappings()) return false; } }