mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2025-02-17 02:38:02 +00:00
Prevent leaking of machport/proc/signal fds across execve()
This commit is contained in:
parent
22005641d9
commit
f411d4553d
@ -87,6 +87,8 @@ evfilt_machport_knote_create(struct filter *filt, struct knote *kn)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
fcntl(kn->kdata.kn_dupfd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
if (epoll_ctl(kn->kn_epollfd, EPOLL_CTL_ADD, kn->kdata.kn_dupfd, &ev) < 0) {
|
||||
dbg_printf("epoll_ctl(2): %s", strerror(errno));
|
||||
return (-1);
|
||||
|
@ -131,6 +131,8 @@ evfilt_proc_knote_create(struct filter *filt, struct knote *kn)
|
||||
kn->kdata.kn_dupfd = lkm_call(NR_evproc_create, &args);
|
||||
if (kn->kdata.kn_dupfd == -1)
|
||||
dbg_printf("evproc_create() failed: %s\n", strerror(errno));
|
||||
|
||||
fcntl(kn->kdata.kn_dupfd, F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
|
||||
kn->kev.fflags &= ~NOTE_PASSINGFD;
|
||||
|
@ -100,6 +100,7 @@ signalfd_create(int epfd, void *ptr, int signum)
|
||||
dbg_perror("signalfd(2)");
|
||||
goto errout;
|
||||
}
|
||||
fcntl(sigfd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
/* Block the signal handler from being invoked */
|
||||
if (sigprocmask(SIG_BLOCK, &sigmask, NULL) < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user