From ba7b23759d65e4d5b41b41f311e8e2f3cbe302a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 14 Jan 2019 17:13:20 +0100 Subject: [PATCH] Do not close an IPC pipe that already has a desired descriptor --- ...pe-in-pipe-open-as-inherit-on-exec-2.patch | 35 +++++++++++++++ ...pipe-in-pipe-open-as-inherit-on-exec.patch | 43 +++++++++++++++++++ perl.spec | 9 ++++ 3 files changed, 87 insertions(+) create mode 100644 perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec-2.patch create mode 100644 perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec.patch diff --git a/perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec-2.patch b/perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec-2.patch new file mode 100644 index 0000000..e0d6989 --- /dev/null +++ b/perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec-2.patch @@ -0,0 +1,35 @@ +From 30c869b87739b56280daca3cd44b0588144747b7 Mon Sep 17 00:00:00 2001 +From: Leon Timmermans +Date: Sun, 16 Dec 2018 01:05:06 +0100 +Subject: [PATCH] Always mark pipe in list pipe-open as inherit-on-exec +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is the my_popen_list counterpart of +c6fe5b981b942ddabb23ed4b7602067e906e6d88 + +Signed-off-by: Petr Písař +--- + util.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/util.c b/util.c +index 99bf4ae2b0..8c9909e10c 100644 +--- a/util.c ++++ b/util.c +@@ -2330,8 +2330,10 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args) + if (p[THAT] != (*mode == 'r')) /* if dup2() didn't close it */ + PerlLIO_close(p[THAT]); /* close parent's end of _the_ pipe */ + } +- else ++ else { ++ setfd_cloexec_or_inhexec_by_sysfdness(p[THIS]); + PerlLIO_close(p[THAT]); /* close parent's end of _the_ pipe */ ++ } + #if !defined(HAS_FCNTL) || !defined(F_SETFD) + /* No automatic close - do it by hand */ + # ifndef NOFILE +-- +2.17.2 + diff --git a/perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec.patch b/perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec.patch new file mode 100644 index 0000000..2f9593f --- /dev/null +++ b/perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec.patch @@ -0,0 +1,43 @@ +From c6fe5b981b942ddabb23ed4b7602067e906e6d88 Mon Sep 17 00:00:00 2001 +From: Leon Timmermans +Date: Sat, 15 Dec 2018 19:08:41 +0100 +Subject: [PATCH] Always mark pipe in pipe-open as inherit-on-exec +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since 2cdf406a a lot of file descriptors are opened close-on-exec, +including the pipe that is passed to the child process in a pipe-open. +This is usually fine because a dup2 follows to rename that handle to +stdin/stdout that will set the inherit-on-exec. However, if the pipe +descriptor already has the right value, for example because stdin was +closed, then no dup2 happens and hence it's still marked as +close-on-exec right when we want to perform an exec. + +This patch explicitly marks such a handle as inherit-on-exec, to ensure +it will be open for the child process. + +Signed-off-by: Petr Písař +--- + util.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/util.c b/util.c +index a9bf9b8609..99bf4ae2b0 100644 +--- a/util.c ++++ b/util.c +@@ -2469,8 +2469,10 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode) + if (p[THAT] != (*mode == 'r')) /* if dup2() didn't close it */ + PerlLIO_close(p[THAT]); + } +- else ++ else { ++ setfd_cloexec_or_inhexec_by_sysfdness(p[THIS]); + PerlLIO_close(p[THAT]); ++ } + #ifndef OS2 + if (doexec) { + #if !defined(HAS_FCNTL) || !defined(F_SETFD) +-- +2.17.2 + diff --git a/perl.spec b/perl.spec index 0485e73..711a6ac 100644 --- a/perl.spec +++ b/perl.spec @@ -219,6 +219,11 @@ Patch39: perl-5.28.1-ext-GDBM_File-t-fatal.t-handle-non-fatality.patch Patch40: perl-5.29.5-Correct-spelling-error-in-skip-message.patch Patch41: perl-5.29.5-Avoid-Use-of-uninitialized-value-res-in-numeric-eq-w.patch +# Do not close an IPC pipe that already has a desired descriptor, RT#133726, +# in upstream after 5.29.5 +Patch42: perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec.patch +Patch43: perl-5.29.5-Always-mark-pipe-in-pipe-open-as-inherit-on-exec-2.patch + # Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048 Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch @@ -2814,6 +2819,8 @@ Perl extension for Version Objects %patch39 -p1 %patch40 -p1 %patch41 -p1 +%patch42 -p1 +%patch43 -p1 %patch200 -p1 %patch201 -p1 @@ -2851,6 +2858,7 @@ perl -x patchlevel.h \ 'Fedora Patch35: Fix in-place edit to replace files on a successful perl exit status (bug #1650041)' \ 'Fedora Patch38: Fix compiling regular expressions that contain both compile- and run-time compiled code blocks (RT#133687)' \ 'Fedora Patch39: Adjust tests to gdbm-1.15 (RT#133295)' \ + 'Fedora Patch42: Do not close an IPC pipe that already has a desired descriptor (RT#133726)' \ 'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \ 'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \ %{nil} @@ -5141,6 +5149,7 @@ popd %changelog * Mon Jan 14 2019 Petr Pisar - 4:5.28.1-430 - Adjust tests to gdbm-1.15 using an upstream fix (RT#133295) +- Do not close an IPC pipe that already has a desired descriptor (RT#133726) * Mon Jan 14 2019 Björn Esser - 4:5.28.1-429 - Rebuilt for libcrypt.so.2 (#1666033)