public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: David King <amigadave@amigadave.com>
To: git-commits@fedoraproject.org
Subject: [rpms/glib2] cve-2026-58016-f44: Add upstream revert of fd mishandling
Date: Tue, 11 Aug 2026 10:37:50 GMT	[thread overview]
Message-ID: <178644467016.1.3658031598418590030.rpms-glib2-a9177ca9af19@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/glib2
            Branch : cve-2026-58016-f44
            Commit : a9177ca9af194d61788e4b72838da1d350d69af7
            Author : David King <amigadave@amigadave.com>
            Date   : 2022-11-02T15:00:22+00:00
            Stats  : +153/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/glib2/c/a9177ca9af194d61788e4b72838da1d350d69af7?branch=cve-2026-58016-f44

            Log:
            Add upstream revert of fd mishandling

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3039

---
diff --git a/glib-2.74.1-revert-fd-handling.patch b/glib-2.74.1-revert-fd-handling.patch
new file mode 100644
index 0000000..2e99623
--- /dev/null
+++ b/glib-2.74.1-revert-fd-handling.patch
@@ -0,0 +1,150 @@
+From 2a36bb4b7e46f9ac043561c61f9a790786a5440c Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode@redhat.com>
+Date: Fri, 28 Oct 2022 11:21:04 -0400
+Subject: [PATCH 1/2] Revert "Handling collision between standard i/o file
+ descriptors and newly created ones"
+
+g_unix_open_pipe tries to avoid the standard io fd range
+when getting pipe fds. This turns out to be a bad idea because
+certain buggy programs rely on it using that range.
+
+This reverts commit d9ba6150909818beb05573f54f26232063492c5b
+
+Closes: #2795
+Reopens: #16
+---
+ glib/glib-unix.c | 24 ------------------------
+ 1 file changed, 24 deletions(-)
+
+diff --git a/glib/glib-unix.c b/glib/glib-unix.c
+index 4710c51168..bc152d7663 100644
+--- a/glib/glib-unix.c
++++ b/glib/glib-unix.c
+@@ -108,17 +108,6 @@ g_unix_open_pipe (int     *fds,
+     ecode = pipe2 (fds, pipe2_flags);
+     if (ecode == -1 && errno != ENOSYS)
+       return g_unix_set_error_from_errno (error, errno);
+-    /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
+-    else if (fds[0] < 3 || fds[1] < 3)
+-      {
+-        int old_fds[2] = { fds[0], fds[1] };
+-        gboolean result = g_unix_open_pipe (fds, flags, error);
+-        close (old_fds[0]);
+-        close (old_fds[1]);
+-
+-        if (!result)
+-          g_unix_set_error_from_errno (error, errno);
+-      }
+     else if (ecode == 0)
+       return TRUE;
+     /* Fall through on -ENOSYS, we must be running on an old kernel */
+@@ -127,19 +116,6 @@ g_unix_open_pipe (int     *fds,
+   ecode = pipe (fds);
+   if (ecode == -1)
+     return g_unix_set_error_from_errno (error, errno);
+-  /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
+-  else if (fds[0] < 3 || fds[1] < 3)
+-    {
+-      int old_fds[2] = { fds[0], fds[1] };
+-      gboolean result = g_unix_open_pipe (fds, flags, error);
+-      close (old_fds[0]);
+-      close (old_fds[1]);
+-
+-      if (!result)
+-        g_unix_set_error_from_errno (error, errno);
+-
+-      return result;
+-    }
+ 
+   if (flags == 0)
+     return TRUE;
+-- 
+GitLab
+
+
+From 1c1c452ff2030135e4abc2816e81b7078a845580 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode@redhat.com>
+Date: Mon, 31 Oct 2022 09:17:55 -0400
+Subject: [PATCH 2/2] glib-unix: Add test to make sure g_unix_open_pipe will
+ intrude standard range
+
+Now that we know it's a bad idea to avoid the standard io fd range
+when getting pipe fds for g_unix_open_pipe, we should test to make sure
+we don't inadvertently try to do it again.
+
+This commit adds that test.
+---
+ glib/tests/unix.c | 41 +++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 41 insertions(+)
+
+diff --git a/glib/tests/unix.c b/glib/tests/unix.c
+index 2112cab6bf..6c4a59dee7 100644
+--- a/glib/tests/unix.c
++++ b/glib/tests/unix.c
+@@ -24,8 +24,11 @@
+ #include "config.h"
+ 
+ #include "glib-unix.h"
++#include "gstdio.h"
++
+ #include <string.h>
+ #include <pwd.h>
++#include <unistd.h>
+ 
+ static void
+ test_pipe (void)
+@@ -52,6 +55,43 @@ test_pipe (void)
+   g_assert (g_str_has_prefix (buf, "hello"));
+ }
+ 
++static void
++test_pipe_stdio_overwrite (void)
++{
++  GError *error = NULL;
++  int pipefd[2], ret;
++  gboolean res;
++  int stdin_fd;
++
++
++  g_test_summary ("Test that g_unix_open_pipe() will use the first available FD, even if it’s stdin/stdout/stderr");
++  g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2795");
++
++  stdin_fd = dup (STDIN_FILENO);
++  g_assert_cmpint (stdin_fd, >, 0);
++
++  g_close (STDIN_FILENO, &error);
++  g_assert_no_error (error);
++
++  res = g_unix_open_pipe (pipefd, FD_CLOEXEC, &error);
++  g_assert_no_error (error);
++  g_assert_true (res);
++
++  g_assert_cmpint (pipefd[0], ==, STDIN_FILENO);
++
++  g_close (pipefd[0], &error);
++  g_assert_no_error (error);
++
++  g_close (pipefd[1], &error);
++  g_assert_no_error (error);
++
++  ret = dup2 (stdin_fd, STDIN_FILENO);
++  g_assert_cmpint (ret, >=, 0);
++
++  g_close (stdin_fd, &error);
++  g_assert_no_error (error);
++}
++
+ static void
+ test_error (void)
+ {
+@@ -337,6 +377,7 @@ main (int   argc,
+   g_test_init (&argc, &argv, NULL);
+ 
+   g_test_add_func ("/glib-unix/pipe", test_pipe);
++  g_test_add_func ("/glib-unix/pipe-stdio-overwrite", test_pipe_stdio_overwrite);
+   g_test_add_func ("/glib-unix/error", test_error);
+   g_test_add_func ("/glib-unix/nonblocking", test_nonblocking);
+   g_test_add_func ("/glib-unix/sighup", test_sighup);
+-- 
+GitLab
+

diff --git a/glib2.spec b/glib2.spec
index bde0188..32eb00a 100644
--- a/glib2.spec
+++ b/glib2.spec
@@ -12,6 +12,9 @@ Source0: https://download.gnome.org/sources/glib/2.72/glib-%{version}.tar.xz
 # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/903
 Patch0: gnutls-hmac.patch
 
+# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3039
+Patch1: glib-2.74.1-revert-fd-handling.patch
+
 BuildRequires: gcc
 BuildRequires: gcc-c++
 BuildRequires: gettext

                 reply	other threads:[~2026-08-11 10:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178644467016.1.3658031598418590030.rpms-glib2-a9177ca9af19@fedoraproject.org \
    --to=amigadave@amigadave.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox