Bug 85663 - closefrom emulation is racy and can miss file descriptors
Summary: closefrom emulation is racy and can miss file descriptors
Status: RESOLVED FIXED
Alias: None
Product: libbsd
Classification: Unclassified
Component: libbsd (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Guillem Jover
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-30 21:14 UTC by Steven Stewart-Gallus
Modified: 2015-12-01 02:09 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Stewart-Gallus 2014-10-30 21:14:17 UTC
The closefrom emulation is racy and can miss file descriptors as it
closes file descriptors while it iterates over the list of open file
descriptors. You have to extract a complete list of file descriptors
and then close them. This problem has probably been hidden because
readdir buffers directory results and reads a bunch of them at once.

Also, personally I'd rather have closefrom abort on errors then fall
back to a bad implementation (although I know you'll probably
disagree) and I'd check every function call for errors (you missed
readdir and closedir). For normal usage checking readdir and closedir
for errors probably doesn't apply but when people do strange things
like use Seccomp or miswrite a signal handler weird things can happen
and so not checking for errors just makes it harder to track down
bugs.
Comment 1 Guillem Jover 2015-09-23 22:39:30 UTC
Hi!

This is fixed now in git master, and will be included in the upcoming release which should happen within the coming couple of weeks at most.
Comment 2 Guillem Jover 2015-12-01 02:09:45 UTC
This has now been released as part of libbsd 0.8.0.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.