On 8/14/23 08:40, Daniel Borkmann wrote:
On 8/10/23 11:43 PM, Martin Kelly wrote:
From: Marco Vedovati <marco.vedovati@xxxxxxxxxxxxxxx>
Enable the close-on-exec flag when using gzopen
This is especially important for multithreaded programs making use of
libbpf, where a fork + exec could race with libbpf library calls,
potentially resulting in a file descriptor leaked to the new process.
Signed-off-by: Marco Vedovati <marco.vedovati@xxxxxxxxxxxxxxx>
Looks good, thanks for the fix, applied! Do we also need to convert the
fmemopen in bpf_object__read_kconfig_mem - if yes, could you also send a
patch?
Thanks,
Daniel
Good thinking, but it looks like (from libc sources and a quick test)
the underlying fmemopen doesn't accept the "e" mode for close-on-exec.
On glibc 2.35 at least, it's calling into _IO_fopencookie, which then
executes this switch and rejects the flag.