[Bug 1254033] New: Chapter 9.2 advice on using /proc/self/fd to close file descriptors before execve is dangerously wrong
bugzilla at redhat.com
bugzilla at redhat.com
Mon Aug 17 00:35:21 UTC 2015
https://bugzilla.redhat.com/show_bug.cgi?id=1254033
Bug ID: 1254033
Summary: Chapter 9.2 advice on using /proc/self/fd to close
file descriptors before execve is dangerously wrong
Product: Fedora Documentation
Version: devel
Component: defensive-coding-guide
Assignee: fweimer at redhat.com
Reporter: sstewartgallus00 at mylangara.bc.ca
QA Contact: docs-qa at lists.fedoraproject.org
CC: fweimer at redhat.com
Description of problem:
The documentation advises to open /proc/self/fd after forking and close the
file descriptor entries found in there before calling execve. However, in a
multi-threaded environment many memory allocators may deadlock after fork
(opendir, and readdir may allocate memory.) As well, most commonly programmers
implement this by looping over /proc/self/fd while closing file descriptors
which is unsafe because it is like looping over a list while removing entries
from it at the same time. Instead, one should set the close on execute bit on
these file descriptors when looping over the directory entries (probably using
the FIONCLEX ioctl for speed.)
--
You are receiving this mail because:
You are the QA Contact for the bug.
More information about the docs-qa
mailing list