summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-11 10:17:08 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-11 10:17:44 +0100
commit6536a80aa9f679e3f0c87e828dcf68c784f4660b (patch)
tree4b6d6c2314ad476ade3c4719852590b3112109f3 /Kernel
parent29b3d95004471578e915f1feee892288b18606f3 (diff)
downloadserenity-6536a80aa9f679e3f0c87e828dcf68c784f4660b.zip
Kernel: Pass a parameter struct to chown()
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp12
-rw-r--r--Kernel/Process.h2
-rw-r--r--Kernel/Syscall.h6
3 files changed, 15 insertions, 5 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 52d860fe14..896457bdec 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -2640,12 +2640,16 @@ int Process::sys$fchown(int fd, uid_t uid, gid_t gid)
return description->chown(uid, gid);
}
-int Process::sys$chown(const char* pathname, uid_t uid, gid_t gid)
+int Process::sys$chown(const Syscall::SC_chown_params* user_params)
{
- SmapDisabler disabler;
- if (!validate_read_str(pathname))
+ if (!validate_read_typed(user_params))
return -EFAULT;
- return VFS::the().chown(StringView(pathname), uid, gid, current_directory());
+ Syscall::SC_chown_params params;
+ copy_from_user(&params, user_params, sizeof(params));
+ auto path = get_syscall_path_argument(params.path.characters, params.path.length);
+ if (path.is_error())
+ return path.error();
+ return VFS::the().chown(path.value(), params.uid, params.gid, current_directory());
}
void Process::finalize()
diff --git a/Kernel/Process.h b/Kernel/Process.h
index f2c9e79f12..e1af793214 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -183,7 +183,7 @@ public:
int sys$umount(const char* mountpoint, size_t mountpoint_length);
int sys$chmod(const char* pathname, size_t path_length, mode_t);
int sys$fchmod(int fd, mode_t);
- int sys$chown(const char* pathname, uid_t, gid_t);
+ int sys$chown(const Syscall::SC_chown_params*);
int sys$fchown(int fd, uid_t, gid_t);
int sys$socket(int domain, int type, int protocol);
int sys$bind(int sockfd, const sockaddr* addr, socklen_t);
diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h
index 6cdf3d31bd..41ed4f6fed 100644
--- a/Kernel/Syscall.h
+++ b/Kernel/Syscall.h
@@ -333,6 +333,12 @@ struct SC_link_params {
StringArgument new_path;
};
+struct SC_chown_params {
+ StringArgument path;
+ u32 uid;
+ u32 gid;
+};
+
void initialize();
int sync();