gold patch committed: Set close-on-exec flag

Ian Lance Taylor iant@google.com
Tue Mar 17 17:12:00 GMT 2009


A gold plugin may exec another program.  In fact, this happens when LTO.
In that case we do not want gold's file descriptors to leak to the other
program.  It's not a security hole, but since gold is file descriptor
hungry it can mean that the other program can't open very many
descriptors of its own.  I committed this patch to set the close-on-exec
flag for every file descriptor opened by gold.  The patch uses O_CLOEXEC
if available.  If it is not available, then we only set FD_CLOEXEC if we
have any plugins, as without any plugins there is no point to making the
extra system call.

Ian


2009-03-17  Ian Lance Taylor  <iant@google.com>

	* descriptors.cc: Include "options.h".
	(FD_CLOEXEC, O_CLOEXEC): Define if not defined.
	(Descriptors::open): Always use O_CLOEXEC when opening a new
	descriptor.  If we have a plugin, and O_CLOEXEC was not defined,
	then set FD_CLOEXEC.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 2721 bytes
Desc: Set close-on-exec flag
URL: <https://sourceware.org/pipermail/binutils/attachments/20090317/3665d405/attachment.bin>


More information about the Binutils mailing list