|
@@ -7,6 +7,7 @@
|
|
|
#include <Kernel/Debug.h>
|
|
|
#include <Kernel/FileSystem/Custody.h>
|
|
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
|
|
+#include <Kernel/KLexicalPath.h>
|
|
|
#include <Kernel/Net/LocalSocket.h>
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
@@ -27,19 +28,29 @@ ErrorOr<FlatPtr> Process::sys$open(Userspace<Syscall::SC_open_params const*> use
|
|
|
if (options & O_UNLINK_INTERNAL)
|
|
|
return EINVAL;
|
|
|
|
|
|
- if (options & O_WRONLY)
|
|
|
- TRY(require_promise(Pledge::wpath));
|
|
|
- else if (options & O_RDONLY)
|
|
|
- TRY(require_promise(Pledge::rpath));
|
|
|
+ auto path = TRY(get_syscall_path_argument(params.path));
|
|
|
|
|
|
- if (options & O_CREAT)
|
|
|
- TRY(require_promise(Pledge::cpath));
|
|
|
+ // Disable checking open pledges when building userspace with coverage
|
|
|
+ // so that all processes can write out coverage data even with pledges
|
|
|
+ bool skip_pledge_verification = false;
|
|
|
+
|
|
|
+#ifdef SKIP_PATH_VALIDATION_FOR_COVERAGE_INSTRUMENTATION
|
|
|
+ if (KLexicalPath::basename(path->view()).ends_with(".profraw"sv))
|
|
|
+ skip_pledge_verification = true;
|
|
|
+#endif
|
|
|
+ if (!skip_pledge_verification) {
|
|
|
+ if (options & O_WRONLY)
|
|
|
+ TRY(require_promise(Pledge::wpath));
|
|
|
+ else if (options & O_RDONLY)
|
|
|
+ TRY(require_promise(Pledge::rpath));
|
|
|
+
|
|
|
+ if (options & O_CREAT)
|
|
|
+ TRY(require_promise(Pledge::cpath));
|
|
|
+ }
|
|
|
|
|
|
// Ignore everything except permission bits.
|
|
|
mode &= 0777;
|
|
|
|
|
|
- auto path = TRY(get_syscall_path_argument(params.path));
|
|
|
-
|
|
|
dbgln_if(IO_DEBUG, "sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path->view(), options, mode);
|
|
|
|
|
|
auto fd_allocation = TRY(allocate_fd());
|