During the 2.6.27 merge window a number of my patches were merge and now we are at the point where we can securely create file descriptors without the danger of possibly leaking information. Before I go into the details let's get some background information.
A file descriptor in the Unix/POSIX world has lots of state associated with it. One bit
(
Read more... )
Comments 2
Reply
I thought I explained it sufficiently. Apparently not. There are two scenarios, both of which can and do happen widely. Most obviously is the multi-thread code:
Thread 1Thread 2 New process
fd = open(...)
fork()
fcntl(fd, F_SETFD, FD_CLOEXEC)
execve(...)
The new process inherits all the open file descriptors without close-o-exec set. Just look at, for example, your web browser. This scenario probably happens dozens of times a day in there.
But one doesn't need threads. It can happen in a single-threaded application as well.
Normal CodeIn Signal handler New Process
fd = socket(...)
fork()
fcntl(fd, F_SETFD, FD_CLOEXEC)execve(...)
fork() is a signal-safe function and can be called from a signal handler. Therefore the above can at any point in time happen. And just because your program doesn't use it doesn't mean it cannot happen: a ( ... )
Reply
Leave a comment