Bug 169800 - [libc] [patch] change a number of system library functions to set the O_CLOEXEC flag
Summary: [libc] [patch] change a number of system library functions to set the O_CLOEX...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.1-BETA1
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-12 10:50 UTC by jau
Modified: 2018-05-29 14:37 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (5.00 KB, patch)
2012-07-12 10:50 UTC, jau
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jau 2012-07-12 10:50:01 UTC
The attached patch changes a number of system library functions to set
the O_CLOEXEC flag immediately while the file is being opened.
This will assure that there will be no time window between opening the file
and setting the close-on-exec flag.
Esp. in a threaded program even the small time window could cause the file
descriptors being leaked to a child program, if another independent library
module decides to call exec() inside another thread while the new file has
been opened but the close-on-exec flag has not been set yet.

NOTICE!
This patch requires as a precondition the second enhanced version of
the patch to

http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/169320

Fix: Find the patch attached.

Patch attached with submission follows:
How-To-Repeat: See full description above.
Comment 1 Dag-Erling Smørgrav freebsd_committer 2018-05-29 14:37:47 UTC
The libfetch portion of the patch was committed in r289420 in late 2015.  I can't speak for the rest.