From 05cf1327ed0bdda7e4898cddf187f0fafe3d2a4e Mon Sep 17 00:00:00 2001 From: implicitfield <114500360+implicitfield@users.noreply.github.com> Date: Sat, 11 May 2024 08:57:42 +0400 Subject: [PATCH] Kernel: Make utimensat ignore the dirfd when given an absolute path --- Kernel/Syscalls/utimensat.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Kernel/Syscalls/utimensat.cpp b/Kernel/Syscalls/utimensat.cpp index 0855b5ee380..6128be1277f 100644 --- a/Kernel/Syscalls/utimensat.cpp +++ b/Kernel/Syscalls/utimensat.cpp @@ -69,8 +69,15 @@ ErrorOr Process::sys$utimensat(Userspace ErrorOr> { + if (!path.is_empty() && path[0] == '/') + return VirtualFileSystem::the().root_custody(); + else + return custody_for_dirfd(params.dirfd); + }; + auto path = TRY(get_syscall_path_argument(params.path)); - auto base = TRY(custody_for_dirfd(params.dirfd)); + auto base = TRY(resolve_base(path->view())); auto& atime = times[0]; auto& mtime = times[1]; TRY(VirtualFileSystem::the().utimensat(credentials(), path->view(), *base, atime, mtime, follow_symlink));