mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 22:01:29 +00:00
[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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user