[Pal/Linux-SGX] Fix UDP bug with connect() in sgx_ocall_sock_connect()

Before, connect() host-OS syscall was issued unconditionally in
sgx_ocall_sock_connect(). However, UDP clients do not strictly need to
issue connect() before sending packets to UDP server. In this case, addr
is NULL, and sgx_ocall_sock_connect() must not issue connect().
This commit is contained in:
Dmitrii Kuvaiskii
2019-05-03 12:50:03 -07:00
parent 121fc9bf1d
commit 76fa183257
+12 -10
View File
@@ -378,19 +378,21 @@ static int sgx_ocall_sock_connect(void * pms)
goto err_fd;
}
ret = INLINE_SYSCALL(connect, 3, fd, ms->ms_addr, ms->ms_addrlen);
if (ms->ms_addr) {
ret = INLINE_SYSCALL(connect, 3, fd, ms->ms_addr, ms->ms_addrlen);
if (IS_ERR(ret) && ERRNO(ret) == EINPROGRESS) {
do {
struct pollfd pfd = { .fd = fd, .events = POLLOUT, .revents = 0, };
ret = INLINE_SYSCALL(ppoll, 4, &pfd, 1, NULL, NULL);
} while (IS_ERR(ret) &&
ERRNO(ret) == -EWOULDBLOCK);
if (IS_ERR(ret) && ERRNO(ret) == EINPROGRESS) {
do {
struct pollfd pfd = { .fd = fd, .events = POLLOUT, .revents = 0, };
ret = INLINE_SYSCALL(ppoll, 4, &pfd, 1, NULL, NULL);
} while (IS_ERR(ret) &&
ERRNO(ret) == -EWOULDBLOCK);
}
if (IS_ERR(ret))
goto err_fd;
}
if (IS_ERR(ret))
goto err_fd;
if (ms->ms_bind_addr && !ms->ms_bind_addr->sa_family) {
socklen_t addrlen;
ret = INLINE_SYSCALL(getsockname, 3, fd, ms->ms_bind_addr,