diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-31 00:26:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-31 00:29:26 +0200 |
commit | 3023a89e9b9c9fcd9f1eea87e707054013d70625 (patch) | |
tree | 0d54b525f56d81c86661276bd031ac7a86975156 /Kernel/Net/Socket.cpp | |
parent | 292cd53192e019cbc3b860bfcad99972cff2a29b (diff) | |
download | serenity-3023a89e9b9c9fcd9f1eea87e707054013d70625.zip |
Kernel: Remove SmapDisabler in sys$setsockopt()
Diffstat (limited to 'Kernel/Net/Socket.cpp')
-rw-r--r-- | Kernel/Net/Socket.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index 99c17d066a..22c2022fb9 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -101,24 +101,26 @@ KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer) return KSuccess; } -KResult Socket::setsockopt(int level, int option, const void* value, socklen_t value_size) +KResult Socket::setsockopt(int level, int option, const void* user_value, socklen_t user_value_size) { ASSERT(level == SOL_SOCKET); switch (option) { case SO_SNDTIMEO: - if (value_size != sizeof(timeval)) + if (user_value_size != sizeof(timeval)) return KResult(-EINVAL); - m_send_timeout = *(const timeval*)value; + copy_from_user(&m_send_timeout, (const timeval*)user_value); return KSuccess; case SO_RCVTIMEO: - if (value_size != sizeof(timeval)) + if (user_value_size != sizeof(timeval)) return KResult(-EINVAL); - m_receive_timeout = *(const timeval*)value; + copy_from_user(&m_receive_timeout, (const timeval*)user_value); return KSuccess; case SO_BINDTODEVICE: { - if (value_size != IFNAMSIZ) + if (user_value_size != IFNAMSIZ) return KResult(-EINVAL); - StringView ifname { (const char*)value }; + auto ifname = Process::current()->validate_and_copy_string_from_user((const char*)user_value, user_value_size); + if (ifname.is_null()) + return KResult(-EFAULT); auto device = NetworkAdapter::lookup_by_name(ifname); if (!device) return KResult(-ENODEV); |