summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-16 08:20:54 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-16 08:20:54 +0100
commit7a8be7f777510a1d13620fbd0c8bdad69cfe0e03 (patch)
treef2d9c932ec021bb15ca28a044411b8f0c58d971b /Kernel
parent7717084ac783d97e241bcd23ccd61f7abaa43a96 (diff)
downloadserenity-7a8be7f777510a1d13620fbd0c8bdad69cfe0e03.zip
Kernel: Remove SmapDisabler in sys$accept()
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index eb26c97327..5f8b3a7374 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -3157,13 +3157,14 @@ int Process::sys$listen(int sockfd, int backlog)
return socket.listen(backlog);
}
-int Process::sys$accept(int accepting_socket_fd, sockaddr* address, socklen_t* address_size)
+int Process::sys$accept(int accepting_socket_fd, sockaddr* user_address, socklen_t* user_address_size)
{
REQUIRE_PROMISE(accept);
- if (!validate_write_typed(address_size))
+ if (!validate_write_typed(user_address_size))
return -EFAULT;
- SmapDisabler disabler;
- if (!validate_write(address, *address_size))
+ socklen_t address_size = 0;
+ copy_from_user(&address_size, user_address_size);
+ if (!validate_write(user_address, address_size))
return -EFAULT;
int accepted_socket_fd = alloc_fd();
if (accepted_socket_fd < 0)
@@ -3184,7 +3185,13 @@ int Process::sys$accept(int accepting_socket_fd, sockaddr* address, socklen_t* a
}
auto accepted_socket = socket.accept();
ASSERT(accepted_socket);
- accepted_socket->get_peer_address(address, address_size);
+
+ u8 address_buffer[sizeof(sockaddr_un)];
+ address_size = min(sizeof(sockaddr_un), static_cast<size_t>(address_size));
+ accepted_socket->get_peer_address((sockaddr*)address_buffer, &address_size);
+ copy_to_user(user_address, address_buffer, address_size);
+ copy_to_user(user_address_size, &address_size);
+
auto accepted_socket_description = FileDescription::create(*accepted_socket);
accepted_socket_description->set_readable(true);
accepted_socket_description->set_writable(true);