From 086522537eca0b63f8dcb45c4852c95d23014d52 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 23 Nov 2020 15:48:45 +0100 Subject: [PATCH] Kernel: Don't leak ref on executable inode in sys$execve() We were leaking a ref on the executed inode in successful calls to sys$execve(). This meant that once a binary had ever been executed, it was impossible to remove it from the file system. The execve system call is particularly finicky since the function does not return normally on success, so extra care must be taken to ensure nothing is kept alive by stack variables. There is a big NOTE comment about this, and yet the bug still got in. It would be nice to enforce this, but I'm unsure how. --- Kernel/Syscalls/execve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 3c888f3705..48a4974982 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -486,7 +486,7 @@ int Process::exec(String path, Vector arguments, Vector environm auto result = VFS::the().open(path, O_EXEC, 0, current_directory()); if (result.is_error()) return result.error(); - auto description = result.value(); + auto description = result.release_value(); auto metadata = description->metadata(); // Always gonna need at least 3 bytes. these are for #!X