Fun with file descriptors
Posted Jun 7, 2007 5:48 UTC (Thu) by
daney (subscriber, #24551)
Parent article:
Fun with file descriptors
The O_CLOEXEC for open(2) is a good start, but it is not sufficient.
We need coverage for accept(2) also. I am not sure if there are other
ways of creating file descriptors, but unless you plug them all, you
have to assume that the race condition will occur and take
precautions. If you have to take these precautions, then fixing only
a portion of the causes (fixing open(2)) is not all that useful.
Another nasty race condition that I have considered is:
Thread 1 Thread 2 Thread 3
---------------------------------------------------------------
load fd from memory load fd from memory
close fd
obtain same fd from open
use fd on wrong file
If Thread 3 did not reuse the fd there would not be a problem.
I am glad that people are starting to address these issues.
(
Log in to post comments)