From cb1cf8a31f5e624f30970f8f7cd109356fa79735 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 24 Aug 2024 23:16:55 -0300 Subject: [PATCH] utime: proper auth checks --- kernel-src/sys/syscalls/utime.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel-src/sys/syscalls/utime.c b/kernel-src/sys/syscalls/utime.c index 2e32d1a7..abeaf05f 100644 --- a/kernel-src/sys/syscalls/utime.c +++ b/kernel-src/sys/syscalls/utime.c @@ -1,6 +1,7 @@ #include #include #include +#include syscallret_t syscall_utimensat(context_t *, int fd, char *upath, timespec_t uts[2], int flags) { syscallret_t ret = { @@ -67,6 +68,15 @@ syscallret_t syscall_utimensat(context_t *, int fd, char *upath, timespec_t uts[ attr.atime = ts[0]; attr.mtime = ts[1]; + ret.errno = auth_filesystem_check(&_cpu()->thread->proc->cred, AUTH_ACTIONS_FILESYSTEM_SETATTR, node); + if (ret.errno) { + if (uts == NULL) + ret.errno = VOP_ACCESS(node, V_ACCESS_WRITE, &_cpu()->thread->proc->cred); + + if (ret.errno) + goto cleanup; + } + ret.errno = VOP_SETATTR(node, &attr, V_ATTR_ATIME | V_ATTR_MTIME, &_cpu()->thread->proc->cred); ret.ret = ret.errno ? -1 : 0;