1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:18:12 +00:00

Kernel: Make Process::file_description() vend a RefPtr<FileDescription>

This encourages callers to strongly reference file descriptions while
working with them.

This fixes a use-after-free issue where one thread would close() an
open fd while another thread was blocked on it becoming readable.

Test: Kernel/uaf-close-while-blocked-in-read.cpp
This commit is contained in:
Andreas Kling 2020-01-07 15:53:42 +01:00
parent a47f3031ae
commit 5387a19268
4 changed files with 66 additions and 46 deletions

View file

@ -81,8 +81,7 @@ public:
bool in_group(gid_t) const;
FileDescription* file_description(int fd);
const FileDescription* file_description(int fd) const;
RefPtr<FileDescription> file_description(int fd) const;
int fd_flags(int fd) const;
template<typename Callback>