[Lldb-commits] [PATCH] Apply SOCK_CLOEXEC flag to socket API functions in order to avoid handle leakage to a forked child process.

Oleksiy Vyalov ovyalov at google.com
Mon Nov 10 16:10:59 PST 2014


>>! In D6204#4, @zturner wrote:
> Some google searching suggests that SOCK_CLOEXEC and FD_CLOEXEC are linux specific flags.  If this is correct, can we put them behind #ifdef _LINUX instead of #ifdef SOCK_CLOEXEC?  It makes it more clear to the reader when the >alternate codepath will actually execute.  

I see 2 reasons to use #ifdef SOCK_CLOEXEC here:
1. SOCK_CLOEXEC is used not only by Linux - FreeBSD and OSX have this flag.
2. Old Linux kernels may lack support of this flag.

> That said, I'm not sure that it's useful to have this be the default behavior.  Dont' most people on posix platforms *expect* handles to be inherited by forked processes?

Yes, it's expected behavior for forked processes but my understanding that in LLDB there is no need to share handles between processes (lldb and debugserver/lldb-gdbserver; debugserver/lldb-gdbserver and inferior) - such sharing may lead useless resource handles in child process and potential security issues when inferior has access to tracer's resources.

http://reviews.llvm.org/D6204






More information about the lldb-commits mailing list