diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-06 12:13:48 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-06 12:13:48 +0100 |
commit | 1226fec19e4f30180690c44c9a526ccd764dd88f (patch) | |
tree | b66019422e3f6bad3e7cacd6f68d185300732af4 | |
parent | 08cfcb888c44f94ca86a56efd3a8f82b086f182e (diff) | |
download | serenity-1226fec19e4f30180690c44c9a526ccd764dd88f.zip |
Kernel: Remove SmapDisablers in stat() and lstat()
-rw-r--r-- | Kernel/Process.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 4249f45139..f19bf33530 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1508,9 +1508,9 @@ int Process::sys$fstat(int fd, stat* statbuf) return description->fstat(*statbuf); } -int Process::sys$lstat(const char* user_path, size_t path_length, stat* statbuf) +int Process::sys$lstat(const char* user_path, size_t path_length, stat* user_statbuf) { - if (!validate_write_typed(statbuf)) + if (!validate_write_typed(user_statbuf)) return -EFAULT; auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) @@ -1518,13 +1518,17 @@ int Process::sys$lstat(const char* user_path, size_t path_length, stat* statbuf) auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory(), O_NOFOLLOW_NOERROR); if (metadata_or_error.is_error()) return metadata_or_error.error(); - SmapDisabler disabler; - return metadata_or_error.value().stat(*statbuf); + stat statbuf; + auto result = metadata_or_error.value().stat(statbuf); + if (result.is_error()) + return result; + copy_to_user(user_statbuf, &statbuf, sizeof(statbuf)); + return 0; } -int Process::sys$stat(const char* user_path, size_t path_length, stat* statbuf) +int Process::sys$stat(const char* user_path, size_t path_length, stat* user_statbuf) { - if (!validate_write_typed(statbuf)) + if (!validate_write_typed(user_statbuf)) return -EFAULT; auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) @@ -1532,8 +1536,12 @@ int Process::sys$stat(const char* user_path, size_t path_length, stat* statbuf) auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory()); if (metadata_or_error.is_error()) return metadata_or_error.error(); - SmapDisabler disabler; - return metadata_or_error.value().stat(*statbuf); + stat statbuf; + auto result = metadata_or_error.value().stat(statbuf); + if (result.is_error()) + return result; + copy_to_user(user_statbuf, &statbuf, sizeof(statbuf)); + return 0; } int Process::sys$readlink(const char* path, char* buffer, ssize_t size) |