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.
This commit is contained in:
Andreas Kling 2020-11-23 15:48:45 +01:00
parent bb9c705fc2
commit 086522537e
Notes: sideshowbarker 2024-07-19 01:18:01 +09:00

View file

@ -486,7 +486,7 @@ int Process::exec(String path, Vector<String> arguments, Vector<String> 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