Kernel: Remove SmapDisabler in sys$accept()

This commit is contained in:
Andreas Kling 2020-02-16 08:20:54 +01:00
parent 7717084ac7
commit 7a8be7f777
Notes: sideshowbarker 2024-07-19 09:16:56 +09:00

View file

@ -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);