projects
/
lttng-ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: concurrent exec(2) file descriptor leak
[lttng-ust.git]
/
src
/
common
/
ustcomm.c
diff --git
a/src/common/ustcomm.c
b/src/common/ustcomm.c
index 2c1836092e0968be1a99192060857c27000cb2ff..917dd4c4073b175ef6fd8f92ad80380d255f5f2b 100644
(file)
--- a/
src/common/ustcomm.c
+++ b/
src/common/ustcomm.c
@@
-60,9
+60,8
@@
int ustcomm_connect_unix_sock(const char *pathname, long timeout)
/*
* libust threads require the close-on-exec flag for all
* resources so it does not leak file descriptors upon exec.
/*
* libust threads require the close-on-exec flag for all
* resources so it does not leak file descriptors upon exec.
- * SOCK_CLOEXEC is not used since it is linux specific.
*/
*/
- fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ fd = socket(PF_UNIX, SOCK_STREAM
| SOCK_CLOEXEC
, 0);
if (fd < 0) {
PERROR("socket");
ret = -errno;
if (fd < 0) {
PERROR("socket");
ret = -errno;
@@
-77,12
+76,6
@@
int ustcomm_connect_unix_sock(const char *pathname, long timeout)
WARN("Error setting connect socket send timeout");
}
}
WARN("Error setting connect socket send timeout");
}
}
- ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
- if (ret < 0) {
- PERROR("fcntl");
- ret = -errno;
- goto error_fcntl;
- }
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
@@
-110,7
+103,6
@@
int ustcomm_connect_unix_sock(const char *pathname, long timeout)
return fd;
error_connect:
return fd;
error_connect:
-error_fcntl:
{
int closeret;
{
int closeret;
@@
-416,7
+408,6
@@
ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
char recv_fd[CMSG_SPACE(sizeof_fds)];
struct msghdr msg;
char dummy;
char recv_fd[CMSG_SPACE(sizeof_fds)];
struct msghdr msg;
char dummy;
- int i;
memset(&msg, 0, sizeof(msg));
memset(&msg, 0, sizeof(msg));
@@
-429,7
+420,7
@@
ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
msg.msg_controllen = sizeof(recv_fd);
do {
msg.msg_controllen = sizeof(recv_fd);
do {
- ret = recvmsg(sock, &msg,
0
);
+ ret = recvmsg(sock, &msg,
MSG_CMSG_CLOEXEC
);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
if (errno != EPIPE && errno != ECONNRESET) {
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
if (errno != EPIPE && errno != ECONNRESET) {
@@
-475,15
+466,6
@@
ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
memcpy(fds, CMSG_DATA(cmsg), sizeof_fds);
memcpy(fds, CMSG_DATA(cmsg), sizeof_fds);
- /* Set FD_CLOEXEC */
- for (i = 0; i < nb_fd; i++) {
- ret = fcntl(fds[i], F_SETFD, FD_CLOEXEC);
- if (ret < 0) {
- PERROR("fcntl failed to set FD_CLOEXEC on fd %d",
- fds[i]);
- }
- }
-
ret = nb_fd;
end:
return ret;
ret = nb_fd;
end:
return ret;
This page took
0.027614 seconds
and
4
git commands to generate.