mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel: Use Userspace<T> for the execve syscall
This commit is contained in:
parent
025a2a3c5b
commit
0f42463eab
Notes:
sideshowbarker
2024-07-19 04:06:27 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/0f42463eabe Pull-request: https://github.com/SerenityOS/serenity/pull/3062 Reviewed-by: https://github.com/awesomekling
5 changed files with 8 additions and 8 deletions
|
@ -957,7 +957,7 @@ int Emulator::virt$execve(FlatPtr params_addr)
|
|||
auto copy_string_list = [this](auto& output_vector, auto& string_list) {
|
||||
for (size_t i = 0; i < string_list.length; ++i) {
|
||||
Syscall::StringArgument string;
|
||||
mmu().copy_from_vm(&string, (FlatPtr)&string_list.strings[i], sizeof(string));
|
||||
mmu().copy_from_vm(&string, (FlatPtr)&string_list.strings.ptr()[i], sizeof(string));
|
||||
output_vector.append(String::copy(mmu().copy_buffer_from_vm((FlatPtr)string.characters, string.length)));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -241,7 +241,7 @@ struct ImmutableBufferArgument {
|
|||
};
|
||||
|
||||
struct StringListArgument {
|
||||
StringArgument* strings { nullptr };
|
||||
Userspace<StringArgument*> strings { };
|
||||
size_t length { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ public:
|
|||
int sys$ttyname(int fd, Userspace<char*>, size_t);
|
||||
int sys$ptsname(int fd, Userspace<char*>, size_t);
|
||||
pid_t sys$fork(RegisterState&);
|
||||
int sys$execve(const Syscall::SC_execve_params*);
|
||||
int sys$execve(Userspace<const Syscall::SC_execve_params*>);
|
||||
int sys$dup(int oldfd);
|
||||
int sys$dup2(int oldfd, int newfd);
|
||||
int sys$sigaction(int signum, const sigaction* act, sigaction* old_act);
|
||||
|
|
|
@ -544,7 +544,7 @@ int Process::exec(String path, Vector<String> arguments, Vector<String> environm
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$execve(const Syscall::SC_execve_params* user_params)
|
||||
int Process::sys$execve(Userspace<const Syscall::SC_execve_params*> user_params)
|
||||
{
|
||||
REQUIRE_PROMISE(exec);
|
||||
|
||||
|
@ -568,14 +568,14 @@ int Process::sys$execve(const Syscall::SC_execve_params* user_params)
|
|||
path = path_arg.value();
|
||||
}
|
||||
|
||||
auto copy_user_strings = [&](const auto& list, auto& output) {
|
||||
auto copy_user_strings = [this](const auto& list, auto& output) {
|
||||
if (!list.length)
|
||||
return true;
|
||||
if (!validate_read_typed(list.strings, list.length))
|
||||
return false;
|
||||
Vector<Syscall::StringArgument, 32> strings;
|
||||
strings.resize(list.length);
|
||||
copy_from_user(strings.data(), list.strings, list.length * sizeof(Syscall::StringArgument));
|
||||
copy_from_user(strings.data(), list.strings.unsafe_userspace_ptr(), list.length * sizeof(Syscall::StringArgument));
|
||||
for (size_t i = 0; i < list.length; ++i) {
|
||||
auto string = validate_and_copy_string_from_user(strings[i]);
|
||||
if (string.is_null())
|
||||
|
|
|
@ -94,8 +94,8 @@ int execve(const char* filename, char* const argv[], char* const envp[])
|
|||
auto copy_strings = [&](auto& vec, size_t count, auto& output) {
|
||||
output.length = count;
|
||||
for (size_t i = 0; vec[i]; ++i) {
|
||||
output.strings[i].characters = vec[i];
|
||||
output.strings[i].length = strlen(vec[i]);
|
||||
output.strings.ptr()[i].characters = vec[i];
|
||||
output.strings.ptr()[i].length = strlen(vec[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue