Blame SOURCES/make-4.3-cloexec.patch

b1d5fb
From d79fe162c009788888faaf0317253b6f0cac7092 Mon Sep 17 00:00:00 2001
b1d5fb
From: Kevin Buettner <kevinb@redhat.com>
b1d5fb
Date: Thu, 23 Apr 2020 17:05:34 -0400
b1d5fb
Subject: [SV 58232] Disable inheritance of jobserver FDs for recursive make
b1d5fb
b1d5fb
A parent make will invoke a sub-make with close-on-exec disabled for
b1d5fb
the jobserver pipe FDs.  Force close-on-exec to be to be enabled in
b1d5fb
the sub-make so the pipe is not always passed to child jobs.
b1d5fb
b1d5fb
I have a test case which, when invoked with a suitable -j switch,
b1d5fb
will hang if the recipe inherits the jobserver pipe.  This test case
b1d5fb
was inspired by a real world case in which testing GDB on Fedora
b1d5fb
would hang due to some poorly written test GDB cases having been
b1d5fb
passed the jobserver file descriptors.
b1d5fb
b1d5fb
* src/posixos.c (jobserver_parse_auth): Call fd_noinherit() for
b1d5fb
jobserver pipe descriptors.
b1d5fb
b1d5fb
Copyright-paperwork-exempt: yes
b1d5fb
b1d5fb
diff --git a/src/posixos.c b/src/posixos.c
b1d5fb
index 525f292c..eab175a4 100644
b1d5fb
--- a/src/posixos.c
b1d5fb
+++ b/src/posixos.c
b1d5fb
@@ -145,6 +145,11 @@ jobserver_parse_auth (const char *auth)
b1d5fb
   /* When using pselect() we want the read to be non-blocking.  */
b1d5fb
   set_blocking (job_fds[0], 0);
b1d5fb
 
b1d5fb
+  /* By default we don't send the job pipe FDs to our children.
b1d5fb
+     See jobserver_pre_child() and jobserver_post_child().  */
b1d5fb
+  fd_noinherit (job_fds[0]);
b1d5fb
+  fd_noinherit (job_fds[1]);
b1d5fb
+
b1d5fb
   return 1;
b1d5fb
 }
b1d5fb