forked from rpms/glibc
		
	Compare commits
	
		
			6 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6f91983eb9 | |||
| 73b8a454b8 | |||
| ff081255d2 | |||
| aff5be9254 | |||
| bd5e3b9f42 | |||
| 07f31ed813 | 
							
								
								
									
										236
									
								
								SOURCES/glibc-RHEL-105326.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										236
									
								
								SOURCES/glibc-RHEL-105326.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,236 @@
 | 
				
			|||||||
 | 
					commit 7ea06e994093fa0bcca0d0ee2c1db271d8d7885d
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Mon Jul 21 21:43:49 2025 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    posix: Fix double-free after allocation failure in regcomp (bug 33185)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    If a memory allocation failure occurs during bracket expression
 | 
				
			||||||
 | 
					    parsing in regcomp, a double-free error may result.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Reported-by: Anastasia Belova <abelova@astralinux.ru>
 | 
				
			||||||
 | 
					    Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
 | 
				
			||||||
 | 
					    Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						posix/Makefile
 | 
				
			||||||
 | 
						  (tests list not reformatted/sorted downstream)
 | 
				
			||||||
 | 
						posix/tst-regcomp-bracket-free.c
 | 
				
			||||||
 | 
						  (missing strerrorname_np downstream)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/posix/Makefile b/posix/Makefile
 | 
				
			||||||
 | 
					index 83162123f9c927a0..42a0290370b40fd9 100644
 | 
				
			||||||
 | 
					--- a/posix/Makefile
 | 
				
			||||||
 | 
					+++ b/posix/Makefile
 | 
				
			||||||
 | 
					@@ -96,7 +96,7 @@ tests		:= test-errno tstgetopt testfnm runtests runptests \
 | 
				
			||||||
 | 
					 		   tst-posix_fadvise tst-posix_fadvise64 \
 | 
				
			||||||
 | 
					 		   tst-sysconf-empty-chroot tst-glob_symlinks tst-fexecve \
 | 
				
			||||||
 | 
					 		   tst-glob-tilde test-ssize-max tst-spawn4 bug-regex37 \
 | 
				
			||||||
 | 
					-		   bug-regex38 tst-regcomp-truncated
 | 
				
			||||||
 | 
					+		   bug-regex38 tst-regcomp-truncated tst-regcomp-bracket-free
 | 
				
			||||||
 | 
					 tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 | 
				
			||||||
 | 
					 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \
 | 
				
			||||||
 | 
					 		   tst-glob_lstat_compat tst-spawn4-compat
 | 
				
			||||||
 | 
					diff --git a/posix/regcomp.c b/posix/regcomp.c
 | 
				
			||||||
 | 
					index 545d188468c376e7..b737b22da8703d6c 100644
 | 
				
			||||||
 | 
					--- a/posix/regcomp.c
 | 
				
			||||||
 | 
					+++ b/posix/regcomp.c
 | 
				
			||||||
 | 
					@@ -3375,6 +3375,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					 #ifdef RE_ENABLE_I18N
 | 
				
			||||||
 | 
					       free_charset (mbcset);
 | 
				
			||||||
 | 
					+      mbcset = NULL;
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					       /* Build a tree for simple bracket.  */
 | 
				
			||||||
 | 
					       br_token.type = SIMPLE_BRACKET;
 | 
				
			||||||
 | 
					@@ -3390,7 +3391,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
 | 
				
			||||||
 | 
					  parse_bracket_exp_free_return:
 | 
				
			||||||
 | 
					   re_free (sbcset);
 | 
				
			||||||
 | 
					 #ifdef RE_ENABLE_I18N
 | 
				
			||||||
 | 
					-  free_charset (mbcset);
 | 
				
			||||||
 | 
					+  if (__glibc_likely (mbcset != NULL))
 | 
				
			||||||
 | 
					+    free_charset (mbcset);
 | 
				
			||||||
 | 
					 #endif /* RE_ENABLE_I18N */
 | 
				
			||||||
 | 
					   return NULL;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					diff --git a/posix/tst-regcomp-bracket-free.c b/posix/tst-regcomp-bracket-free.c
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 0000000000000000..e6041ddaeba3045c
 | 
				
			||||||
 | 
					--- /dev/null
 | 
				
			||||||
 | 
					+++ b/posix/tst-regcomp-bracket-free.c
 | 
				
			||||||
 | 
					@@ -0,0 +1,176 @@
 | 
				
			||||||
 | 
					+/* Test regcomp bracket parsing with injected allocation failures (bug 33185).
 | 
				
			||||||
 | 
					+   Copyright (C) 2025 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* This test invokes regcomp multiple times, failing one memory
 | 
				
			||||||
 | 
					+   allocation in each call.  The function call should fail with
 | 
				
			||||||
 | 
					+   REG_ESPACE (or succeed if it can recover from the allocation
 | 
				
			||||||
 | 
					+   failure).  Previously, there was double-free bug.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <errno.h>
 | 
				
			||||||
 | 
					+#include <regex.h>
 | 
				
			||||||
 | 
					+#include <stdio.h>
 | 
				
			||||||
 | 
					+#include <string.h>
 | 
				
			||||||
 | 
					+#include <support/check.h>
 | 
				
			||||||
 | 
					+#include <support/namespace.h>
 | 
				
			||||||
 | 
					+#include <support/support.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Data structure allocated via MAP_SHARED, so that writes from the
 | 
				
			||||||
 | 
					+   subprocess are visible.  */
 | 
				
			||||||
 | 
					+struct shared_data
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  /* Number of tracked allocations performed so far.  */
 | 
				
			||||||
 | 
					+  volatile unsigned int allocation_count;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* If this number is reached, one allocation fails.  */
 | 
				
			||||||
 | 
					+  volatile unsigned int failing_allocation;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* The subprocess stores the expected name here.  */
 | 
				
			||||||
 | 
					+  char name[100];
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Allocation count in shared mapping.  */
 | 
				
			||||||
 | 
					+static struct shared_data *shared;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Returns true if a failure should be injected for this allocation.  */
 | 
				
			||||||
 | 
					+static bool
 | 
				
			||||||
 | 
					+fail_this_allocation (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (shared != NULL)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      unsigned int count = shared->allocation_count;
 | 
				
			||||||
 | 
					+      shared->allocation_count = count + 1;
 | 
				
			||||||
 | 
					+      return count == shared->failing_allocation;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+  else
 | 
				
			||||||
 | 
					+    return false;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Failure-injecting wrappers for allocation functions used by glibc.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void *
 | 
				
			||||||
 | 
					+malloc (size_t size)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (fail_this_allocation ())
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      errno = ENOMEM;
 | 
				
			||||||
 | 
					+      return NULL;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+  extern __typeof (malloc) __libc_malloc;
 | 
				
			||||||
 | 
					+  return __libc_malloc (size);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void *
 | 
				
			||||||
 | 
					+calloc (size_t a, size_t b)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (fail_this_allocation ())
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      errno = ENOMEM;
 | 
				
			||||||
 | 
					+      return NULL;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+  extern __typeof (calloc) __libc_calloc;
 | 
				
			||||||
 | 
					+  return __libc_calloc (a, b);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void *
 | 
				
			||||||
 | 
					+realloc (void *ptr, size_t size)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (fail_this_allocation ())
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      errno = ENOMEM;
 | 
				
			||||||
 | 
					+      return NULL;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+  extern __typeof (realloc) __libc_realloc;
 | 
				
			||||||
 | 
					+  return __libc_realloc (ptr, size);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* No-op subprocess to verify that support_isolate_in_subprocess does
 | 
				
			||||||
 | 
					+   not perform any heap allocations.  */
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+no_op (void *ignored)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Perform a regcomp call in a subprocess.  Used to count its
 | 
				
			||||||
 | 
					+   allocations.  */
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+initialize (void *regexp1)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  const char *regexp = regexp1;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  shared->allocation_count = 0;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  regex_t reg;
 | 
				
			||||||
 | 
					+  TEST_COMPARE (regcomp (®, regexp, 0), 0);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Perform regcomp in a subprocess with fault injection.  */
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+test_in_subprocess (void *regexp1)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  const char *regexp = regexp1;
 | 
				
			||||||
 | 
					+  unsigned int inject_at = shared->failing_allocation;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  regex_t reg;
 | 
				
			||||||
 | 
					+  int ret = regcomp (®, regexp, 0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  if (ret != 0)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      TEST_COMPARE (ret, REG_ESPACE);
 | 
				
			||||||
 | 
					+      printf ("info: allocation %u failure results in return value %d,"
 | 
				
			||||||
 | 
					+              " error %s (%d)\n",
 | 
				
			||||||
 | 
					+              inject_at, ret, strerror (errno), errno);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+do_test (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  char regexp[] = "[:alpha:]";
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  shared = support_shared_allocate (sizeof (*shared));
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Disable fault injection.  */
 | 
				
			||||||
 | 
					+  shared->failing_allocation = ~0U;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  support_isolate_in_subprocess (no_op, NULL);
 | 
				
			||||||
 | 
					+  TEST_COMPARE (shared->allocation_count, 0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  support_isolate_in_subprocess (initialize, regexp);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* The number of allocations in the successful case, plus some
 | 
				
			||||||
 | 
					+     slack.  Once the number of expected allocations is exceeded,
 | 
				
			||||||
 | 
					+     injecting further failures does not make a difference.  */
 | 
				
			||||||
 | 
					+  unsigned int maximum_allocation_count = shared->allocation_count;
 | 
				
			||||||
 | 
					+  printf ("info: successful call performs %u allocations\n",
 | 
				
			||||||
 | 
					+          maximum_allocation_count);
 | 
				
			||||||
 | 
					+  maximum_allocation_count += 10;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  for (unsigned int inject_at = 0; inject_at <= maximum_allocation_count;
 | 
				
			||||||
 | 
					+       ++inject_at)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      shared->allocation_count = 0;
 | 
				
			||||||
 | 
					+      shared->failing_allocation = inject_at;
 | 
				
			||||||
 | 
					+      support_isolate_in_subprocess (test_in_subprocess, regexp);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  support_shared_free (shared);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
							
								
								
									
										59
									
								
								SOURCES/glibc-RHEL-18039-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								SOURCES/glibc-RHEL-18039-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					commit 868ab8923a2ec977faafec97ecafac0c3159c1b2
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Thu Jun 13 18:56:30 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    resolv: Track single-request fallback via _res._flags (bug 31476)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This avoids changing _res.options, which inteferes with change
 | 
				
			||||||
 | 
					    detection as part of automatic reloading of /etc/resolv.conf.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Reviewed-by: DJ Delorie <dj@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/res_send.c b/resolv/res_send.c
 | 
				
			||||||
 | 
					--- a/resolv/res_send.c	2025-02-19 21:54:08.104421209 -0500
 | 
				
			||||||
 | 
					+++ b/resolv/res_send.c	2025-02-19 21:54:51.202625194 -0500
 | 
				
			||||||
 | 
					@@ -1065,9 +1065,11 @@ send_dg(res_state statp,
 | 
				
			||||||
 | 
					 		seconds /= statp->nscount;
 | 
				
			||||||
 | 
					 	if (seconds <= 0)
 | 
				
			||||||
 | 
					 		seconds = 1;
 | 
				
			||||||
 | 
					-	bool single_request_reopen = (statp->options & RES_SNGLKUPREOP) != 0;
 | 
				
			||||||
 | 
					-	bool single_request = (((statp->options & RES_SNGLKUP) != 0)
 | 
				
			||||||
 | 
					-			       | single_request_reopen);
 | 
				
			||||||
 | 
					+	bool single_request_reopen = ((statp->options & RES_SNGLKUPREOP)
 | 
				
			||||||
 | 
					+				      || (statp->_flags & RES_F_SNGLKUPREOP));
 | 
				
			||||||
 | 
					+	bool single_request = ((statp->options & RES_SNGLKUP)
 | 
				
			||||||
 | 
					+			       || (statp->_flags & RES_F_SNGLKUP)
 | 
				
			||||||
 | 
					+			       || single_request_reopen);
 | 
				
			||||||
 | 
					 	int save_gotsomewhere = *gotsomewhere;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	int retval;
 | 
				
			||||||
 | 
					@@ -1124,14 +1126,14 @@ send_dg(res_state statp,
 | 
				
			||||||
 | 
					 		       have received the first answer.  */
 | 
				
			||||||
 | 
					 		    if (!single_request)
 | 
				
			||||||
 | 
					 		      {
 | 
				
			||||||
 | 
					-			statp->options |= RES_SNGLKUP;
 | 
				
			||||||
 | 
					+			statp->_flags |= RES_F_SNGLKUP;
 | 
				
			||||||
 | 
					 			single_request = true;
 | 
				
			||||||
 | 
					 			*gotsomewhere = save_gotsomewhere;
 | 
				
			||||||
 | 
					 			goto retry;
 | 
				
			||||||
 | 
					 		      }
 | 
				
			||||||
 | 
					 		    else if (!single_request_reopen)
 | 
				
			||||||
 | 
					 		      {
 | 
				
			||||||
 | 
					-			statp->options |= RES_SNGLKUPREOP;
 | 
				
			||||||
 | 
					+			statp->_flags |= RES_F_SNGLKUPREOP;
 | 
				
			||||||
 | 
					 			single_request_reopen = true;
 | 
				
			||||||
 | 
					 			*gotsomewhere = save_gotsomewhere;
 | 
				
			||||||
 | 
					 			__res_iclose (statp, false);
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/resolv-internal.h b/resolv/resolv-internal.h
 | 
				
			||||||
 | 
					--- a/resolv/resolv-internal.h	2025-02-19 21:54:08.104421209 -0500
 | 
				
			||||||
 | 
					+++ b/resolv/resolv-internal.h	2025-02-19 21:56:25.771072777 -0500
 | 
				
			||||||
 | 
					@@ -26,7 +26,8 @@
 | 
				
			||||||
 | 
					 #define RES_F_VC        0x00000001 /* Socket is TCP.  */
 | 
				
			||||||
 | 
					 #define RES_F_CONN      0x00000002 /* Socket is connected.  */
 | 
				
			||||||
 | 
					 #define RES_F_EDNS0ERR  0x00000004 /* EDNS0 caused errors.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					+#define RES_F_SNGLKUP	0x00200000 /* Private version of RES_SNGLKUP.  */
 | 
				
			||||||
 | 
					+#define RES_F_SNGLKUPREOP 0x00400000 /* Private version of RES_SNGLKUPREOP.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Internal version of RES_USE_INET6 which does not trigger a
 | 
				
			||||||
 | 
					    deprecation warning.  */
 | 
				
			||||||
							
								
								
									
										197
									
								
								SOURCES/glibc-RHEL-18039-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										197
									
								
								SOURCES/glibc-RHEL-18039-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,197 @@
 | 
				
			|||||||
 | 
					commit 691a3b2e9bfaba842e46a5ccb7f5e6ea144c3ade
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Wed Jul 24 12:06:47 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    resolv: Allow short error responses to match any query (bug 31890)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Reviewed-by: DJ Delorie <dj@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						resolv/res_send.c: res_queriesmatch/__libc_res_queriesmatch 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/Makefile b/resolv/Makefile
 | 
				
			||||||
 | 
					--- a/resolv/Makefile	2025-06-06 08:53:20.890276516 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/Makefile	2025-06-06 08:57:09.981844872 -0400
 | 
				
			||||||
 | 
					@@ -62,6 +62,7 @@ tests += \
 | 
				
			||||||
 | 
					   tst-resolv-nondecimal \
 | 
				
			||||||
 | 
					   tst-resolv-res_init-multi \
 | 
				
			||||||
 | 
					   tst-resolv-search \
 | 
				
			||||||
 | 
					+  tst-resolv-short-response \
 | 
				
			||||||
 | 
					   tst-resolv-trailing \
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 # This test calls __res_context_send directly, which is not exported
 | 
				
			||||||
 | 
					@@ -208,6 +209,8 @@ $(objpfx)tst-resolv-nondecimal: $(objpfx
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-qtypes: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-rotate: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-search: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					+$(objpfx)tst-resolv-short-response: $(objpfx)libresolv.so \
 | 
				
			||||||
 | 
					+  $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-trailing: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-threads: \
 | 
				
			||||||
 | 
					   $(libdl) $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/res_send.c b/resolv/res_send.c
 | 
				
			||||||
 | 
					--- a/resolv/res_send.c	2025-06-06 08:53:30.892216323 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/res_send.c	2025-06-06 08:59:35.588914830 -0400
 | 
				
			||||||
 | 
					@@ -1322,17 +1322,30 @@ send_dg(res_state statp,
 | 
				
			||||||
 | 
					 		  goto wait;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 		/* Check for the correct header layout and a matching
 | 
				
			||||||
 | 
					-		   question.  */
 | 
				
			||||||
 | 
					+		   question.  Some recursive resolvers send REFUSED
 | 
				
			||||||
 | 
					+		   without copying back the question section
 | 
				
			||||||
 | 
					+		   (producing a response that is only HFIXEDSZ bytes
 | 
				
			||||||
 | 
					+		   long).  Skip query matching in this case.  */
 | 
				
			||||||
 | 
					+		bool thisansp_error = (anhp->rcode == SERVFAIL ||
 | 
				
			||||||
 | 
					+				       anhp->rcode == NOTIMP ||
 | 
				
			||||||
 | 
					+				       anhp->rcode == REFUSED);
 | 
				
			||||||
 | 
					+		bool skip_query_match = (*thisresplenp == HFIXEDSZ
 | 
				
			||||||
 | 
					+					 && ntohs (anhp->qdcount) == 0
 | 
				
			||||||
 | 
					+					 && thisansp_error);
 | 
				
			||||||
 | 
					 		int matching_query = 0; /* Default to no matching query.  */
 | 
				
			||||||
 | 
					 		if (!recvresp1
 | 
				
			||||||
 | 
					 		    && anhp->id == hp->id
 | 
				
			||||||
 | 
					-		    && res_queriesmatch (buf, buf + buflen,
 | 
				
			||||||
 | 
					-					 *thisansp, *thisansp + *thisanssizp))
 | 
				
			||||||
 | 
					+		    && (skip_query_match
 | 
				
			||||||
 | 
					+			|| res_queriesmatch (buf, buf + buflen,
 | 
				
			||||||
 | 
					+						    *thisansp,
 | 
				
			||||||
 | 
					+						    *thisansp + *thisanssizp)))
 | 
				
			||||||
 | 
					 		  matching_query = 1;
 | 
				
			||||||
 | 
					 		if (!recvresp2
 | 
				
			||||||
 | 
					 		    && anhp->id == hp2->id
 | 
				
			||||||
 | 
					-		    && res_queriesmatch (buf2, buf2 + buflen2,
 | 
				
			||||||
 | 
					-					 *thisansp, *thisansp + *thisanssizp))
 | 
				
			||||||
 | 
					+		    && (skip_query_match
 | 
				
			||||||
 | 
					+			|| res_queriesmatch (buf2, buf2 + buflen2,
 | 
				
			||||||
 | 
					+						    *thisansp,
 | 
				
			||||||
 | 
					+						    *thisansp + *thisanssizp)))
 | 
				
			||||||
 | 
					 		  matching_query = 2;
 | 
				
			||||||
 | 
					 		if (matching_query == 0)
 | 
				
			||||||
 | 
					 		  /* Spurious UDP packet.  Drop it and continue
 | 
				
			||||||
 | 
					@@ -1342,9 +1355,7 @@ send_dg(res_state statp,
 | 
				
			||||||
 | 
					 		    goto wait;
 | 
				
			||||||
 | 
					 		  }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-		if (anhp->rcode == SERVFAIL ||
 | 
				
			||||||
 | 
					-		    anhp->rcode == NOTIMP ||
 | 
				
			||||||
 | 
					-		    anhp->rcode == REFUSED) {
 | 
				
			||||||
 | 
					+		if (thisansp_error) {
 | 
				
			||||||
 | 
					 		next_ns:
 | 
				
			||||||
 | 
					 			if (recvresp1 || (buf2 != NULL && recvresp2)) {
 | 
				
			||||||
 | 
					 			  *resplen2 = 0;
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/tst-resolv-short-response.c b/resolv/tst-resolv-short-response.c
 | 
				
			||||||
 | 
					--- a/resolv/tst-resolv-short-response.c	1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/resolv/tst-resolv-short-response.c	2025-06-06 08:57:09.987844834 -0400
 | 
				
			||||||
 | 
					@@ -0,0 +1,112 @@
 | 
				
			||||||
 | 
					+/* Test for spurious timeouts with short 12-byte responses (bug 31890).
 | 
				
			||||||
 | 
					+   Copyright (C) 2024 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <resolv.h>
 | 
				
			||||||
 | 
					+#include <support/check.h>
 | 
				
			||||||
 | 
					+#include <support/resolv_test.h>
 | 
				
			||||||
 | 
					+#include <support/check_nss.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* The rcode in the initial response.  */
 | 
				
			||||||
 | 
					+static volatile int rcode;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+response (const struct resolv_response_context *ctx,
 | 
				
			||||||
 | 
					+          struct resolv_response_builder *b,
 | 
				
			||||||
 | 
					+          const char *qname, uint16_t qclass, uint16_t qtype)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  switch (ctx->server_index)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+    case 0:
 | 
				
			||||||
 | 
					+      /* First server times out.  */
 | 
				
			||||||
 | 
					+      struct resolv_response_flags flags = {.rcode = rcode};
 | 
				
			||||||
 | 
					+      resolv_response_init (b, flags);
 | 
				
			||||||
 | 
					+      break;
 | 
				
			||||||
 | 
					+    case 1:
 | 
				
			||||||
 | 
					+      /* Second server sends reply.  */
 | 
				
			||||||
 | 
					+      resolv_response_init (b, (struct resolv_response_flags) {});
 | 
				
			||||||
 | 
					+      resolv_response_add_question (b, qname, qclass, qtype);
 | 
				
			||||||
 | 
					+      resolv_response_section (b, ns_s_an);
 | 
				
			||||||
 | 
					+      resolv_response_open_record (b, qname, qclass, qtype, 0);
 | 
				
			||||||
 | 
					+      switch (qtype)
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+        case T_A:
 | 
				
			||||||
 | 
					+          {
 | 
				
			||||||
 | 
					+            char ipv4[4] = {192, 0, 2, 17};
 | 
				
			||||||
 | 
					+            resolv_response_add_data (b, &ipv4, sizeof (ipv4));
 | 
				
			||||||
 | 
					+          }
 | 
				
			||||||
 | 
					+          break;
 | 
				
			||||||
 | 
					+        case T_AAAA:
 | 
				
			||||||
 | 
					+          {
 | 
				
			||||||
 | 
					+            char ipv6[16]
 | 
				
			||||||
 | 
					+              = {0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
 | 
				
			||||||
 | 
					+            resolv_response_add_data (b, &ipv6, sizeof (ipv6));
 | 
				
			||||||
 | 
					+          }
 | 
				
			||||||
 | 
					+          break;
 | 
				
			||||||
 | 
					+        default:
 | 
				
			||||||
 | 
					+          FAIL_EXIT1 ("unexpected TYPE%d query", qtype);
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+      resolv_response_close_record (b);
 | 
				
			||||||
 | 
					+      break;
 | 
				
			||||||
 | 
					+    default:
 | 
				
			||||||
 | 
					+      FAIL_EXIT1 ("unexpected query to server %d", ctx->server_index);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+check_one (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* The buggy 1-second query timeout results in 30 seconds of delay,
 | 
				
			||||||
 | 
					+     which triggers a test timeout failure.  */
 | 
				
			||||||
 | 
					+  for (int i = 0;  i < 10; ++i)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      check_hostent ("www.example", gethostbyname ("www.example"),
 | 
				
			||||||
 | 
					+                     "name: www.example\n"
 | 
				
			||||||
 | 
					+                     "address: 192.0.2.17\n");
 | 
				
			||||||
 | 
					+      check_hostent ("www.example", gethostbyname2 ("www.example", AF_INET6),
 | 
				
			||||||
 | 
					+                     "name: www.example\n"
 | 
				
			||||||
 | 
					+                     "address: 2001:db8::1\n");
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+do_test (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  struct resolv_test *aux = resolv_test_start
 | 
				
			||||||
 | 
					+    ((struct resolv_redirect_config)
 | 
				
			||||||
 | 
					+     {
 | 
				
			||||||
 | 
					+       .response_callback = response,
 | 
				
			||||||
 | 
					+     });
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  _res.options |= RES_SNGLKUP;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  rcode = 2; /* SERVFAIL.  */
 | 
				
			||||||
 | 
					+  check_one ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  rcode = 4; /* NOTIMP.  */
 | 
				
			||||||
 | 
					+  check_one ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  rcode = 5; /* REFUSED.  */
 | 
				
			||||||
 | 
					+  check_one ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  resolv_test_end (aux);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
							
								
								
									
										203
									
								
								SOURCES/glibc-RHEL-18039-3.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										203
									
								
								SOURCES/glibc-RHEL-18039-3.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,203 @@
 | 
				
			|||||||
 | 
					commit af625987d619388a100b153520d3ee308bda9889
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Wed Jul 24 12:06:47 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    resolv: Do not wait for non-existing second DNS response after error (bug 30081)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    In single-request mode, there is no second response after an error
 | 
				
			||||||
 | 
					    because the second query has not been sent yet.  Waiting for it
 | 
				
			||||||
 | 
					    introduces an unnecessary timeout.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: DJ Delorie <dj@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/Makefile b/resolv/Makefile
 | 
				
			||||||
 | 
					--- a/resolv/Makefile	2025-02-19 22:32:03.567568899 -0500
 | 
				
			||||||
 | 
					+++ b/resolv/Makefile	2025-02-19 22:36:58.647149025 -0500
 | 
				
			||||||
 | 
					@@ -62,6 +62,7 @@ tests += \
 | 
				
			||||||
 | 
					   tst-resolv-nondecimal \
 | 
				
			||||||
 | 
					   tst-resolv-res_init-multi \
 | 
				
			||||||
 | 
					   tst-resolv-search \
 | 
				
			||||||
 | 
					+  tst-resolv-semi-failure \
 | 
				
			||||||
 | 
					   tst-resolv-short-response \
 | 
				
			||||||
 | 
					   tst-resolv-trailing \
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -209,6 +210,8 @@ $(objpfx)tst-resolv-nondecimal: $(objpfx
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-qtypes: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-rotate: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-search: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					+$(objpfx)tst-resolv-semi-failure: $(objpfx)libresolv.so \
 | 
				
			||||||
 | 
					+  $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-short-response: $(objpfx)libresolv.so \
 | 
				
			||||||
 | 
					   $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-resolv-trailing: $(objpfx)libresolv.so $(shared-thread-library)
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/res_send.c b/resolv/res_send.c
 | 
				
			||||||
 | 
					--- a/resolv/res_send.c	2025-02-19 22:32:03.567568899 -0500
 | 
				
			||||||
 | 
					+++ b/resolv/res_send.c	2025-02-19 22:34:59.213509475 -0500
 | 
				
			||||||
 | 
					@@ -1361,7 +1361,7 @@ send_dg(res_state statp,
 | 
				
			||||||
 | 
					 			  *resplen2 = 0;
 | 
				
			||||||
 | 
					 			  return resplen;
 | 
				
			||||||
 | 
					 			}
 | 
				
			||||||
 | 
					-			if (buf2 != NULL)
 | 
				
			||||||
 | 
					+			if (buf2 != NULL && !single_request)
 | 
				
			||||||
 | 
					 			  {
 | 
				
			||||||
 | 
					 			    /* No data from the first reply.  */
 | 
				
			||||||
 | 
					 			    resplen = 0;
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/tst-resolv-semi-failure.c b/resolv/tst-resolv-semi-failure.c
 | 
				
			||||||
 | 
					--- a/resolv/tst-resolv-semi-failure.c	1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/resolv/tst-resolv-semi-failure.c	2025-02-19 22:34:59.213509475 -0500
 | 
				
			||||||
 | 
					@@ -0,0 +1,133 @@
 | 
				
			||||||
 | 
					+/* Test parallel failure/success responses (bug 30081).
 | 
				
			||||||
 | 
					+   Copyright (C) 2024 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <resolv.h>
 | 
				
			||||||
 | 
					+#include <support/check.h>
 | 
				
			||||||
 | 
					+#include <support/resolv_test.h>
 | 
				
			||||||
 | 
					+#include <support/check_nss.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* The rcode in the initial response.  */
 | 
				
			||||||
 | 
					+static volatile int rcode;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Whether to fail the initial A query (!fail_aaaa) or the initial
 | 
				
			||||||
 | 
					+   AAAA query (fail_aaaa).  */
 | 
				
			||||||
 | 
					+static volatile bool fail_aaaa;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+response (const struct resolv_response_context *ctx,
 | 
				
			||||||
 | 
					+          struct resolv_response_builder *b,
 | 
				
			||||||
 | 
					+          const char *qname, uint16_t qclass, uint16_t qtype)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  /* Handle the failing query.  */
 | 
				
			||||||
 | 
					+  if ((fail_aaaa && qtype == T_AAAA) && ctx->server_index == 0)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      struct resolv_response_flags flags = {.rcode = rcode};
 | 
				
			||||||
 | 
					+      resolv_response_init (b, flags);
 | 
				
			||||||
 | 
					+      return;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Otherwise produce a response.  */
 | 
				
			||||||
 | 
					+  resolv_response_init (b, (struct resolv_response_flags) {});
 | 
				
			||||||
 | 
					+  resolv_response_add_question (b, qname, qclass, qtype);
 | 
				
			||||||
 | 
					+  resolv_response_section (b, ns_s_an);
 | 
				
			||||||
 | 
					+  resolv_response_open_record (b, qname, qclass, qtype, 0);
 | 
				
			||||||
 | 
					+  switch (qtype)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+    case T_A:
 | 
				
			||||||
 | 
					+      {
 | 
				
			||||||
 | 
					+        char ipv4[4] = {192, 0, 2, 17};
 | 
				
			||||||
 | 
					+        resolv_response_add_data (b, &ipv4, sizeof (ipv4));
 | 
				
			||||||
 | 
					+      }
 | 
				
			||||||
 | 
					+      break;
 | 
				
			||||||
 | 
					+    case T_AAAA:
 | 
				
			||||||
 | 
					+      {
 | 
				
			||||||
 | 
					+        char ipv6[16]
 | 
				
			||||||
 | 
					+          = {0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
 | 
				
			||||||
 | 
					+        resolv_response_add_data (b, &ipv6, sizeof (ipv6));
 | 
				
			||||||
 | 
					+      }
 | 
				
			||||||
 | 
					+      break;
 | 
				
			||||||
 | 
					+    default:
 | 
				
			||||||
 | 
					+      FAIL_EXIT1 ("unexpected TYPE%d query", qtype);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+  resolv_response_close_record (b);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+check_one (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* The buggy 1-second query timeout results in 30 seconds of delay,
 | 
				
			||||||
 | 
					+     which triggers are test timeout failure.  */
 | 
				
			||||||
 | 
					+  for (int i = 0;  i < 30; ++i)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      static const struct addrinfo hints =
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          .ai_family = AF_UNSPEC,
 | 
				
			||||||
 | 
					+          .ai_socktype = SOCK_STREAM,
 | 
				
			||||||
 | 
					+        };
 | 
				
			||||||
 | 
					+      struct addrinfo *ai;
 | 
				
			||||||
 | 
					+      int ret = getaddrinfo ("www.example", "80", &hints, &ai);
 | 
				
			||||||
 | 
					+      const char *expected;
 | 
				
			||||||
 | 
					+      if (ret == 0 && ai->ai_next != NULL)
 | 
				
			||||||
 | 
					+        expected = ("address: STREAM/TCP 192.0.2.17 80\n"
 | 
				
			||||||
 | 
					+                    "address: STREAM/TCP 2001:db8::1 80\n");
 | 
				
			||||||
 | 
					+      else
 | 
				
			||||||
 | 
					+        /* Only one response because the AAAA lookup failure is
 | 
				
			||||||
 | 
					+           treated as an ignoreable error.  */
 | 
				
			||||||
 | 
					+        expected = "address: STREAM/TCP 192.0.2.17 80\n";
 | 
				
			||||||
 | 
					+      check_addrinfo ("www.example", ai, ret, expected);
 | 
				
			||||||
 | 
					+      if (ret == 0)
 | 
				
			||||||
 | 
					+        freeaddrinfo (ai);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+do_test (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  for (int do_single_lookup = 0; do_single_lookup < 2; ++do_single_lookup)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      struct resolv_test *aux = resolv_test_start
 | 
				
			||||||
 | 
					+        ((struct resolv_redirect_config)
 | 
				
			||||||
 | 
					+         {
 | 
				
			||||||
 | 
					+           .response_callback = response,
 | 
				
			||||||
 | 
					+         });
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      if (do_single_lookup)
 | 
				
			||||||
 | 
					+        _res.options |= RES_SNGLKUP;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      for (int do_fail_aaaa = 0; do_fail_aaaa < 2; ++do_fail_aaaa)
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          fail_aaaa = do_fail_aaaa;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+          rcode = 2; /* SERVFAIL.  */
 | 
				
			||||||
 | 
					+          check_one ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+          rcode = 4; /* NOTIMP.  */
 | 
				
			||||||
 | 
					+          check_one ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+          rcode = 5; /* REFUSED.  */
 | 
				
			||||||
 | 
					+          check_one ();
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      resolv_test_end (aux);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/tst-resolv-short-response.c b/resolv/tst-resolv-short-response.c
 | 
				
			||||||
 | 
					--- a/resolv/tst-resolv-short-response.c	2025-02-19 22:32:03.567568899 -0500
 | 
				
			||||||
 | 
					+++ b/resolv/tst-resolv-short-response.c	2025-02-19 22:34:59.213509475 -0500
 | 
				
			||||||
 | 
					@@ -81,6 +81,18 @@ check_one (void)
 | 
				
			||||||
 | 
					       check_hostent ("www.example", gethostbyname2 ("www.example", AF_INET6),
 | 
				
			||||||
 | 
					                      "name: www.example\n"
 | 
				
			||||||
 | 
					                      "address: 2001:db8::1\n");
 | 
				
			||||||
 | 
					+      static const struct addrinfo hints =
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          .ai_family = AF_UNSPEC,
 | 
				
			||||||
 | 
					+          .ai_socktype = SOCK_STREAM,
 | 
				
			||||||
 | 
					+        };
 | 
				
			||||||
 | 
					+      struct addrinfo *ai;
 | 
				
			||||||
 | 
					+      int ret = getaddrinfo ("www.example", "80", &hints, &ai);
 | 
				
			||||||
 | 
					+      check_addrinfo ("www.example", ai, ret,
 | 
				
			||||||
 | 
					+                      "address: STREAM/TCP 192.0.2.17 80\n"
 | 
				
			||||||
 | 
					+                      "address: STREAM/TCP 2001:db8::1 80\n");
 | 
				
			||||||
 | 
					+      if (ret == 0)
 | 
				
			||||||
 | 
					+        freeaddrinfo (ai);
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
							
								
								
									
										81
									
								
								SOURCES/glibc-RHEL-18039-4.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								SOURCES/glibc-RHEL-18039-4.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,81 @@
 | 
				
			|||||||
 | 
					commit 95f61610f3e481d191b6184432342236fd59186d
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Wed Jul 24 12:06:47 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    resolv: Support clearing option flags with a “-” prefix (bug 14799)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    I think using a “-” prefix is less confusing than introducing
 | 
				
			||||||
 | 
					    double-negation construct (“no-no-tld-query”).
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: DJ Delorie <dj@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						NEWS: Dropped
 | 
				
			||||||
 | 
						resolv/res_init.c: DEPRECATED_RES_USE_INET6 and RES_TRUSTAD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/res_init.c b/resolv/res_init.c
 | 
				
			||||||
 | 
					--- a/resolv/res_init.c	2025-05-21 08:57:39.108958310 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/res_init.c	2025-05-21 08:59:11.528419481 -0400
 | 
				
			||||||
 | 
					@@ -682,27 +682,29 @@ res_setoptions (struct resolv_conf_parse
 | 
				
			||||||
 | 
					           {
 | 
				
			||||||
 | 
					             char str[22];
 | 
				
			||||||
 | 
					             uint8_t len;
 | 
				
			||||||
 | 
					-            uint8_t clear;
 | 
				
			||||||
 | 
					             unsigned long int flag;
 | 
				
			||||||
 | 
					           } options[] = {
 | 
				
			||||||
 | 
					 #define STRnLEN(str) str, sizeof (str) - 1
 | 
				
			||||||
 | 
					-            { STRnLEN ("inet6"), 0, DEPRECATED_RES_USE_INET6 },
 | 
				
			||||||
 | 
					-            { STRnLEN ("rotate"), 0, RES_ROTATE },
 | 
				
			||||||
 | 
					-            { STRnLEN ("edns0"), 0, RES_USE_EDNS0 },
 | 
				
			||||||
 | 
					-            { STRnLEN ("single-request-reopen"), 0, RES_SNGLKUPREOP },
 | 
				
			||||||
 | 
					-            { STRnLEN ("single-request"), 0, RES_SNGLKUP },
 | 
				
			||||||
 | 
					-            { STRnLEN ("no_tld_query"), 0, RES_NOTLDQUERY },
 | 
				
			||||||
 | 
					-            { STRnLEN ("no-tld-query"), 0, RES_NOTLDQUERY },
 | 
				
			||||||
 | 
					-            { STRnLEN ("no-reload"), 0, RES_NORELOAD },
 | 
				
			||||||
 | 
					-            { STRnLEN ("use-vc"), 0, RES_USEVC },
 | 
				
			||||||
 | 
					-            { STRnLEN ("no-aaaa"), 0, RES_NOAAAA },
 | 
				
			||||||
 | 
					+            { STRnLEN ("inet6"), DEPRECATED_RES_USE_INET6 },
 | 
				
			||||||
 | 
					+            { STRnLEN ("rotate"), RES_ROTATE },
 | 
				
			||||||
 | 
					+            { STRnLEN ("edns0"),  RES_USE_EDNS0 },
 | 
				
			||||||
 | 
					+            { STRnLEN ("single-request-reopen"), RES_SNGLKUPREOP },
 | 
				
			||||||
 | 
					+            { STRnLEN ("single-request"), RES_SNGLKUP },
 | 
				
			||||||
 | 
					+            { STRnLEN ("no_tld_query"), RES_NOTLDQUERY },
 | 
				
			||||||
 | 
					+            { STRnLEN ("no-tld-query"), RES_NOTLDQUERY },
 | 
				
			||||||
 | 
					+            { STRnLEN ("no-reload"), RES_NORELOAD },
 | 
				
			||||||
 | 
					+            { STRnLEN ("use-vc"),  RES_USEVC },
 | 
				
			||||||
 | 
					+            { STRnLEN ("no-aaaa"), RES_NOAAAA },
 | 
				
			||||||
 | 
					           };
 | 
				
			||||||
 | 
					 #define noptions (sizeof (options) / sizeof (options[0]))
 | 
				
			||||||
 | 
					+          bool negate_option = *cp == '-';
 | 
				
			||||||
 | 
					+          if (negate_option)
 | 
				
			||||||
 | 
					+            ++cp;
 | 
				
			||||||
 | 
					           for (int i = 0; i < noptions; ++i)
 | 
				
			||||||
 | 
					             if (strncmp (cp, options[i].str, options[i].len) == 0)
 | 
				
			||||||
 | 
					               {
 | 
				
			||||||
 | 
					-                if (options[i].clear)
 | 
				
			||||||
 | 
					-                  parser->template.options &= options[i].flag;
 | 
				
			||||||
 | 
					+                if (negate_option)
 | 
				
			||||||
 | 
					+                  parser->template.options &= ~options[i].flag;
 | 
				
			||||||
 | 
					                 else
 | 
				
			||||||
 | 
					                   parser->template.options |= options[i].flag;
 | 
				
			||||||
 | 
					                 break;
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/tst-resolv-res_init-skeleton.c b/resolv/tst-resolv-res_init-skeleton.c
 | 
				
			||||||
 | 
					--- a/resolv/tst-resolv-res_init-skeleton.c	2025-05-21 08:57:39.109958315 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/tst-resolv-res_init-skeleton.c	2025-05-21 08:58:09.541110166 -0400
 | 
				
			||||||
 | 
					@@ -680,6 +680,16 @@ struct test_case test_cases[] =
 | 
				
			||||||
 | 
					      "; nameserver[0]: [192.0.2.1]:53\n",
 | 
				
			||||||
 | 
					      .res_options = "attempts:5 ndots:3 edns0 ",
 | 
				
			||||||
 | 
					     },
 | 
				
			||||||
 | 
					+    {.name = "RES_OPTIONS can clear flags",
 | 
				
			||||||
 | 
					+     .conf = "options ndots:2 use-vc no-aaaa edns0\n"
 | 
				
			||||||
 | 
					+     "nameserver 192.0.2.1\n",
 | 
				
			||||||
 | 
					+     .expected = "options ndots:3 use-vc\n"
 | 
				
			||||||
 | 
					+     "search example.com\n"
 | 
				
			||||||
 | 
					+     "; search[0]: example.com\n"
 | 
				
			||||||
 | 
					+     "nameserver 192.0.2.1\n"
 | 
				
			||||||
 | 
					+     "; nameserver[0]: [192.0.2.1]:53\n",
 | 
				
			||||||
 | 
					+     .res_options = "ndots:3 -edns0 -no-aaaa",
 | 
				
			||||||
 | 
					+    },
 | 
				
			||||||
 | 
					     {.name = "many search list entries (bug 19569)",
 | 
				
			||||||
 | 
					      .conf = "nameserver 192.0.2.1\n"
 | 
				
			||||||
 | 
					      "search corp.example.com support.example.com"
 | 
				
			||||||
							
								
								
									
										207
									
								
								SOURCES/glibc-RHEL-18039-5.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										207
									
								
								SOURCES/glibc-RHEL-18039-5.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,207 @@
 | 
				
			|||||||
 | 
					commit 765325951ac5c7d072278c9424930b29657e9758
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Wed Jul 24 12:06:47 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    resolv: Implement strict-error stub resolver option (bug 27929)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    For now, do not enable this mode by default due to the potential
 | 
				
			||||||
 | 
					    impact on compatibility with existing deployments.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Reviewed-by: DJ Delorie <dj@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
					        NEWS
 | 
				
			||||||
 | 
					         (Dropped)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/res_init.c b/resolv/res_init.c
 | 
				
			||||||
 | 
					--- a/resolv/res_init.c	2025-06-06 07:00:12.496548260 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/res_init.c	2025-06-06 07:02:49.092632696 -0400
 | 
				
			||||||
 | 
					@@ -695,6 +695,7 @@ res_setoptions (struct resolv_conf_parse
 | 
				
			||||||
 | 
					             { STRnLEN ("no-reload"), RES_NORELOAD },
 | 
				
			||||||
 | 
					             { STRnLEN ("use-vc"),  RES_USEVC },
 | 
				
			||||||
 | 
					             { STRnLEN ("no-aaaa"), RES_NOAAAA },
 | 
				
			||||||
 | 
					+            { STRnLEN ("strict-error"), RES_STRICTERR },
 | 
				
			||||||
 | 
					           };
 | 
				
			||||||
 | 
					 #define noptions (sizeof (options) / sizeof (options[0]))
 | 
				
			||||||
 | 
					           bool negate_option = *cp == '-';
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/res_send.c b/resolv/res_send.c
 | 
				
			||||||
 | 
					--- a/resolv/res_send.c	2025-06-06 07:00:12.434548622 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/res_send.c	2025-06-06 07:02:49.095632678 -0400
 | 
				
			||||||
 | 
					@@ -1357,21 +1357,38 @@ send_dg(res_state statp,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 		if (thisansp_error) {
 | 
				
			||||||
 | 
					 		next_ns:
 | 
				
			||||||
 | 
					-			if (recvresp1 || (buf2 != NULL && recvresp2)) {
 | 
				
			||||||
 | 
					-			  *resplen2 = 0;
 | 
				
			||||||
 | 
					-			  return resplen;
 | 
				
			||||||
 | 
					-			}
 | 
				
			||||||
 | 
					-			if (buf2 != NULL && !single_request)
 | 
				
			||||||
 | 
					+		        /* Outside of strict-error mode, use the first
 | 
				
			||||||
 | 
					+			   response even if the second response is an
 | 
				
			||||||
 | 
					+			   error.  This allows parallel resolution to
 | 
				
			||||||
 | 
					+			   succeed even if the recursive resolver
 | 
				
			||||||
 | 
					+			   always answers with SERVFAIL for AAAA
 | 
				
			||||||
 | 
					+			   queries (which still happens in practice
 | 
				
			||||||
 | 
					+			   unfortunately).
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+			   In strict-error mode, always switch to the
 | 
				
			||||||
 | 
					+			   next server and try to get a response from
 | 
				
			||||||
 | 
					+			   there.  */
 | 
				
			||||||
 | 
					+			if ((statp->options & RES_STRICTERR) == 0)
 | 
				
			||||||
 | 
					 			  {
 | 
				
			||||||
 | 
					-			    /* No data from the first reply.  */
 | 
				
			||||||
 | 
					-			    resplen = 0;
 | 
				
			||||||
 | 
					-			    /* We are waiting for a possible second reply.  */
 | 
				
			||||||
 | 
					-			    if (matching_query == 1)
 | 
				
			||||||
 | 
					-			      recvresp1 = 1;
 | 
				
			||||||
 | 
					-			    else
 | 
				
			||||||
 | 
					-			      recvresp2 = 1;
 | 
				
			||||||
 | 
					+			    if (recvresp1 || (buf2 != NULL && recvresp2))
 | 
				
			||||||
 | 
					+			      {
 | 
				
			||||||
 | 
					+				*resplen2 = 0;
 | 
				
			||||||
 | 
					+				return resplen;
 | 
				
			||||||
 | 
					+			      }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+			    if (buf2 != NULL && !single_request)
 | 
				
			||||||
 | 
					+			      {
 | 
				
			||||||
 | 
					+				/* No data from the first reply.  */
 | 
				
			||||||
 | 
					+				resplen = 0;
 | 
				
			||||||
 | 
					+				/* We are waiting for a possible
 | 
				
			||||||
 | 
					+				   second reply.  */
 | 
				
			||||||
 | 
					+				if (matching_query == 1)
 | 
				
			||||||
 | 
					+				  recvresp1 = 1;
 | 
				
			||||||
 | 
					+				else
 | 
				
			||||||
 | 
					+				  recvresp2 = 1;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-			    goto wait;
 | 
				
			||||||
 | 
					+				goto wait;
 | 
				
			||||||
 | 
					+			      }
 | 
				
			||||||
 | 
					 			  }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 			/* don't retry if called from dig */
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/resolv.h b/resolv/resolv.h
 | 
				
			||||||
 | 
					--- a/resolv/resolv.h	2025-06-06 06:59:53.530659146 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/resolv.h	2025-06-06 07:09:57.754126400 -0400
 | 
				
			||||||
 | 
					@@ -136,6 +136,7 @@ struct res_sym {
 | 
				
			||||||
 | 
					 					   as a TLD.  */
 | 
				
			||||||
 | 
					 #define RES_NORELOAD    0x02000000 /* No automatic configuration reload.  */
 | 
				
			||||||
 | 
					 #define RES_NOAAAA      0x08000000 /* Suppress AAAA queries.  */
 | 
				
			||||||
 | 
					+#define RES_STRICTERR   0x10000000 /* Report more DNS errors as errors.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #define RES_DEFAULT	(RES_RECURSE|RES_DEFNAMES|RES_DNSRCH)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/tst-resolv-res_init-skeleton.c b/resolv/tst-resolv-res_init-skeleton.c
 | 
				
			||||||
 | 
					--- a/resolv/tst-resolv-res_init-skeleton.c	2025-06-06 07:00:12.499548242 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/tst-resolv-res_init-skeleton.c	2025-06-06 07:11:46.131274310 -0400
 | 
				
			||||||
 | 
					@@ -130,6 +130,7 @@ print_resp (FILE *fp, res_state resp)
 | 
				
			||||||
 | 
					         print_option_flag (fp, &options, RES_NOTLDQUERY, "no-tld-query");
 | 
				
			||||||
 | 
					         print_option_flag (fp, &options, RES_NORELOAD, "no-reload");
 | 
				
			||||||
 | 
					         print_option_flag (fp, &options, RES_NOAAAA, "no-aaaa");
 | 
				
			||||||
 | 
					+        print_option_flag (fp, &options, RES_STRICTERR, "strict-error");
 | 
				
			||||||
 | 
					         fputc ('\n', fp);
 | 
				
			||||||
 | 
					         if (options != 0)
 | 
				
			||||||
 | 
					           fprintf (fp, "; error: unresolved option bits: 0x%x\n", options);
 | 
				
			||||||
 | 
					@@ -731,6 +732,15 @@ struct test_case test_cases[] =
 | 
				
			||||||
 | 
					      "search example.com\n"
 | 
				
			||||||
 | 
					      "; search[0]: example.com\n"
 | 
				
			||||||
 | 
					      "nameserver 192.0.2.1\n"
 | 
				
			||||||
 | 
					+     "; nameserver[0]: [192.0.2.1]:53\n"
 | 
				
			||||||
 | 
					+    },
 | 
				
			||||||
 | 
					+    {.name = "strict-error flag",
 | 
				
			||||||
 | 
					+     .conf = "options strict-error\n"
 | 
				
			||||||
 | 
					+     "nameserver 192.0.2.1\n",
 | 
				
			||||||
 | 
					+     .expected = "options strict-error\n"
 | 
				
			||||||
 | 
					+     "search example.com\n"
 | 
				
			||||||
 | 
					+     "; search[0]: example.com\n"
 | 
				
			||||||
 | 
					+     "nameserver 192.0.2.1\n"
 | 
				
			||||||
 | 
					      "; nameserver[0]: [192.0.2.1]:53\n"
 | 
				
			||||||
 | 
					     },
 | 
				
			||||||
 | 
					     { NULL }
 | 
				
			||||||
 | 
					diff -Nrup a/resolv/tst-resolv-semi-failure.c b/resolv/tst-resolv-semi-failure.c
 | 
				
			||||||
 | 
					--- a/resolv/tst-resolv-semi-failure.c	2025-06-06 07:00:12.438548599 -0400
 | 
				
			||||||
 | 
					+++ b/resolv/tst-resolv-semi-failure.c	2025-06-06 07:02:49.099632654 -0400
 | 
				
			||||||
 | 
					@@ -67,6 +67,9 @@ response (const struct resolv_response_c
 | 
				
			||||||
 | 
					   resolv_response_close_record (b);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+/* Set to 1 if strict error checking is enabled.  */
 | 
				
			||||||
 | 
					+static int do_strict_error;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 static void
 | 
				
			||||||
 | 
					 check_one (void)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					@@ -83,7 +86,10 @@ check_one (void)
 | 
				
			||||||
 | 
					       struct addrinfo *ai;
 | 
				
			||||||
 | 
					       int ret = getaddrinfo ("www.example", "80", &hints, &ai);
 | 
				
			||||||
 | 
					       const char *expected;
 | 
				
			||||||
 | 
					-      if (ret == 0 && ai->ai_next != NULL)
 | 
				
			||||||
 | 
					+      /* In strict-error mode, a switch to the second name server
 | 
				
			||||||
 | 
					+         happens, and both responses are received, so a single
 | 
				
			||||||
 | 
					+         response is a bug.  */
 | 
				
			||||||
 | 
					+      if (do_strict_error || (ret == 0 && ai->ai_next != NULL))
 | 
				
			||||||
 | 
					         expected = ("address: STREAM/TCP 192.0.2.17 80\n"
 | 
				
			||||||
 | 
					                     "address: STREAM/TCP 2001:db8::1 80\n");
 | 
				
			||||||
 | 
					       else
 | 
				
			||||||
 | 
					@@ -99,33 +105,36 @@ check_one (void)
 | 
				
			||||||
 | 
					 static int
 | 
				
			||||||
 | 
					 do_test (void)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-  for (int do_single_lookup = 0; do_single_lookup < 2; ++do_single_lookup)
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					-      struct resolv_test *aux = resolv_test_start
 | 
				
			||||||
 | 
					-        ((struct resolv_redirect_config)
 | 
				
			||||||
 | 
					-         {
 | 
				
			||||||
 | 
					-           .response_callback = response,
 | 
				
			||||||
 | 
					-         });
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      if (do_single_lookup)
 | 
				
			||||||
 | 
					-        _res.options |= RES_SNGLKUP;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      for (int do_fail_aaaa = 0; do_fail_aaaa < 2; ++do_fail_aaaa)
 | 
				
			||||||
 | 
					-        {
 | 
				
			||||||
 | 
					-          fail_aaaa = do_fail_aaaa;
 | 
				
			||||||
 | 
					+  for (do_strict_error = 0; do_strict_error < 2; ++do_strict_error)
 | 
				
			||||||
 | 
					+    for (int do_single_lookup = 0; do_single_lookup < 2; ++do_single_lookup)
 | 
				
			||||||
 | 
					+      {
 | 
				
			||||||
 | 
					+        struct resolv_test *aux = resolv_test_start
 | 
				
			||||||
 | 
					+          ((struct resolv_redirect_config)
 | 
				
			||||||
 | 
					+           {
 | 
				
			||||||
 | 
					+             .response_callback = response,
 | 
				
			||||||
 | 
					+           });
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+        if (do_strict_error)
 | 
				
			||||||
 | 
					+          _res.options |= RES_STRICTERR;
 | 
				
			||||||
 | 
					+        if (do_single_lookup)
 | 
				
			||||||
 | 
					+          _res.options |= RES_SNGLKUP;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+        for (int do_fail_aaaa = 0; do_fail_aaaa < 2; ++do_fail_aaaa)
 | 
				
			||||||
 | 
					+          {
 | 
				
			||||||
 | 
					+            fail_aaaa = do_fail_aaaa;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+            rcode = 2; /* SERVFAIL.  */
 | 
				
			||||||
 | 
					+            check_one ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+            rcode = 4; /* NOTIMP.  */
 | 
				
			||||||
 | 
					+            check_one ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+            rcode = 5; /* REFUSED.  */
 | 
				
			||||||
 | 
					+            check_one ();
 | 
				
			||||||
 | 
					+          }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-          rcode = 2; /* SERVFAIL.  */
 | 
				
			||||||
 | 
					-          check_one ();
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-          rcode = 4; /* NOTIMP.  */
 | 
				
			||||||
 | 
					-          check_one ();
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-          rcode = 5; /* REFUSED.  */
 | 
				
			||||||
 | 
					-          check_one ();
 | 
				
			||||||
 | 
					-        }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      resolv_test_end (aux);
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					+        resolv_test_end (aux);
 | 
				
			||||||
 | 
					+      }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
							
								
								
									
										28
									
								
								SOURCES/glibc-RHEL-18039-6.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								SOURCES/glibc-RHEL-18039-6.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					commit ec119972cb2598c04ec7d4219e20506006836f64
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Thu Aug 1 10:46:10 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    resolv: Fix tst-resolv-short-response for older GCC (bug 32042)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Previous GCC versions do not support the C23 change that
 | 
				
			||||||
 | 
					    allows labels on declarations.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/resolv/tst-resolv-short-response.c b/resolv/tst-resolv-short-response.c
 | 
				
			||||||
 | 
					index be354ae1c7..9b06b0c176 100644
 | 
				
			||||||
 | 
					--- a/resolv/tst-resolv-short-response.c
 | 
				
			||||||
 | 
					+++ b/resolv/tst-resolv-short-response.c
 | 
				
			||||||
 | 
					@@ -33,8 +33,10 @@ response (const struct resolv_response_context *ctx,
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					     case 0:
 | 
				
			||||||
 | 
					       /* First server times out.  */
 | 
				
			||||||
 | 
					-      struct resolv_response_flags flags = {.rcode = rcode};
 | 
				
			||||||
 | 
					-      resolv_response_init (b, flags);
 | 
				
			||||||
 | 
					+      {
 | 
				
			||||||
 | 
					+        struct resolv_response_flags flags = {.rcode = rcode};
 | 
				
			||||||
 | 
					+        resolv_response_init (b, flags);
 | 
				
			||||||
 | 
					+      }
 | 
				
			||||||
 | 
					       break;
 | 
				
			||||||
 | 
					     case 1:
 | 
				
			||||||
 | 
					       /* Second server sends reply.  */
 | 
				
			||||||
							
								
								
									
										30
									
								
								SOURCES/glibc-RHEL-35280.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								SOURCES/glibc-RHEL-35280.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					commit 4bbca1a44691a6e9adcee5c6798a707b626bc331
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Thu May 2 17:06:19 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nscd: Use time_t for return type of addgetnetgrentX
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Using int may give false results for future dates (timeouts after the
 | 
				
			||||||
 | 
					    year 2028).
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Fixes commit 04a21e050d64a1193a6daab872bca2528bda44b ("CVE-2024-33601,
 | 
				
			||||||
 | 
					    CVE-2024-33602: nscd: netgroup: Use two buffers in addgetnetgrentX
 | 
				
			||||||
 | 
					    (bug 31680)").
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
 | 
				
			||||||
 | 
					index dd180f8083e7c9f9..b118b55af2d7c9a0 100644
 | 
				
			||||||
 | 
					--- a/nscd/netgroupcache.c
 | 
				
			||||||
 | 
					+++ b/nscd/netgroupcache.c
 | 
				
			||||||
 | 
					@@ -681,8 +681,8 @@ readdinnetgr (struct database_dyn *db, struct hashentry *he,
 | 
				
			||||||
 | 
					       .key_len = he->len
 | 
				
			||||||
 | 
					     };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  int timeout = addinnetgrX (db, -1, &req, db->data + he->key, he->owner,
 | 
				
			||||||
 | 
					-			     he, dh);
 | 
				
			||||||
 | 
					+  time_t timeout = addinnetgrX (db, -1, &req, db->data + he->key, he->owner,
 | 
				
			||||||
 | 
					+				he, dh);
 | 
				
			||||||
 | 
					   if (timeout < 0)
 | 
				
			||||||
 | 
					     timeout = 0;
 | 
				
			||||||
 | 
					   return timeout;
 | 
				
			||||||
							
								
								
									
										51
									
								
								SOURCES/glibc-RHEL-49490-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								SOURCES/glibc-RHEL-49490-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					commit 9b7651410375ec8848a1944992d663d514db4ba7
 | 
				
			||||||
 | 
					Author: Stefan Liebler <stli@linux.ibm.com>
 | 
				
			||||||
 | 
					Date:   Thu Jul 11 11:28:53 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    s390x: Fix segfault in wcsncmp [BZ #31934]
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The z13/vector-optimized wcsncmp implementation segfaults if n=1
 | 
				
			||||||
 | 
					    and there is only one character (equal on both strings) before
 | 
				
			||||||
 | 
					    the page end.  Then it loads and compares one character and misses
 | 
				
			||||||
 | 
					    to check n again.  The following load fails.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This patch removes the extra load and compare of the first character
 | 
				
			||||||
 | 
					    and just start with the loop which uses vector-load-to-block-boundary.
 | 
				
			||||||
 | 
					    This code-path also checks n.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    With this patch both tests are passing:
 | 
				
			||||||
 | 
					    - the simplified one mentioned in the bugzilla 31934
 | 
				
			||||||
 | 
					    - the full one in Florian Weimer's patch:
 | 
				
			||||||
 | 
					    "manual: Document a GNU extension for strncmp/wcsncmp"
 | 
				
			||||||
 | 
					    (https://patchwork.sourceware.org/project/glibc/patch/874j9eml6y.fsf@oldenburg.str.redhat.com/):
 | 
				
			||||||
 | 
					    On s390x-linux-gnu (z16), the new wcsncmp test fails due to bug 31934.
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sysdeps/s390/wcsncmp-vx.S b/sysdeps/s390/wcsncmp-vx.S
 | 
				
			||||||
 | 
					index bf6dfa6bc2..8b081567a2 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/s390/wcsncmp-vx.S
 | 
				
			||||||
 | 
					+++ b/sysdeps/s390/wcsncmp-vx.S
 | 
				
			||||||
 | 
					@@ -59,14 +59,7 @@ ENTRY(WCSNCMP_Z13)
 | 
				
			||||||
 | 
					 	sllg	%r4,%r4,2	/* Convert character-count to byte-count.  */
 | 
				
			||||||
 | 
					 	locgrne	%r4,%r1		/* Use max byte-count, if bit 0/1 was one.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Check first character without vector load.  */
 | 
				
			||||||
 | 
					-	lghi	%r5,4		/* current_len = 4 bytes.  */
 | 
				
			||||||
 | 
					-	/* Check s1/2[0].  */
 | 
				
			||||||
 | 
					-	lt	%r0,0(%r2)
 | 
				
			||||||
 | 
					-	l	%r1,0(%r3)
 | 
				
			||||||
 | 
					-	je	.Lend_cmp_one_char
 | 
				
			||||||
 | 
					-	crjne	%r0,%r1,.Lend_cmp_one_char
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					+	lghi	%r5,0		/* current_len = 0 bytes.  */
 | 
				
			||||||
 | 
					 .Lloop:
 | 
				
			||||||
 | 
					 	vlbb	%v17,0(%r5,%r3),6 /* Load s2 to block boundary.  */
 | 
				
			||||||
 | 
					 	vlbb	%v16,0(%r5,%r2),6 /* Load s1 to block boundary.  */
 | 
				
			||||||
 | 
					@@ -167,7 +160,6 @@ ENTRY(WCSNCMP_Z13)
 | 
				
			||||||
 | 
					 	srl	%r4,2		/* And convert it to character-index.  */
 | 
				
			||||||
 | 
					 	vlgvf	%r0,%v16,0(%r4)	/* Load character-values.  */
 | 
				
			||||||
 | 
					 	vlgvf	%r1,%v17,0(%r4)
 | 
				
			||||||
 | 
					-.Lend_cmp_one_char:
 | 
				
			||||||
 | 
					 	cr	%r0,%r1
 | 
				
			||||||
 | 
					 	je	.Lend_equal
 | 
				
			||||||
 | 
					 	lghi	%r2,1
 | 
				
			||||||
							
								
								
									
										248
									
								
								SOURCES/glibc-RHEL-49490-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										248
									
								
								SOURCES/glibc-RHEL-49490-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,248 @@
 | 
				
			|||||||
 | 
					commit 54252394c25ddf0062e288d4a6ab7a885f8ae009
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Thu Jun 27 16:26:56 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Enhanced test coverage for strncmp, wcsncmp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Add string/test-strncmp-nonarray and
 | 
				
			||||||
 | 
					    wcsmbs/test-wcsncmp-nonarray.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This is the test that uncovered bug 31934.  Test run time
 | 
				
			||||||
 | 
					    is more than one minute on a fairly current system, so turn
 | 
				
			||||||
 | 
					    these into xtests that do not run automatically.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/string/Makefile b/string/Makefile
 | 
				
			||||||
 | 
					--- a/string/Makefile	2024-09-17 14:28:06.030433788 -0400
 | 
				
			||||||
 | 
					+++ b/string/Makefile	2024-09-17 14:33:56.846338606 -0400
 | 
				
			||||||
 | 
					@@ -62,7 +62,11 @@ tests		:= tester inl-tester noinl-tester
 | 
				
			||||||
 | 
					 		   test-endian-sign-conversion
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 # This test allocates a lot of memory and can run for a long time.
 | 
				
			||||||
 | 
					-xtests = tst-strcoll-overflow
 | 
				
			||||||
 | 
					+xtests += tst-strcoll-overflow
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+# This test runs for a long time.
 | 
				
			||||||
 | 
					+xtests += test-strncmp-nonarray
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 # This test needs libdl.
 | 
				
			||||||
 | 
					 ifeq (yes,$(build-shared))
 | 
				
			||||||
 | 
					diff -Nrup a/string/test-Xncmp-nonarray.c b/string/test-Xncmp-nonarray.c
 | 
				
			||||||
 | 
					--- a/string/test-Xncmp-nonarray.c	1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/string/test-Xncmp-nonarray.c	2024-09-17 14:27:27.538224809 -0400
 | 
				
			||||||
 | 
					@@ -0,0 +1,183 @@
 | 
				
			||||||
 | 
					+/* Test non-array inputs to string comparison functions.
 | 
				
			||||||
 | 
					+   Copyright (C) 2024 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* This skeleton file is included from string/test-strncmp-nonarray.c and
 | 
				
			||||||
 | 
					+   wcsmbs/test-wcsncmp-nonarray.c to test that reading of the arrays stops
 | 
				
			||||||
 | 
					+   at the first null character.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   TEST_IDENTIFIER must be the test function identifier.  TEST_NAME is
 | 
				
			||||||
 | 
					+   the same as a string.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   CHAR must be defined as the character type.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <array_length.h>
 | 
				
			||||||
 | 
					+#include <string.h>
 | 
				
			||||||
 | 
					+#include <support/check.h>
 | 
				
			||||||
 | 
					+#include <support/next_to_fault.h>
 | 
				
			||||||
 | 
					+#include <support/test-driver.h>
 | 
				
			||||||
 | 
					+#include <sys/param.h>
 | 
				
			||||||
 | 
					+#include <unistd.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Much shorter than test-Xnlen-nonarray.c because of deeply nested loops.  */
 | 
				
			||||||
 | 
					+enum { buffer_length = 80 };
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* The test buffer layout follows what is described test-Xnlen-nonarray.c,
 | 
				
			||||||
 | 
					+   except that there two buffers, left and right.  The variables
 | 
				
			||||||
 | 
					+   a_count, zero_count, start_offset are all duplicated.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Return the maximum string length for a string that starts at
 | 
				
			||||||
 | 
					+   start_offset.  */
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+string_length (int a_count, int start_offset)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (start_offset == buffer_length || start_offset >= a_count)
 | 
				
			||||||
 | 
					+    return 0;
 | 
				
			||||||
 | 
					+  else
 | 
				
			||||||
 | 
					+    return a_count - start_offset;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* This is the valid maximum length argument computation for
 | 
				
			||||||
 | 
					+   strnlen/wcsnlen.  See text-Xnlen-nonarray.c.  */
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+maximum_length (int start_offset, int zero_count)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (start_offset == buffer_length)
 | 
				
			||||||
 | 
					+    return 0;
 | 
				
			||||||
 | 
					+  else if (zero_count > 0)
 | 
				
			||||||
 | 
					+    /* Effectively unbounded, but we need to stop fairly low,
 | 
				
			||||||
 | 
					+       otherwise testing takes too long.  */
 | 
				
			||||||
 | 
					+    return buffer_length + 32;
 | 
				
			||||||
 | 
					+  else
 | 
				
			||||||
 | 
					+    return buffer_length - start_offset;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+typedef __typeof (TEST_IDENTIFIER) *proto_t;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#define TEST_MAIN
 | 
				
			||||||
 | 
					+#include "test-string.h"
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+IMPL (TEST_IDENTIFIER, 1)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+test_main (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  TEST_VERIFY_EXIT (sysconf (_SC_PAGESIZE) >= buffer_length);
 | 
				
			||||||
 | 
					+  test_init ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  struct support_next_to_fault left_ntf
 | 
				
			||||||
 | 
					+    = support_next_to_fault_allocate (buffer_length * sizeof (CHAR));
 | 
				
			||||||
 | 
					+  CHAR *left_buffer = (CHAR *) left_ntf.buffer;
 | 
				
			||||||
 | 
					+  struct support_next_to_fault right_ntf
 | 
				
			||||||
 | 
					+    = support_next_to_fault_allocate (buffer_length * sizeof (CHAR));
 | 
				
			||||||
 | 
					+  CHAR *right_buffer = (CHAR *) right_ntf.buffer;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  FOR_EACH_IMPL (impl, 0)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      printf ("info: testing %s\n", impl->name);
 | 
				
			||||||
 | 
					+      for (size_t i = 0; i < buffer_length; ++i)
 | 
				
			||||||
 | 
					+        left_buffer[i] = 'A';
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      for (int left_zero_count = 0; left_zero_count <= buffer_length;
 | 
				
			||||||
 | 
					+           ++left_zero_count)
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          if (left_zero_count > 0)
 | 
				
			||||||
 | 
					+            left_buffer[buffer_length - left_zero_count] = 0;
 | 
				
			||||||
 | 
					+          int left_a_count = buffer_length - left_zero_count;
 | 
				
			||||||
 | 
					+          for (size_t i = 0; i < buffer_length; ++i)
 | 
				
			||||||
 | 
					+            right_buffer[i] = 'A';
 | 
				
			||||||
 | 
					+          for (int right_zero_count = 0; right_zero_count <= buffer_length;
 | 
				
			||||||
 | 
					+               ++right_zero_count)
 | 
				
			||||||
 | 
					+            {
 | 
				
			||||||
 | 
					+              if (right_zero_count > 0)
 | 
				
			||||||
 | 
					+                right_buffer[buffer_length - right_zero_count] = 0;
 | 
				
			||||||
 | 
					+              int right_a_count = buffer_length - right_zero_count;
 | 
				
			||||||
 | 
					+              for (int left_start_offset = 0;
 | 
				
			||||||
 | 
					+                   left_start_offset <= buffer_length;
 | 
				
			||||||
 | 
					+                   ++left_start_offset)
 | 
				
			||||||
 | 
					+                {
 | 
				
			||||||
 | 
					+                  CHAR *left_start_pointer = left_buffer + left_start_offset;
 | 
				
			||||||
 | 
					+                  int left_maxlen
 | 
				
			||||||
 | 
					+                    = maximum_length (left_start_offset, left_zero_count);
 | 
				
			||||||
 | 
					+                  int left_length
 | 
				
			||||||
 | 
					+                    = string_length (left_a_count, left_start_offset);
 | 
				
			||||||
 | 
					+                  for (int right_start_offset = 0;
 | 
				
			||||||
 | 
					+                       right_start_offset <= buffer_length;
 | 
				
			||||||
 | 
					+                       ++right_start_offset)
 | 
				
			||||||
 | 
					+                    {
 | 
				
			||||||
 | 
					+                      CHAR *right_start_pointer
 | 
				
			||||||
 | 
					+                        = right_buffer + right_start_offset;
 | 
				
			||||||
 | 
					+                      int right_maxlen
 | 
				
			||||||
 | 
					+                        = maximum_length (right_start_offset, right_zero_count);
 | 
				
			||||||
 | 
					+                      int right_length
 | 
				
			||||||
 | 
					+                        = string_length (right_a_count, right_start_offset);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+                      /* Maximum length is modelled after strnlen/wcsnlen,
 | 
				
			||||||
 | 
					+                         and must be valid for both pointer arguments at
 | 
				
			||||||
 | 
					+                         the same time.  */
 | 
				
			||||||
 | 
					+                      int maxlen = MIN (left_maxlen, right_maxlen);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+                      for (int length_argument = 0; length_argument <= maxlen;
 | 
				
			||||||
 | 
					+                           ++length_argument)
 | 
				
			||||||
 | 
					+                        {
 | 
				
			||||||
 | 
					+                          if (test_verbose)
 | 
				
			||||||
 | 
					+                            {
 | 
				
			||||||
 | 
					+                              printf ("left: zero_count=%d"
 | 
				
			||||||
 | 
					+                                      " a_count=%d start_offset=%d\n",
 | 
				
			||||||
 | 
					+                                      left_zero_count, left_a_count,
 | 
				
			||||||
 | 
					+                                      left_start_offset);
 | 
				
			||||||
 | 
					+                              printf ("right: zero_count=%d"
 | 
				
			||||||
 | 
					+                                      " a_count=%d start_offset=%d\n",
 | 
				
			||||||
 | 
					+                                      right_zero_count, right_a_count,
 | 
				
			||||||
 | 
					+                                      right_start_offset);
 | 
				
			||||||
 | 
					+                              printf ("length argument: %d\n",
 | 
				
			||||||
 | 
					+                                      length_argument);
 | 
				
			||||||
 | 
					+                            }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+                          /* Effective lengths bounded by length argument.
 | 
				
			||||||
 | 
					+                             The effective length determines the
 | 
				
			||||||
 | 
					+                             outcome of the comparison.  */
 | 
				
			||||||
 | 
					+                          int left_effective
 | 
				
			||||||
 | 
					+                            = MIN (left_length, length_argument);
 | 
				
			||||||
 | 
					+                          int right_effective
 | 
				
			||||||
 | 
					+                            = MIN (right_length, length_argument);
 | 
				
			||||||
 | 
					+                          if (left_effective == right_effective)
 | 
				
			||||||
 | 
					+                            TEST_COMPARE (CALL (impl,
 | 
				
			||||||
 | 
					+                                                left_start_pointer,
 | 
				
			||||||
 | 
					+                                                right_start_pointer,
 | 
				
			||||||
 | 
					+                                                length_argument), 0);
 | 
				
			||||||
 | 
					+                          else if (left_effective < right_effective)
 | 
				
			||||||
 | 
					+                            TEST_COMPARE (CALL (impl,
 | 
				
			||||||
 | 
					+                                                left_start_pointer,
 | 
				
			||||||
 | 
					+                                                right_start_pointer,
 | 
				
			||||||
 | 
					+                                                length_argument) < 0, 1);
 | 
				
			||||||
 | 
					+                          else
 | 
				
			||||||
 | 
					+                            TEST_COMPARE (CALL (impl,
 | 
				
			||||||
 | 
					+                                                left_start_pointer,
 | 
				
			||||||
 | 
					+                                                right_start_pointer,
 | 
				
			||||||
 | 
					+                                                length_argument) > 0, 1);
 | 
				
			||||||
 | 
					+                        }
 | 
				
			||||||
 | 
					+                    }
 | 
				
			||||||
 | 
					+                }
 | 
				
			||||||
 | 
					+            }
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
 | 
					diff -Nrup a/string/test-strncmp-nonarray.c b/string/test-strncmp-nonarray.c
 | 
				
			||||||
 | 
					--- a/string/test-strncmp-nonarray.c    1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/string/test-strncmp-nonarray.c    2024-09-17 14:27:27.538224809 -0400
 | 
				
			||||||
 | 
					@@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					+#define TEST_IDENTIFIER strncmp
 | 
				
			||||||
 | 
					+#define TEST_NAME "strncmp"
 | 
				
			||||||
 | 
					+typedef char CHAR;
 | 
				
			||||||
 | 
					+#include "test-Xncmp-nonarray.c"
 | 
				
			||||||
 | 
					diff -Nrup a/wcsmbs/Makefile b/wcsmbs/Makefile
 | 
				
			||||||
 | 
					--- a/wcsmbs/Makefile	2018-08-01 01:10:47.000000000 -0400
 | 
				
			||||||
 | 
					+++ b/wcsmbs/Makefile	2024-09-17 14:31:04.725404041 -0400
 | 
				
			||||||
 | 
					@@ -53,6 +53,9 @@ tests := tst-wcstof wcsmbs-tst1 tst-wcsn
 | 
				
			||||||
 | 
					 	 tst-wcstod-round test-char-types tst-fgetwc-after-eof \
 | 
				
			||||||
 | 
					 	 tst-wcstod-nan-sign $(addprefix test-,$(strop-tests))
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+# This test runs for a long time.
 | 
				
			||||||
 | 
					+xtests += test-wcsncmp-nonarray
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 include ../Rules
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 ifeq ($(run-built-tests),yes)
 | 
				
			||||||
 | 
					diff -Nrup a/wcsmbs/test-wcsncmp-nonarray.c b/wcsmbs/test-wcsncmp-nonarray.c
 | 
				
			||||||
 | 
					--- a/wcsmbs/test-wcsncmp-nonarray.c	1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/wcsmbs/test-wcsncmp-nonarray.c	2024-09-17 14:27:27.539224815 -0400
 | 
				
			||||||
 | 
					@@ -0,0 +1,5 @@
 | 
				
			||||||
 | 
					+#include <wchar.h>
 | 
				
			||||||
 | 
					+#define TEST_IDENTIFIER wcsncmp
 | 
				
			||||||
 | 
					+#define TEST_NAME "wcsncmp"
 | 
				
			||||||
 | 
					+typedef wchar_t CHAR;
 | 
				
			||||||
 | 
					+#include "../string/test-Xncmp-nonarray.c"
 | 
				
			||||||
							
								
								
									
										374
									
								
								SOURCES/glibc-RHEL-61255.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										374
									
								
								SOURCES/glibc-RHEL-61255.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,374 @@
 | 
				
			|||||||
 | 
					commit 03e1378f94173fc192a81e421457198f7b8a34a0
 | 
				
			||||||
 | 
					Author: Alex Butler <Alex.Butler@arm.com>
 | 
				
			||||||
 | 
					Date:   Tue Jun 16 12:44:24 2020 +0000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    aarch64: MTE compatible strncmp
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Add support for MTE to strncmp. Regression tested with xcheck and benchmarked
 | 
				
			||||||
 | 
					    with glibc's benchtests on the Cortex-A53, Cortex-A72, and Neoverse N1.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The existing implementation assumes that any access to the pages in which the
 | 
				
			||||||
 | 
					    string resides is safe. This assumption is not true when MTE is enabled. This
 | 
				
			||||||
 | 
					    patch updates the algorithm to ensure that accesses remain within the bounds
 | 
				
			||||||
 | 
					    of an MTE tag (16-byte chunks) and improves overall performance.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Co-authored-by: Branislav Rankov <branislav.rankov@arm.com>
 | 
				
			||||||
 | 
					    Co-authored-by: Wilco Dijkstra <wilco.dijkstra@arm.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sysdeps/aarch64/strncmp.S b/sysdeps/aarch64/strncmp.S
 | 
				
			||||||
 | 
					index c5141fab8a..ba2563490e 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/aarch64/strncmp.S
 | 
				
			||||||
 | 
					+++ b/sysdeps/aarch64/strncmp.S
 | 
				
			||||||
 | 
					@@ -25,7 +25,6 @@
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #define REP8_01 0x0101010101010101
 | 
				
			||||||
 | 
					 #define REP8_7f 0x7f7f7f7f7f7f7f7f
 | 
				
			||||||
 | 
					-#define REP8_80 0x8080808080808080
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Parameters and result.  */
 | 
				
			||||||
 | 
					 #define src1		x0
 | 
				
			||||||
 | 
					@@ -46,15 +45,31 @@
 | 
				
			||||||
 | 
					 #define tmp3		x10
 | 
				
			||||||
 | 
					 #define zeroones	x11
 | 
				
			||||||
 | 
					 #define pos		x12
 | 
				
			||||||
 | 
					-#define limit_wd	x13
 | 
				
			||||||
 | 
					-#define mask		x14
 | 
				
			||||||
 | 
					-#define endloop		x15
 | 
				
			||||||
 | 
					+#define mask		x13
 | 
				
			||||||
 | 
					+#define endloop		x14
 | 
				
			||||||
 | 
					 #define count		mask
 | 
				
			||||||
 | 
					+#define offset		pos
 | 
				
			||||||
 | 
					+#define neg_offset	x15
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-ENTRY_ALIGN_AND_PAD (strncmp, 6, 7)
 | 
				
			||||||
 | 
					-	DELOUSE (0)
 | 
				
			||||||
 | 
					-	DELOUSE (1)
 | 
				
			||||||
 | 
					-	DELOUSE (2)
 | 
				
			||||||
 | 
					+/* Define endian dependent shift operations.
 | 
				
			||||||
 | 
					+   On big-endian early bytes are at MSB and on little-endian LSB.
 | 
				
			||||||
 | 
					+   LS_FW means shifting towards early bytes.
 | 
				
			||||||
 | 
					+   LS_BK means shifting towards later bytes.
 | 
				
			||||||
 | 
					+   */
 | 
				
			||||||
 | 
					+#ifdef __AARCH64EB__
 | 
				
			||||||
 | 
					+#define LS_FW lsl
 | 
				
			||||||
 | 
					+#define LS_BK lsr
 | 
				
			||||||
 | 
					+#else
 | 
				
			||||||
 | 
					+#define LS_FW lsr
 | 
				
			||||||
 | 
					+#define LS_BK lsl
 | 
				
			||||||
 | 
					+#endif
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	.text
 | 
				
			||||||
 | 
					+	.p2align 6
 | 
				
			||||||
 | 
					+	.rep 9
 | 
				
			||||||
 | 
					+	nop	/* Pad so that the loop below fits a cache line.  */
 | 
				
			||||||
 | 
					+	.endr
 | 
				
			||||||
 | 
					+ENTRY_ALIGN (strncmp, 0)
 | 
				
			||||||
 | 
					 	cbz	limit, L(ret0)
 | 
				
			||||||
 | 
					 	eor	tmp1, src1, src2
 | 
				
			||||||
 | 
					 	mov	zeroones, #REP8_01
 | 
				
			||||||
 | 
					@@ -62,9 +77,6 @@ ENTRY_ALIGN_AND_PAD (strncmp, 6, 7)
 | 
				
			||||||
 | 
					 	and	count, src1, #7
 | 
				
			||||||
 | 
					 	b.ne	L(misaligned8)
 | 
				
			||||||
 | 
					 	cbnz	count, L(mutual_align)
 | 
				
			||||||
 | 
					-	/* Calculate the number of full and partial words -1.  */
 | 
				
			||||||
 | 
					-	sub	limit_wd, limit, #1	/* limit != 0, so no underflow.  */
 | 
				
			||||||
 | 
					-	lsr	limit_wd, limit_wd, #3	/* Convert to Dwords.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* NUL detection works on the principle that (X - 1) & (~X) & 0x80
 | 
				
			||||||
 | 
					 	   (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and
 | 
				
			||||||
 | 
					@@ -74,56 +86,52 @@ L(loop_aligned):
 | 
				
			||||||
 | 
					 	ldr	data1, [src1], #8
 | 
				
			||||||
 | 
					 	ldr	data2, [src2], #8
 | 
				
			||||||
 | 
					 L(start_realigned):
 | 
				
			||||||
 | 
					-	subs	limit_wd, limit_wd, #1
 | 
				
			||||||
 | 
					+	subs	limit, limit, #8
 | 
				
			||||||
 | 
					 	sub	tmp1, data1, zeroones
 | 
				
			||||||
 | 
					 	orr	tmp2, data1, #REP8_7f
 | 
				
			||||||
 | 
					 	eor	diff, data1, data2	/* Non-zero if differences found.  */
 | 
				
			||||||
 | 
					-	csinv	endloop, diff, xzr, pl	/* Last Dword or differences.  */
 | 
				
			||||||
 | 
					+	csinv	endloop, diff, xzr, hi	/* Last Dword or differences.  */
 | 
				
			||||||
 | 
					 	bics	has_nul, tmp1, tmp2	/* Non-zero if NUL terminator.  */
 | 
				
			||||||
 | 
					 	ccmp	endloop, #0, #0, eq
 | 
				
			||||||
 | 
					 	b.eq	L(loop_aligned)
 | 
				
			||||||
 | 
					 	/* End of performance-critical section  -- one 64B cache line.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Not reached the limit, must have found the end or a diff.  */
 | 
				
			||||||
 | 
					-	tbz	limit_wd, #63, L(not_limit)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* Limit % 8 == 0 => all bytes significant.  */
 | 
				
			||||||
 | 
					-	ands	limit, limit, #7
 | 
				
			||||||
 | 
					-	b.eq	L(not_limit)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	lsl	limit, limit, #3	/* Bits -> bytes.  */
 | 
				
			||||||
 | 
					-	mov	mask, #~0
 | 
				
			||||||
 | 
					-#ifdef __AARCH64EB__
 | 
				
			||||||
 | 
					-	lsr	mask, mask, limit
 | 
				
			||||||
 | 
					-#else
 | 
				
			||||||
 | 
					-	lsl	mask, mask, limit
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-	bic	data1, data1, mask
 | 
				
			||||||
 | 
					-	bic	data2, data2, mask
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* Make sure that the NUL byte is marked in the syndrome.  */
 | 
				
			||||||
 | 
					-	orr	has_nul, has_nul, mask
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(not_limit):
 | 
				
			||||||
 | 
					+L(full_check):
 | 
				
			||||||
 | 
					+#ifndef __AARCH64EB__
 | 
				
			||||||
 | 
					 	orr	syndrome, diff, has_nul
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#ifndef	__AARCH64EB__
 | 
				
			||||||
 | 
					+	add	limit, limit, 8	/* Rewind limit to before last subs. */
 | 
				
			||||||
 | 
					+L(syndrome_check):
 | 
				
			||||||
 | 
					+	/* Limit was reached. Check if the NUL byte or the difference
 | 
				
			||||||
 | 
					+	   is before the limit. */
 | 
				
			||||||
 | 
					 	rev	syndrome, syndrome
 | 
				
			||||||
 | 
					 	rev	data1, data1
 | 
				
			||||||
 | 
					-	/* The MS-non-zero bit of the syndrome marks either the first bit
 | 
				
			||||||
 | 
					-	   that is different, or the top bit of the first zero byte.
 | 
				
			||||||
 | 
					-	   Shifting left now will bring the critical information into the
 | 
				
			||||||
 | 
					-	   top bits.  */
 | 
				
			||||||
 | 
					 	clz	pos, syndrome
 | 
				
			||||||
 | 
					 	rev	data2, data2
 | 
				
			||||||
 | 
					 	lsl	data1, data1, pos
 | 
				
			||||||
 | 
					+	cmp	limit, pos, lsr #3
 | 
				
			||||||
 | 
					 	lsl	data2, data2, pos
 | 
				
			||||||
 | 
					 	/* But we need to zero-extend (char is unsigned) the value and then
 | 
				
			||||||
 | 
					 	   perform a signed 32-bit subtraction.  */
 | 
				
			||||||
 | 
					 	lsr	data1, data1, #56
 | 
				
			||||||
 | 
					 	sub	result, data1, data2, lsr #56
 | 
				
			||||||
 | 
					-	RET
 | 
				
			||||||
 | 
					+	csel result, result, xzr, hi
 | 
				
			||||||
 | 
					+	ret
 | 
				
			||||||
 | 
					 #else
 | 
				
			||||||
 | 
					+	/* Not reached the limit, must have found the end or a diff.  */
 | 
				
			||||||
 | 
					+	tbz	limit, #63, L(not_limit)
 | 
				
			||||||
 | 
					+	add	tmp1, limit, 8
 | 
				
			||||||
 | 
					+	cbz	limit, L(not_limit)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	lsl	limit, tmp1, #3	/* Bits -> bytes.  */
 | 
				
			||||||
 | 
					+	mov	mask, #~0
 | 
				
			||||||
 | 
					+	lsr	mask, mask, limit
 | 
				
			||||||
 | 
					+	bic	data1, data1, mask
 | 
				
			||||||
 | 
					+	bic	data2, data2, mask
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	/* Make sure that the NUL byte is marked in the syndrome.  */
 | 
				
			||||||
 | 
					+	orr	has_nul, has_nul, mask
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+L(not_limit):
 | 
				
			||||||
 | 
					 	/* For big-endian we cannot use the trick with the syndrome value
 | 
				
			||||||
 | 
					 	   as carry-propagation can corrupt the upper bits if the trailing
 | 
				
			||||||
 | 
					 	   bytes in the string contain 0x01.  */
 | 
				
			||||||
 | 
					@@ -134,7 +142,7 @@ L(not_limit):
 | 
				
			||||||
 | 
					 	cmp	data1, data2
 | 
				
			||||||
 | 
					 	cset	result, ne
 | 
				
			||||||
 | 
					 	cneg	result, result, lo
 | 
				
			||||||
 | 
					-	RET
 | 
				
			||||||
 | 
					+	ret
 | 
				
			||||||
 | 
					 1:
 | 
				
			||||||
 | 
					 	/* Re-compute the NUL-byte detection, using a byte-reversed value.  */
 | 
				
			||||||
 | 
					 	rev	tmp3, data1
 | 
				
			||||||
 | 
					@@ -144,17 +152,18 @@ L(not_limit):
 | 
				
			||||||
 | 
					 	rev	has_nul, has_nul
 | 
				
			||||||
 | 
					 	orr	syndrome, diff, has_nul
 | 
				
			||||||
 | 
					 	clz	pos, syndrome
 | 
				
			||||||
 | 
					-	/* The MS-non-zero bit of the syndrome marks either the first bit
 | 
				
			||||||
 | 
					-	   that is different, or the top bit of the first zero byte.
 | 
				
			||||||
 | 
					+	/* The most-significant-non-zero bit of the syndrome marks either the
 | 
				
			||||||
 | 
					+	   first bit that is different, or the top bit of the first zero byte.
 | 
				
			||||||
 | 
					 	   Shifting left now will bring the critical information into the
 | 
				
			||||||
 | 
					 	   top bits.  */
 | 
				
			||||||
 | 
					+L(end_quick):
 | 
				
			||||||
 | 
					 	lsl	data1, data1, pos
 | 
				
			||||||
 | 
					 	lsl	data2, data2, pos
 | 
				
			||||||
 | 
					 	/* But we need to zero-extend (char is unsigned) the value and then
 | 
				
			||||||
 | 
					 	   perform a signed 32-bit subtraction.  */
 | 
				
			||||||
 | 
					 	lsr	data1, data1, #56
 | 
				
			||||||
 | 
					 	sub	result, data1, data2, lsr #56
 | 
				
			||||||
 | 
					-	RET
 | 
				
			||||||
 | 
					+	ret
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 L(mutual_align):
 | 
				
			||||||
 | 
					@@ -169,22 +178,12 @@ L(mutual_align):
 | 
				
			||||||
 | 
					 	neg	tmp3, count, lsl #3	/* 64 - bits(bytes beyond align). */
 | 
				
			||||||
 | 
					 	ldr	data2, [src2], #8
 | 
				
			||||||
 | 
					 	mov	tmp2, #~0
 | 
				
			||||||
 | 
					-	sub	limit_wd, limit, #1	/* limit != 0, so no underflow.  */
 | 
				
			||||||
 | 
					-#ifdef __AARCH64EB__
 | 
				
			||||||
 | 
					-	/* Big-endian.  Early bytes are at MSB.  */
 | 
				
			||||||
 | 
					-	lsl	tmp2, tmp2, tmp3	/* Shift (count & 63).  */
 | 
				
			||||||
 | 
					-#else
 | 
				
			||||||
 | 
					-	/* Little-endian.  Early bytes are at LSB.  */
 | 
				
			||||||
 | 
					-	lsr	tmp2, tmp2, tmp3	/* Shift (count & 63).  */
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-	and	tmp3, limit_wd, #7
 | 
				
			||||||
 | 
					-	lsr	limit_wd, limit_wd, #3
 | 
				
			||||||
 | 
					-	/* Adjust the limit. Only low 3 bits used, so overflow irrelevant.  */
 | 
				
			||||||
 | 
					-	add	limit, limit, count
 | 
				
			||||||
 | 
					-	add	tmp3, tmp3, count
 | 
				
			||||||
 | 
					+	LS_FW	tmp2, tmp2, tmp3	/* Shift (count & 63).  */
 | 
				
			||||||
 | 
					+	/* Adjust the limit and ensure it doesn't overflow.  */
 | 
				
			||||||
 | 
					+	adds	limit, limit, count
 | 
				
			||||||
 | 
					+	csinv	limit, limit, xzr, lo
 | 
				
			||||||
 | 
					 	orr	data1, data1, tmp2
 | 
				
			||||||
 | 
					 	orr	data2, data2, tmp2
 | 
				
			||||||
 | 
					-	add	limit_wd, limit_wd, tmp3, lsr #3
 | 
				
			||||||
 | 
					 	b	L(start_realigned)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	.p2align 6
 | 
				
			||||||
 | 
					@@ -203,18 +202,15 @@ L(byte_loop):
 | 
				
			||||||
 | 
					 	b.eq	L(byte_loop)
 | 
				
			||||||
 | 
					 L(done):
 | 
				
			||||||
 | 
					 	sub	result, data1, data2
 | 
				
			||||||
 | 
					-	RET
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					+	ret
 | 
				
			||||||
 | 
					 	/* Align the SRC1 to a dword by doing a bytewise compare and then do
 | 
				
			||||||
 | 
					 	   the dword loop.  */
 | 
				
			||||||
 | 
					 L(try_misaligned_words):
 | 
				
			||||||
 | 
					-	lsr	limit_wd, limit, #3
 | 
				
			||||||
 | 
					-	cbz	count, L(do_misaligned)
 | 
				
			||||||
 | 
					+	cbz	count, L(src1_aligned)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	neg	count, count
 | 
				
			||||||
 | 
					 	and	count, count, #7
 | 
				
			||||||
 | 
					 	sub	limit, limit, count
 | 
				
			||||||
 | 
					-	lsr	limit_wd, limit, #3
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 L(page_end_loop):
 | 
				
			||||||
 | 
					 	ldrb	data1w, [src1], #1
 | 
				
			||||||
 | 
					@@ -225,48 +221,98 @@ L(page_end_loop):
 | 
				
			||||||
 | 
					 	subs	count, count, #1
 | 
				
			||||||
 | 
					 	b.hi	L(page_end_loop)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-L(do_misaligned):
 | 
				
			||||||
 | 
					-	/* Prepare ourselves for the next page crossing.  Unlike the aligned
 | 
				
			||||||
 | 
					-	   loop, we fetch 1 less dword because we risk crossing bounds on
 | 
				
			||||||
 | 
					-	   SRC2.  */
 | 
				
			||||||
 | 
					-	mov	count, #8
 | 
				
			||||||
 | 
					-	subs	limit_wd, limit_wd, #1
 | 
				
			||||||
 | 
					-	b.lo	L(done_loop)
 | 
				
			||||||
 | 
					+	/* The following diagram explains the comparison of misaligned strings.
 | 
				
			||||||
 | 
					+	   The bytes are shown in natural order. For little-endian, it is
 | 
				
			||||||
 | 
					+	   reversed in the registers. The "x" bytes are before the string.
 | 
				
			||||||
 | 
					+	   The "|" separates data that is loaded at one time.
 | 
				
			||||||
 | 
					+	   src1     | a a a a a a a a | b b b c c c c c | . . .
 | 
				
			||||||
 | 
					+	   src2     | x x x x x a a a   a a a a a b b b | c c c c c . . .
 | 
				
			||||||
 | 
					+	   After shifting in each step, the data looks like this:
 | 
				
			||||||
 | 
					+	                STEP_A              STEP_B              STEP_C
 | 
				
			||||||
 | 
					+	   data1    a a a a a a a a     b b b c c c c c     b b b c c c c c
 | 
				
			||||||
 | 
					+	   data2    a a a a a a a a     b b b 0 0 0 0 0     0 0 0 c c c c c
 | 
				
			||||||
 | 
					+	   The bytes with "0" are eliminated from the syndrome via mask.
 | 
				
			||||||
 | 
					+	   Align SRC2 down to 16 bytes. This way we can read 16 bytes at a
 | 
				
			||||||
 | 
					+	   time from SRC2. The comparison happens in 3 steps. After each step
 | 
				
			||||||
 | 
					+	   the loop can exit, or read from SRC1 or SRC2. */
 | 
				
			||||||
 | 
					+L(src1_aligned):
 | 
				
			||||||
 | 
					+	/* Calculate offset from 8 byte alignment to string start in bits. No
 | 
				
			||||||
 | 
					+	   need to mask offset since shifts are ignoring upper bits. */
 | 
				
			||||||
 | 
					+	lsl	offset, src2, #3
 | 
				
			||||||
 | 
					+	bic	src2, src2, #0xf
 | 
				
			||||||
 | 
					+	mov	mask, -1
 | 
				
			||||||
 | 
					+	neg	neg_offset, offset
 | 
				
			||||||
 | 
					+	ldr	data1, [src1], #8
 | 
				
			||||||
 | 
					+	ldp	tmp1, tmp2, [src2], #16
 | 
				
			||||||
 | 
					+	LS_BK	mask, mask, neg_offset
 | 
				
			||||||
 | 
					+	and	neg_offset, neg_offset, #63	/* Need actual value for cmp later. */
 | 
				
			||||||
 | 
					+	/* Skip the first compare if data in tmp1 is irrelevant. */
 | 
				
			||||||
 | 
					+	tbnz	offset, 6, L(misaligned_mid_loop)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 L(loop_misaligned):
 | 
				
			||||||
 | 
					-	and	tmp2, src2, #0xff8
 | 
				
			||||||
 | 
					-	eor	tmp2, tmp2, #0xff8
 | 
				
			||||||
 | 
					-	cbz	tmp2, L(page_end_loop)
 | 
				
			||||||
 | 
					+	/* STEP_A: Compare full 8 bytes when there is enough data from SRC2.*/
 | 
				
			||||||
 | 
					+	LS_FW	data2, tmp1, offset
 | 
				
			||||||
 | 
					+	LS_BK	tmp1, tmp2, neg_offset
 | 
				
			||||||
 | 
					+	subs	limit, limit, #8
 | 
				
			||||||
 | 
					+	orr	data2, data2, tmp1	/* 8 bytes from SRC2 combined from two regs.*/
 | 
				
			||||||
 | 
					+	sub	has_nul, data1, zeroones
 | 
				
			||||||
 | 
					+	eor	diff, data1, data2	/* Non-zero if differences found.  */
 | 
				
			||||||
 | 
					+	orr	tmp3, data1, #REP8_7f
 | 
				
			||||||
 | 
					+	csinv	endloop, diff, xzr, hi	/* If limit, set to all ones. */
 | 
				
			||||||
 | 
					+	bic	has_nul, has_nul, tmp3	/* Non-zero if NUL byte found in SRC1. */
 | 
				
			||||||
 | 
					+	orr	tmp3, endloop, has_nul
 | 
				
			||||||
 | 
					+	cbnz	tmp3, L(full_check)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	ldr	data1, [src1], #8
 | 
				
			||||||
 | 
					-	ldr	data2, [src2], #8
 | 
				
			||||||
 | 
					-	sub	tmp1, data1, zeroones
 | 
				
			||||||
 | 
					-	orr	tmp2, data1, #REP8_7f
 | 
				
			||||||
 | 
					-	eor	diff, data1, data2	/* Non-zero if differences found.  */
 | 
				
			||||||
 | 
					-	bics	has_nul, tmp1, tmp2	/* Non-zero if NUL terminator.  */
 | 
				
			||||||
 | 
					-	ccmp	diff, #0, #0, eq
 | 
				
			||||||
 | 
					-	b.ne	L(not_limit)
 | 
				
			||||||
 | 
					-	subs	limit_wd, limit_wd, #1
 | 
				
			||||||
 | 
					-	b.pl	L(loop_misaligned)
 | 
				
			||||||
 | 
					+L(misaligned_mid_loop):
 | 
				
			||||||
 | 
					+	/* STEP_B: Compare first part of data1 to second part of tmp2. */
 | 
				
			||||||
 | 
					+	LS_FW	data2, tmp2, offset
 | 
				
			||||||
 | 
					+#ifdef __AARCH64EB__
 | 
				
			||||||
 | 
					+	/* For big-endian we do a byte reverse to avoid carry-propagation
 | 
				
			||||||
 | 
					+	problem described above. This way we can reuse the has_nul in the
 | 
				
			||||||
 | 
					+	next step and also use syndrome value trick at the end. */
 | 
				
			||||||
 | 
					+	rev	tmp3, data1
 | 
				
			||||||
 | 
					+	#define data1_fixed tmp3
 | 
				
			||||||
 | 
					+#else
 | 
				
			||||||
 | 
					+	#define data1_fixed data1
 | 
				
			||||||
 | 
					+#endif
 | 
				
			||||||
 | 
					+	sub	has_nul, data1_fixed, zeroones
 | 
				
			||||||
 | 
					+	orr	tmp3, data1_fixed, #REP8_7f
 | 
				
			||||||
 | 
					+	eor	diff, data2, data1	/* Non-zero if differences found.  */
 | 
				
			||||||
 | 
					+	bic	has_nul, has_nul, tmp3	/* Non-zero if NUL terminator.  */
 | 
				
			||||||
 | 
					+#ifdef __AARCH64EB__
 | 
				
			||||||
 | 
					+	rev	has_nul, has_nul
 | 
				
			||||||
 | 
					+#endif
 | 
				
			||||||
 | 
					+	cmp	limit, neg_offset, lsr #3
 | 
				
			||||||
 | 
					+	orr	syndrome, diff, has_nul
 | 
				
			||||||
 | 
					+	bic	syndrome, syndrome, mask	/* Ignore later bytes. */
 | 
				
			||||||
 | 
					+	csinv	tmp3, syndrome, xzr, hi	/* If limit, set to all ones. */
 | 
				
			||||||
 | 
					+	cbnz	tmp3, L(syndrome_check)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-L(done_loop):
 | 
				
			||||||
 | 
					-	/* We found a difference or a NULL before the limit was reached.  */
 | 
				
			||||||
 | 
					-	and	limit, limit, #7
 | 
				
			||||||
 | 
					-	cbz	limit, L(not_limit)
 | 
				
			||||||
 | 
					-	/* Read the last word.  */
 | 
				
			||||||
 | 
					-	sub	src1, src1, 8
 | 
				
			||||||
 | 
					-	sub	src2, src2, 8
 | 
				
			||||||
 | 
					-	ldr	data1, [src1, limit]
 | 
				
			||||||
 | 
					-	ldr	data2, [src2, limit]
 | 
				
			||||||
 | 
					-	sub	tmp1, data1, zeroones
 | 
				
			||||||
 | 
					-	orr	tmp2, data1, #REP8_7f
 | 
				
			||||||
 | 
					-	eor	diff, data1, data2	/* Non-zero if differences found.  */
 | 
				
			||||||
 | 
					-	bics	has_nul, tmp1, tmp2	/* Non-zero if NUL terminator.  */
 | 
				
			||||||
 | 
					-	ccmp	diff, #0, #0, eq
 | 
				
			||||||
 | 
					-	b.ne	L(not_limit)
 | 
				
			||||||
 | 
					+	/* STEP_C: Compare second part of data1 to first part of tmp1. */
 | 
				
			||||||
 | 
					+	ldp	tmp1, tmp2, [src2], #16
 | 
				
			||||||
 | 
					+	cmp	limit, #8
 | 
				
			||||||
 | 
					+	LS_BK	data2, tmp1, neg_offset
 | 
				
			||||||
 | 
					+	eor	diff, data2, data1	/* Non-zero if differences found.  */
 | 
				
			||||||
 | 
					+	orr	syndrome, diff, has_nul
 | 
				
			||||||
 | 
					+	and	syndrome, syndrome, mask	/* Ignore earlier bytes. */
 | 
				
			||||||
 | 
					+	csinv	tmp3, syndrome, xzr, hi	/* If limit, set to all ones. */
 | 
				
			||||||
 | 
					+	cbnz	tmp3, L(syndrome_check)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	ldr	data1, [src1], #8
 | 
				
			||||||
 | 
					+	sub	limit, limit, #8
 | 
				
			||||||
 | 
					+	b	L(loop_misaligned)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#ifdef	__AARCH64EB__
 | 
				
			||||||
 | 
					+L(syndrome_check):
 | 
				
			||||||
 | 
					+	clz	pos, syndrome
 | 
				
			||||||
 | 
					+	cmp	pos, limit, lsl #3
 | 
				
			||||||
 | 
					+	b.lo	L(end_quick)
 | 
				
			||||||
 | 
					+#endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 L(ret0):
 | 
				
			||||||
 | 
					 	mov	result, #0
 | 
				
			||||||
 | 
					-	RET
 | 
				
			||||||
 | 
					+	ret
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 END (strncmp)
 | 
				
			||||||
 | 
					 libc_hidden_builtin_def (strncmp)
 | 
				
			||||||
							
								
								
									
										335
									
								
								SOURCES/glibc-RHEL-61259-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										335
									
								
								SOURCES/glibc-RHEL-61259-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,335 @@
 | 
				
			|||||||
 | 
					commit 2f47198b04a02097f438ecb765306fa39568a006
 | 
				
			||||||
 | 
					Author: Rajalakshmi Srinivasaraghavan <rajis@linux.ibm.com>
 | 
				
			||||||
 | 
					Date:   Fri Dec 2 14:26:41 2022 -0600
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    powerpc64: Remove old strncmp optimization
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This patch cleans up the power4 strncmp optimization for powerpc64 which
 | 
				
			||||||
 | 
					    is unlikely to be used anywhere.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Tested on ppc64le with and without --disable-multi-arch flag.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
 | 
				
			||||||
 | 
					    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/power4/strncmp.S
 | 
				
			||||||
 | 
						  (copyright year changes upstream)
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/multiarch/strncmp.c - fix indentation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
 | 
				
			||||||
 | 
					index 626845a43c4e8ded..5b20dab108de14ab 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
 | 
				
			||||||
 | 
					+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
 | 
				
			||||||
 | 
					@@ -12,8 +12,7 @@ sysdep_routines += memcpy-power8-cached memcpy-power7 memcpy-a2 memcpy-power6 \
 | 
				
			||||||
 | 
					 		   strnlen-power8 strnlen-power7 strnlen-ppc64 \
 | 
				
			||||||
 | 
					 		   strcasecmp-power7 strcasecmp_l-power7 \
 | 
				
			||||||
 | 
					 		   strncase-power7 strncase_l-power7 \
 | 
				
			||||||
 | 
					-		   strncmp-power8 strncmp-power7 \
 | 
				
			||||||
 | 
					-		   strncmp-power4 strncmp-ppc64 \
 | 
				
			||||||
 | 
					+		   strncmp-power8 strncmp-power7 strncmp-ppc64 \
 | 
				
			||||||
 | 
					 		   strchr-power8 strchr-power7 strchr-ppc64 \
 | 
				
			||||||
 | 
					 		   strchrnul-power8 strchrnul-power7 strchrnul-ppc64 \
 | 
				
			||||||
 | 
					 		   strcpy-power8 strcpy-power7 strcpy-ppc64 stpcpy-power8 \
 | 
				
			||||||
 | 
					diff -Nrup a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c	2024-11-21 16:22:27.914201581 -0500
 | 
				
			||||||
 | 
					+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c	2024-11-21 16:25:31.721479517 -0500
 | 
				
			||||||
 | 
					@@ -154,8 +154,6 @@ __libc_ifunc_impl_list (const char *name
 | 
				
			||||||
 | 
					 			      __strncmp_power8)
 | 
				
			||||||
 | 
					 	      IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
 | 
				
			||||||
 | 
					 			      __strncmp_power7)
 | 
				
			||||||
 | 
					-	      IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_POWER4,
 | 
				
			||||||
 | 
					-			      __strncmp_power4)
 | 
				
			||||||
 | 
					 	      IFUNC_IMPL_ADD (array, i, strncmp, 1,
 | 
				
			||||||
 | 
					 			      __strncmp_ppc))
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S
 | 
				
			||||||
 | 
					deleted file mode 100644
 | 
				
			||||||
 | 
					index 6ead3b6374749e6a..0000000000000000
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S
 | 
				
			||||||
 | 
					+++ /dev/null
 | 
				
			||||||
 | 
					@@ -1,23 +0,0 @@
 | 
				
			||||||
 | 
					-/* Copyright (C) 2013-2018 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					-   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					-   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					-   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					-   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					-   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					-   <http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#define STRNCMP __strncmp_power4
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#undef libc_hidden_builtin_def
 | 
				
			||||||
 | 
					-#define libc_hidden_builtin_def(name)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#include <sysdeps/powerpc/powerpc64/power4/strncmp.S>
 | 
				
			||||||
 | 
					diff -Nrup a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c	2024-11-21 19:52:23.420623986 -0500
 | 
				
			||||||
 | 
					+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c	2024-11-21 19:52:02.088475579 -0500
 | 
				
			||||||
 | 
					@@ -26,7 +26,6 @@
 | 
				
			||||||
 | 
					 # include "init-arch.h"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 extern __typeof (strncmp) __strncmp_ppc attribute_hidden;
 | 
				
			||||||
 | 
					-extern __typeof (strncmp) __strncmp_power4 attribute_hidden;
 | 
				
			||||||
 | 
					 extern __typeof (strncmp) __strncmp_power7 attribute_hidden;
 | 
				
			||||||
 | 
					 extern __typeof (strncmp) __strncmp_power8 attribute_hidden;
 | 
				
			||||||
 | 
					 # ifdef __LITTLE_ENDIAN__
 | 
				
			||||||
 | 
					@@ -41,11 +40,9 @@ libc_ifunc_redirected (__redirect_strncm
 | 
				
			||||||
 | 
					 			(hwcap2 & PPC_FEATURE2_ARCH_3_00)
 | 
				
			||||||
 | 
					 			? __strncmp_power9 :
 | 
				
			||||||
 | 
					 # endif
 | 
				
			||||||
 | 
					-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
 | 
				
			||||||
 | 
					-		       ? __strncmp_power8
 | 
				
			||||||
 | 
					-		       : (hwcap & PPC_FEATURE_HAS_VSX)
 | 
				
			||||||
 | 
					-			 ? __strncmp_power7
 | 
				
			||||||
 | 
					-			 : (hwcap & PPC_FEATURE_POWER4)
 | 
				
			||||||
 | 
					-			   ? __strncmp_power4
 | 
				
			||||||
 | 
					-			   : __strncmp_ppc);
 | 
				
			||||||
 | 
					+			(hwcap2 & PPC_FEATURE2_ARCH_2_07)
 | 
				
			||||||
 | 
					+			? __strncmp_power8
 | 
				
			||||||
 | 
					+			: (hwcap & PPC_FEATURE_HAS_VSX)
 | 
				
			||||||
 | 
					+			  ? __strncmp_power7
 | 
				
			||||||
 | 
					+			  : __strncmp_ppc);
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/power4/strncmp.S b/sysdeps/powerpc/powerpc64/power4/strncmp.S
 | 
				
			||||||
 | 
					deleted file mode 100644
 | 
				
			||||||
 | 
					index cf5f4e5fb8fb2522..0000000000000000
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/power4/strncmp.S
 | 
				
			||||||
 | 
					+++ /dev/null
 | 
				
			||||||
 | 
					@@ -1,225 +0,0 @@
 | 
				
			||||||
 | 
					-/* Optimized strcmp implementation for PowerPC64.
 | 
				
			||||||
 | 
					-   Copyright (C) 2003-2018 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					-   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					-   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					-   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					-   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					-   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					-   <http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#include <sysdep.h>
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#ifndef STRNCMP
 | 
				
			||||||
 | 
					-# define STRNCMP strncmp
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* See strlen.s for comments on how the end-of-string testing works.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* int [r3] strncmp (const char *s1 [r3], const char *s2 [r4], size_t size [r5])  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-ENTRY_TOCLESS (STRNCMP, 4)
 | 
				
			||||||
 | 
					-	CALL_MCOUNT 3
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#define rTMP2	r0
 | 
				
			||||||
 | 
					-#define rRTN	r3
 | 
				
			||||||
 | 
					-#define rSTR1	r3	/* first string arg */
 | 
				
			||||||
 | 
					-#define rSTR2	r4	/* second string arg */
 | 
				
			||||||
 | 
					-#define rN	r5	/* max string length */
 | 
				
			||||||
 | 
					-#define rWORD1	r6	/* current word in s1 */
 | 
				
			||||||
 | 
					-#define rWORD2	r7	/* current word in s2 */
 | 
				
			||||||
 | 
					-#define rWORD3  r10
 | 
				
			||||||
 | 
					-#define rWORD4  r11
 | 
				
			||||||
 | 
					-#define rFEFE	r8	/* constant 0xfefefefefefefeff (-0x0101010101010101) */
 | 
				
			||||||
 | 
					-#define r7F7F	r9	/* constant 0x7f7f7f7f7f7f7f7f */
 | 
				
			||||||
 | 
					-#define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
 | 
				
			||||||
 | 
					-#define rBITDIF	r11	/* bits that differ in s1 & s2 words */
 | 
				
			||||||
 | 
					-#define rTMP	r12
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	dcbt	0,rSTR1
 | 
				
			||||||
 | 
					-	or	rTMP, rSTR2, rSTR1
 | 
				
			||||||
 | 
					-	lis	r7F7F, 0x7f7f
 | 
				
			||||||
 | 
					-	dcbt	0,rSTR2
 | 
				
			||||||
 | 
					-	clrldi.	rTMP, rTMP, 61
 | 
				
			||||||
 | 
					-	cmpldi	cr1, rN, 0
 | 
				
			||||||
 | 
					-	lis	rFEFE, -0x101
 | 
				
			||||||
 | 
					-	bne	L(unaligned)
 | 
				
			||||||
 | 
					-/* We are doubleword aligned so set up for two loops.  first a double word
 | 
				
			||||||
 | 
					-   loop, then fall into the byte loop if any residual.  */
 | 
				
			||||||
 | 
					-	srdi.	rTMP, rN, 3
 | 
				
			||||||
 | 
					-	clrldi	rN, rN, 61
 | 
				
			||||||
 | 
					-	addi	rFEFE, rFEFE, -0x101
 | 
				
			||||||
 | 
					-	addi	r7F7F, r7F7F, 0x7f7f
 | 
				
			||||||
 | 
					-	cmpldi	cr1, rN, 0
 | 
				
			||||||
 | 
					-	beq	L(unaligned)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	mtctr	rTMP	/* Power4 wants mtctr 1st in dispatch group.  */
 | 
				
			||||||
 | 
					-	ld	rWORD1, 0(rSTR1)
 | 
				
			||||||
 | 
					-	ld	rWORD2, 0(rSTR2)
 | 
				
			||||||
 | 
					-	sldi	rTMP, rFEFE, 32
 | 
				
			||||||
 | 
					-	insrdi	r7F7F, r7F7F, 32, 0
 | 
				
			||||||
 | 
					-	add	rFEFE, rFEFE, rTMP
 | 
				
			||||||
 | 
					-	b	L(g1)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(g0):
 | 
				
			||||||
 | 
					-	ldu	rWORD1, 8(rSTR1)
 | 
				
			||||||
 | 
					-	bne-	cr1, L(different)
 | 
				
			||||||
 | 
					-	ldu	rWORD2, 8(rSTR2)
 | 
				
			||||||
 | 
					-L(g1):	add	rTMP, rFEFE, rWORD1
 | 
				
			||||||
 | 
					-	nor	rNEG, r7F7F, rWORD1
 | 
				
			||||||
 | 
					-	bdz	L(tail)
 | 
				
			||||||
 | 
					-	and.	rTMP, rTMP, rNEG
 | 
				
			||||||
 | 
					-	cmpd	cr1, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq+	L(g0)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* OK. We've hit the end of the string. We need to be careful that
 | 
				
			||||||
 | 
					-   we don't compare two strings as different because of gunk beyond
 | 
				
			||||||
 | 
					-   the end of the strings...  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#ifdef __LITTLE_ENDIAN__
 | 
				
			||||||
 | 
					-L(endstring):
 | 
				
			||||||
 | 
					-	addi    rTMP2, rTMP, -1
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	andc    rTMP2, rTMP2, rTMP
 | 
				
			||||||
 | 
					-	rldimi	rTMP2, rTMP2, 1, 0
 | 
				
			||||||
 | 
					-	and	rWORD2, rWORD2, rTMP2	/* Mask off gunk.  */
 | 
				
			||||||
 | 
					-	and	rWORD1, rWORD1, rTMP2
 | 
				
			||||||
 | 
					-	cmpd	cr1, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
 | 
				
			||||||
 | 
					-	neg	rNEG, rBITDIF
 | 
				
			||||||
 | 
					-	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
 | 
				
			||||||
 | 
					-	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
 | 
				
			||||||
 | 
					-	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
 | 
				
			||||||
 | 
					-	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
 | 
				
			||||||
 | 
					-	sld	rWORD2, rWORD2, rNEG
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63		/* must return an int.  */
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(equal):
 | 
				
			||||||
 | 
					-	li	rRTN, 0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(different):
 | 
				
			||||||
 | 
					-	ld	rWORD1, -8(rSTR1)
 | 
				
			||||||
 | 
					-	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
 | 
				
			||||||
 | 
					-	neg	rNEG, rBITDIF
 | 
				
			||||||
 | 
					-	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
 | 
				
			||||||
 | 
					-	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
 | 
				
			||||||
 | 
					-	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
 | 
				
			||||||
 | 
					-	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
 | 
				
			||||||
 | 
					-	sld	rWORD2, rWORD2, rNEG
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(highbit):
 | 
				
			||||||
 | 
					-	sradi	rRTN, rWORD2, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#else
 | 
				
			||||||
 | 
					-L(endstring):
 | 
				
			||||||
 | 
					-	and	rTMP, r7F7F, rWORD1
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	add	rTMP, rTMP, r7F7F
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	andc	rNEG, rNEG, rTMP
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	cntlzd	rBITDIF, rBITDIF
 | 
				
			||||||
 | 
					-	cntlzd	rNEG, rNEG
 | 
				
			||||||
 | 
					-	addi	rNEG, rNEG, 7
 | 
				
			||||||
 | 
					-	cmpd	cr1, rNEG, rBITDIF
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	cr1, L(equal)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63		/* must return an int.  */
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(equal):
 | 
				
			||||||
 | 
					-	li	rRTN, 0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(different):
 | 
				
			||||||
 | 
					-	ld	rWORD1, -8(rSTR1)
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(highbit):
 | 
				
			||||||
 | 
					-	sradi	rRTN, rWORD2, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* Oh well.  In this case, we just do a byte-by-byte comparison.  */
 | 
				
			||||||
 | 
					-	.align 4
 | 
				
			||||||
 | 
					-L(tail):
 | 
				
			||||||
 | 
					-	and.	rTMP, rTMP, rNEG
 | 
				
			||||||
 | 
					-	cmpd	cr1, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	bne-	L(endstring)
 | 
				
			||||||
 | 
					-	addi	rSTR1, rSTR1, 8
 | 
				
			||||||
 | 
					-	bne-	cr1, L(different)
 | 
				
			||||||
 | 
					-	addi	rSTR2, rSTR2, 8
 | 
				
			||||||
 | 
					-	cmpldi	cr1, rN, 0
 | 
				
			||||||
 | 
					-L(unaligned):
 | 
				
			||||||
 | 
					-	mtctr   rN	/* Power4 wants mtctr 1st in dispatch group */
 | 
				
			||||||
 | 
					-	ble	cr1, L(ux)
 | 
				
			||||||
 | 
					-L(uz):
 | 
				
			||||||
 | 
					-	lbz	rWORD1, 0(rSTR1)
 | 
				
			||||||
 | 
					-	lbz	rWORD2, 0(rSTR2)
 | 
				
			||||||
 | 
					-	.align 4
 | 
				
			||||||
 | 
					-L(u1):
 | 
				
			||||||
 | 
					-	cmpdi	cr1, rWORD1, 0
 | 
				
			||||||
 | 
					-	bdz	L(u4)
 | 
				
			||||||
 | 
					-	cmpd	rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq-	cr1, L(u4)
 | 
				
			||||||
 | 
					-	bne-	L(u4)
 | 
				
			||||||
 | 
					-	lbzu    rWORD3, 1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD4, 1(rSTR2)
 | 
				
			||||||
 | 
					-	cmpdi	cr1, rWORD3, 0
 | 
				
			||||||
 | 
					-	bdz	L(u3)
 | 
				
			||||||
 | 
					-	cmpd	rWORD3, rWORD4
 | 
				
			||||||
 | 
					-	beq-    cr1, L(u3)
 | 
				
			||||||
 | 
					-	bne-    L(u3)
 | 
				
			||||||
 | 
					-	lbzu	rWORD1, 1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD2, 1(rSTR2)
 | 
				
			||||||
 | 
					-	cmpdi	cr1, rWORD1, 0
 | 
				
			||||||
 | 
					-	bdz	L(u4)
 | 
				
			||||||
 | 
					-	cmpd	rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq-	cr1, L(u4)
 | 
				
			||||||
 | 
					-	bne-	L(u4)
 | 
				
			||||||
 | 
					-	lbzu	rWORD3, 1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD4, 1(rSTR2)
 | 
				
			||||||
 | 
					-	cmpdi	cr1, rWORD3, 0
 | 
				
			||||||
 | 
					-	bdz	L(u3)
 | 
				
			||||||
 | 
					-	cmpd	rWORD3, rWORD4
 | 
				
			||||||
 | 
					-	beq-    cr1, L(u3)
 | 
				
			||||||
 | 
					-	bne-    L(u3)
 | 
				
			||||||
 | 
					-	lbzu	rWORD1, 1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD2, 1(rSTR2)
 | 
				
			||||||
 | 
					-	b       L(u1)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(u3):  sub     rRTN, rWORD3, rWORD4
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(u4):	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(ux):
 | 
				
			||||||
 | 
					-	li	rRTN, 0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-END (STRNCMP)
 | 
				
			||||||
 | 
					-libc_hidden_builtin_def (strncmp)
 | 
				
			||||||
							
								
								
									
										595
									
								
								SOURCES/glibc-RHEL-61259-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										595
									
								
								SOURCES/glibc-RHEL-61259-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,595 @@
 | 
				
			|||||||
 | 
					commit 92fdb11ae7aa1ab6b18622670ea702205cd6fdc5
 | 
				
			||||||
 | 
					Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
 | 
				
			||||||
 | 
					Date:   Tue Feb 28 14:23:59 2023 -0300
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    powerpc: Remove powerpc64 strncmp variants
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The default, and power7 implementation just adds word aligned
 | 
				
			||||||
 | 
					    access when inputs have the same aligment.  The unaligned case
 | 
				
			||||||
 | 
					    is still done by byte operations.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This is already covered by the generic implementation, which also add
 | 
				
			||||||
 | 
					    the unaligned input optimization.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Checked on powerpc64-linux-gnu built without multi-arch for powerpc64,
 | 
				
			||||||
 | 
					    power7, power8, and power9 (build for le).
 | 
				
			||||||
 | 
					    Reviewed-by: Rajalakshmi Srinivasaraghavan <rajis@linux.ibm.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/power7/strncmp.S
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/strncmp.S
 | 
				
			||||||
 | 
						  (copyright year changes upstream)
 | 
				
			||||||
 | 
						sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c - PPC_FEATURE difference
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
 | 
				
			||||||
 | 
					index 5b20dab108de14ab..0ee7ce39d6470d80 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
 | 
				
			||||||
 | 
					+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
 | 
				
			||||||
 | 
					@@ -12,7 +12,7 @@ sysdep_routines += memcpy-power8-cached memcpy-power7 memcpy-a2 memcpy-power6 \
 | 
				
			||||||
 | 
					 		   strnlen-power8 strnlen-power7 strnlen-ppc64 \
 | 
				
			||||||
 | 
					 		   strcasecmp-power7 strcasecmp_l-power7 \
 | 
				
			||||||
 | 
					 		   strncase-power7 strncase_l-power7 \
 | 
				
			||||||
 | 
					-		   strncmp-power8 strncmp-power7 strncmp-ppc64 \
 | 
				
			||||||
 | 
					+		   strncmp-power8 strncmp-ppc64 \
 | 
				
			||||||
 | 
					 		   strchr-power8 strchr-power7 strchr-ppc64 \
 | 
				
			||||||
 | 
					 		   strchrnul-power8 strchrnul-power7 strchrnul-ppc64 \
 | 
				
			||||||
 | 
					 		   strcpy-power8 strcpy-power7 strcpy-ppc64 stpcpy-power8 \
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
 | 
				
			||||||
 | 
					index 914e7d5e28a98b5d..2c84d287ee76a7ea 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
 | 
				
			||||||
 | 
					+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
 | 
				
			||||||
 | 
					@@ -152,8 +152,6 @@ __libc_ifunc_impl_list (const char *name
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					 	      IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_2_07,
 | 
				
			||||||
 | 
					 			      __strncmp_power8)
 | 
				
			||||||
 | 
					-	      IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
 | 
				
			||||||
 | 
					-			      __strncmp_power7)
 | 
				
			||||||
 | 
					 	      IFUNC_IMPL_ADD (array, i, strncmp, 1,
 | 
				
			||||||
 | 
					 			      __strncmp_ppc))
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S
 | 
				
			||||||
 | 
					deleted file mode 100644
 | 
				
			||||||
 | 
					index 8282ff076c9e00ce..0000000000000000
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S
 | 
				
			||||||
 | 
					+++ /dev/null
 | 
				
			||||||
 | 
					@@ -1,23 +0,0 @@
 | 
				
			||||||
 | 
					-/* Copyright (C) 2013-2018 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					-   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					-   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					-   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					-   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					-   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					-   <http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#define STRNCMP __strncmp_power7
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#undef libc_hidden_builtin_def
 | 
				
			||||||
 | 
					-#define libc_hidden_builtin_def(name)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#include <sysdeps/powerpc/powerpc64/power7/strncmp.S>
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S
 | 
				
			||||||
 | 
					deleted file mode 100644
 | 
				
			||||||
 | 
					index c6f325650c9ace3b..0000000000000000
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S
 | 
				
			||||||
 | 
					+++ /dev/null
 | 
				
			||||||
 | 
					@@ -1,26 +0,0 @@
 | 
				
			||||||
 | 
					-/* Copyright (C) 2013-2018 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					-   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					-   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					-   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					-   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					-   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					-   <http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#if defined SHARED && IS_IN (libc)
 | 
				
			||||||
 | 
					-# define STRNCMP __strncmp_ppc
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-# undef libc_hidden_builtin_def
 | 
				
			||||||
 | 
					-# define libc_hidden_builtin_def(name)				\
 | 
				
			||||||
 | 
					-    .globl __GI_strncmp; __GI_strncmp = __strncmp_ppc
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#include <sysdeps/powerpc/powerpc64/strncmp.S>
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.c
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 0000000000000000..09cc009a913ed169
 | 
				
			||||||
 | 
					--- /dev/null
 | 
				
			||||||
 | 
					+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.c
 | 
				
			||||||
 | 
					@@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					+#if defined SHARED && IS_IN (libc)
 | 
				
			||||||
 | 
					+# define STRNCMP __strncmp_ppc
 | 
				
			||||||
 | 
					+# undef libc_hidden_builtin_def
 | 
				
			||||||
 | 
					+# define libc_hidden_builtin_def(name) \
 | 
				
			||||||
 | 
					+    __hidden_ver1 (__strncmp_ppc, __GI_strncmp, __strncmp_ppc);
 | 
				
			||||||
 | 
					+#endif
 | 
				
			||||||
 | 
					+#include <string/strncmp.c>
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
 | 
				
			||||||
 | 
					index 275a558e4afa7d61..df2c0707a919ad79 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
 | 
				
			||||||
 | 
					+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
 | 
				
			||||||
 | 
					@@ -26,7 +26,6 @@
 | 
				
			||||||
 | 
					 # include "init-arch.h"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 extern __typeof (strncmp) __strncmp_ppc attribute_hidden;
 | 
				
			||||||
 | 
					-extern __typeof (strncmp) __strncmp_power7 attribute_hidden;
 | 
				
			||||||
 | 
					 extern __typeof (strncmp) __strncmp_power8 attribute_hidden;
 | 
				
			||||||
 | 
					 # ifdef __LITTLE_ENDIAN__
 | 
				
			||||||
 | 
					 extern __typeof (strncmp) __strncmp_power9 attribute_hidden;
 | 
				
			||||||
 | 
					@@ -42,7 +41,5 @@ libc_ifunc_redirected (__redirect_strncm
 | 
				
			||||||
 | 
					 # endif
 | 
				
			||||||
 | 
					 			(hwcap2 & PPC_FEATURE2_ARCH_2_07)
 | 
				
			||||||
 | 
					 			? __strncmp_power8
 | 
				
			||||||
 | 
					-			: (hwcap & PPC_FEATURE_HAS_VSX)
 | 
				
			||||||
 | 
					-			  ? __strncmp_power7
 | 
				
			||||||
 | 
					-			  : __strncmp_ppc);
 | 
				
			||||||
 | 
					+			: __strncmp_ppc);			
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/power7/strncmp.S b/sysdeps/powerpc/powerpc64/power7/strncmp.S
 | 
				
			||||||
 | 
					deleted file mode 100644
 | 
				
			||||||
 | 
					index d91aeb6077a558f2..0000000000000000
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/power7/strncmp.S
 | 
				
			||||||
 | 
					+++ /dev/null
 | 
				
			||||||
 | 
					@@ -1,227 +0,0 @@
 | 
				
			||||||
 | 
					-/* Optimized strcmp implementation for POWER7/PowerPC64.
 | 
				
			||||||
 | 
					-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					-   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					-   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					-   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					-   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					-   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					-   <http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#include <sysdep.h>
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#ifndef STRNCMP
 | 
				
			||||||
 | 
					-# define STRNCMP strncmp
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* See strlen.s for comments on how the end-of-string testing works.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* int [r3] strncmp (const char *s1 [r3],
 | 
				
			||||||
 | 
					-		     const char *s2 [r4],
 | 
				
			||||||
 | 
					-		     size_t size [r5])  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-ENTRY_TOCLESS (STRNCMP, 5)
 | 
				
			||||||
 | 
					-	CALL_MCOUNT 3
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#define rTMP2	r0
 | 
				
			||||||
 | 
					-#define rRTN	r3
 | 
				
			||||||
 | 
					-#define rSTR1	r3	/* first string arg */
 | 
				
			||||||
 | 
					-#define rSTR2	r4	/* second string arg */
 | 
				
			||||||
 | 
					-#define rN	r5	/* max string length */
 | 
				
			||||||
 | 
					-#define rWORD1	r6	/* current word in s1 */
 | 
				
			||||||
 | 
					-#define rWORD2	r7	/* current word in s2 */
 | 
				
			||||||
 | 
					-#define rWORD3  r10
 | 
				
			||||||
 | 
					-#define rWORD4  r11
 | 
				
			||||||
 | 
					-#define rFEFE	r8	/* constant 0xfefefefefefefeff (-0x0101010101010101) */
 | 
				
			||||||
 | 
					-#define r7F7F	r9	/* constant 0x7f7f7f7f7f7f7f7f */
 | 
				
			||||||
 | 
					-#define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
 | 
				
			||||||
 | 
					-#define rBITDIF	r11	/* bits that differ in s1 & s2 words */
 | 
				
			||||||
 | 
					-#define rTMP	r12
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	dcbt	0,rSTR1
 | 
				
			||||||
 | 
					-	nop
 | 
				
			||||||
 | 
					-	or	rTMP,rSTR2,rSTR1
 | 
				
			||||||
 | 
					-	lis	r7F7F,0x7f7f
 | 
				
			||||||
 | 
					-	dcbt	0,rSTR2
 | 
				
			||||||
 | 
					-	nop
 | 
				
			||||||
 | 
					-	clrldi.	rTMP,rTMP,61
 | 
				
			||||||
 | 
					-	cmpldi	cr1,rN,0
 | 
				
			||||||
 | 
					-	lis	rFEFE,-0x101
 | 
				
			||||||
 | 
					-	bne	L(unaligned)
 | 
				
			||||||
 | 
					-/* We are doubleword aligned so set up for two loops.  first a double word
 | 
				
			||||||
 | 
					-   loop, then fall into the byte loop if any residual.  */
 | 
				
			||||||
 | 
					-	srdi.	rTMP,rN,3
 | 
				
			||||||
 | 
					-	clrldi	rN,rN,61
 | 
				
			||||||
 | 
					-	addi	rFEFE,rFEFE,-0x101
 | 
				
			||||||
 | 
					-	addi	r7F7F,r7F7F,0x7f7f
 | 
				
			||||||
 | 
					-	cmpldi	cr1,rN,0
 | 
				
			||||||
 | 
					-	beq	L(unaligned)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	mtctr	rTMP
 | 
				
			||||||
 | 
					-	ld	rWORD1,0(rSTR1)
 | 
				
			||||||
 | 
					-	ld	rWORD2,0(rSTR2)
 | 
				
			||||||
 | 
					-	sldi	rTMP,rFEFE,32
 | 
				
			||||||
 | 
					-	insrdi	r7F7F,r7F7F,32,0
 | 
				
			||||||
 | 
					-	add	rFEFE,rFEFE,rTMP
 | 
				
			||||||
 | 
					-	b	L(g1)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(g0):
 | 
				
			||||||
 | 
					-	ldu	rWORD1,8(rSTR1)
 | 
				
			||||||
 | 
					-	bne	cr1,L(different)
 | 
				
			||||||
 | 
					-	ldu	rWORD2,8(rSTR2)
 | 
				
			||||||
 | 
					-L(g1):	add	rTMP,rFEFE,rWORD1
 | 
				
			||||||
 | 
					-	nor	rNEG,r7F7F,rWORD1
 | 
				
			||||||
 | 
					-	bdz	L(tail)
 | 
				
			||||||
 | 
					-	and.	rTMP,rTMP,rNEG
 | 
				
			||||||
 | 
					-	cmpd	cr1,rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	beq	L(g0)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* OK. We've hit the end of the string. We need to be careful that
 | 
				
			||||||
 | 
					-   we don't compare two strings as different because of gunk beyond
 | 
				
			||||||
 | 
					-   the end of the strings...  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#ifdef __LITTLE_ENDIAN__
 | 
				
			||||||
 | 
					-L(endstring):
 | 
				
			||||||
 | 
					-	addi    rTMP2, rTMP, -1
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	andc    rTMP2, rTMP2, rTMP
 | 
				
			||||||
 | 
					-	rldimi	rTMP2, rTMP2, 1, 0
 | 
				
			||||||
 | 
					-	and	rWORD2, rWORD2, rTMP2	/* Mask off gunk.  */
 | 
				
			||||||
 | 
					-	and	rWORD1, rWORD1, rTMP2
 | 
				
			||||||
 | 
					-	cmpd	cr1, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	cmpb	rBITDIF, rWORD1, rWORD2	/* 0xff on equal bytes.  */
 | 
				
			||||||
 | 
					-	addi	rNEG, rBITDIF, 1
 | 
				
			||||||
 | 
					-	orc	rNEG, rNEG, rBITDIF	/* 0's below LS differing byte.  */
 | 
				
			||||||
 | 
					-	sldi	rNEG, rNEG, 8		/* 1's above LS differing byte.  */
 | 
				
			||||||
 | 
					-	andc	rWORD1, rWORD1, rNEG	/* mask off MS bytes.  */
 | 
				
			||||||
 | 
					-	andc	rWORD2, rWORD2, rNEG
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63		/* must return an int.  */
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(equal):
 | 
				
			||||||
 | 
					-	li	rRTN, 0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(different):
 | 
				
			||||||
 | 
					-	ld	rWORD1, -8(rSTR1)
 | 
				
			||||||
 | 
					-	cmpb	rBITDIF, rWORD1, rWORD2	/* 0xff on equal bytes.  */
 | 
				
			||||||
 | 
					-	addi	rNEG, rBITDIF, 1
 | 
				
			||||||
 | 
					-	orc	rNEG, rNEG, rBITDIF	/* 0's below LS differing byte.  */
 | 
				
			||||||
 | 
					-	sldi	rNEG, rNEG, 8		/* 1's above LS differing byte.  */
 | 
				
			||||||
 | 
					-	andc	rWORD1, rWORD1, rNEG	/* mask off MS bytes.  */
 | 
				
			||||||
 | 
					-	andc	rWORD2, rWORD2, rNEG
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(highbit):
 | 
				
			||||||
 | 
					-	sradi	rRTN, rWORD2, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#else
 | 
				
			||||||
 | 
					-L(endstring):
 | 
				
			||||||
 | 
					-	and	rTMP,r7F7F,rWORD1
 | 
				
			||||||
 | 
					-	beq	cr1,L(equal)
 | 
				
			||||||
 | 
					-	add	rTMP,rTMP,r7F7F
 | 
				
			||||||
 | 
					-	xor.	rBITDIF,rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	andc	rNEG,rNEG,rTMP
 | 
				
			||||||
 | 
					-	blt	L(highbit)
 | 
				
			||||||
 | 
					-	cntlzd	rBITDIF,rBITDIF
 | 
				
			||||||
 | 
					-	cntlzd	rNEG,rNEG
 | 
				
			||||||
 | 
					-	addi	rNEG,rNEG,7
 | 
				
			||||||
 | 
					-	cmpd	cr1,rNEG,rBITDIF
 | 
				
			||||||
 | 
					-	sub	rRTN,rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	blt	cr1,L(equal)
 | 
				
			||||||
 | 
					-	sradi	rRTN,rRTN,63		/* must return an int.  */
 | 
				
			||||||
 | 
					-	ori	rRTN,rRTN,1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(equal):
 | 
				
			||||||
 | 
					-	li	rRTN,0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(different):
 | 
				
			||||||
 | 
					-	ld	rWORD1,-8(rSTR1)
 | 
				
			||||||
 | 
					-	xor.	rBITDIF,rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN,rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	blt	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN,rRTN,63
 | 
				
			||||||
 | 
					-	ori	rRTN,rRTN,1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(highbit):
 | 
				
			||||||
 | 
					-	sradi	rRTN,rWORD2,63
 | 
				
			||||||
 | 
					-	ori	rRTN,rRTN,1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* Oh well.  In this case, we just do a byte-by-byte comparison.  */
 | 
				
			||||||
 | 
					-	.align	4
 | 
				
			||||||
 | 
					-L(tail):
 | 
				
			||||||
 | 
					-	and.	rTMP,rTMP,rNEG
 | 
				
			||||||
 | 
					-	cmpd	cr1,rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	bne	L(endstring)
 | 
				
			||||||
 | 
					-	addi	rSTR1,rSTR1,8
 | 
				
			||||||
 | 
					-	bne	cr1,L(different)
 | 
				
			||||||
 | 
					-	addi	rSTR2,rSTR2,8
 | 
				
			||||||
 | 
					-	cmpldi	cr1,rN,0
 | 
				
			||||||
 | 
					-L(unaligned):
 | 
				
			||||||
 | 
					-	mtctr	rN
 | 
				
			||||||
 | 
					-	ble	cr1,L(ux)
 | 
				
			||||||
 | 
					-L(uz):
 | 
				
			||||||
 | 
					-	lbz	rWORD1,0(rSTR1)
 | 
				
			||||||
 | 
					-	lbz	rWORD2,0(rSTR2)
 | 
				
			||||||
 | 
					-	.align	4
 | 
				
			||||||
 | 
					-L(u1):
 | 
				
			||||||
 | 
					-	cmpdi	cr1,rWORD1,0
 | 
				
			||||||
 | 
					-	bdz	L(u4)
 | 
				
			||||||
 | 
					-	cmpd	rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	beq	cr1,L(u4)
 | 
				
			||||||
 | 
					-	bne	L(u4)
 | 
				
			||||||
 | 
					-	lbzu	rWORD3,1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD4,1(rSTR2)
 | 
				
			||||||
 | 
					-	cmpdi	cr1,rWORD3,0
 | 
				
			||||||
 | 
					-	bdz	L(u3)
 | 
				
			||||||
 | 
					-	cmpd	rWORD3,rWORD4
 | 
				
			||||||
 | 
					-	beq	cr1,L(u3)
 | 
				
			||||||
 | 
					-	bne	L(u3)
 | 
				
			||||||
 | 
					-	lbzu	rWORD1,1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD2,1(rSTR2)
 | 
				
			||||||
 | 
					-	cmpdi	cr1,rWORD1,0
 | 
				
			||||||
 | 
					-	bdz	L(u4)
 | 
				
			||||||
 | 
					-	cmpd	rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	beq	cr1,L(u4)
 | 
				
			||||||
 | 
					-	bne	L(u4)
 | 
				
			||||||
 | 
					-	lbzu	rWORD3,1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD4,1(rSTR2)
 | 
				
			||||||
 | 
					-	cmpdi	cr1,rWORD3,0
 | 
				
			||||||
 | 
					-	bdz	L(u3)
 | 
				
			||||||
 | 
					-	cmpd	rWORD3,rWORD4
 | 
				
			||||||
 | 
					-	beq	cr1,L(u3)
 | 
				
			||||||
 | 
					-	bne	L(u3)
 | 
				
			||||||
 | 
					-	lbzu	rWORD1,1(rSTR1)
 | 
				
			||||||
 | 
					-	lbzu	rWORD2,1(rSTR2)
 | 
				
			||||||
 | 
					-	b	L(u1)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(u3):  sub	rRTN,rWORD3,rWORD4
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(u4):	sub	rRTN,rWORD1,rWORD2
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(ux):
 | 
				
			||||||
 | 
					-	li	rRTN,0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-END (STRNCMP)
 | 
				
			||||||
 | 
					-libc_hidden_builtin_def (strncmp)
 | 
				
			||||||
 | 
					diff --git a/sysdeps/powerpc/powerpc64/strncmp.S b/sysdeps/powerpc/powerpc64/strncmp.S
 | 
				
			||||||
 | 
					deleted file mode 100644
 | 
				
			||||||
 | 
					index 40a230242cbdf733..0000000000000000
 | 
				
			||||||
 | 
					--- a/sysdeps/powerpc/powerpc64/strncmp.S
 | 
				
			||||||
 | 
					+++ /dev/null
 | 
				
			||||||
 | 
					@@ -1,210 +0,0 @@
 | 
				
			||||||
 | 
					-/* Optimized strcmp implementation for PowerPC64.
 | 
				
			||||||
 | 
					-   Copyright (C) 2003-2018 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					-   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					-   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					-   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					-   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					-   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					-   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					-   <http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#include <sysdep.h>
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* See strlen.s for comments on how the end-of-string testing works.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* int [r3] strncmp (const char *s1 [r3], const char *s2 [r4], size_t size [r5])  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#ifndef STRNCMP
 | 
				
			||||||
 | 
					-# define STRNCMP strncmp
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-ENTRY_TOCLESS (STRNCMP, 4)
 | 
				
			||||||
 | 
					-	CALL_MCOUNT 3
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#define rTMP2	r0
 | 
				
			||||||
 | 
					-#define rRTN	r3
 | 
				
			||||||
 | 
					-#define rSTR1	r3	/* first string arg */
 | 
				
			||||||
 | 
					-#define rSTR2	r4	/* second string arg */
 | 
				
			||||||
 | 
					-#define rN	r5	/* max string length */
 | 
				
			||||||
 | 
					-#define rWORD1	r6	/* current word in s1 */
 | 
				
			||||||
 | 
					-#define rWORD2	r7	/* current word in s2 */
 | 
				
			||||||
 | 
					-#define rFEFE	r8	/* constant 0xfefefefefefefeff (-0x0101010101010101) */
 | 
				
			||||||
 | 
					-#define r7F7F	r9	/* constant 0x7f7f7f7f7f7f7f7f */
 | 
				
			||||||
 | 
					-#define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
 | 
				
			||||||
 | 
					-#define rBITDIF	r11	/* bits that differ in s1 & s2 words */
 | 
				
			||||||
 | 
					-#define rTMP	r12
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	dcbt	0,rSTR1
 | 
				
			||||||
 | 
					-	or	rTMP, rSTR2, rSTR1
 | 
				
			||||||
 | 
					-	lis	r7F7F, 0x7f7f
 | 
				
			||||||
 | 
					-	dcbt	0,rSTR2
 | 
				
			||||||
 | 
					-	clrldi.	rTMP, rTMP, 61
 | 
				
			||||||
 | 
					-	cmpldi	cr1, rN, 0
 | 
				
			||||||
 | 
					-	lis	rFEFE, -0x101
 | 
				
			||||||
 | 
					-	bne	L(unaligned)
 | 
				
			||||||
 | 
					-/* We are doubleword aligned so set up for two loops.  first a double word
 | 
				
			||||||
 | 
					-   loop, then fall into the byte loop if any residual.  */
 | 
				
			||||||
 | 
					-	srdi.	rTMP, rN, 3
 | 
				
			||||||
 | 
					-	clrldi	rN, rN, 61
 | 
				
			||||||
 | 
					-	addi	rFEFE, rFEFE, -0x101
 | 
				
			||||||
 | 
					-	addi	r7F7F, r7F7F, 0x7f7f
 | 
				
			||||||
 | 
					-	cmpldi	cr1, rN, 0
 | 
				
			||||||
 | 
					-	beq	L(unaligned)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	mtctr	rTMP	/* Power4 wants mtctr 1st in dispatch group.  */
 | 
				
			||||||
 | 
					-	ld	rWORD1, 0(rSTR1)
 | 
				
			||||||
 | 
					-	ld	rWORD2, 0(rSTR2)
 | 
				
			||||||
 | 
					-	sldi	rTMP, rFEFE, 32
 | 
				
			||||||
 | 
					-	insrdi	r7F7F, r7F7F, 32, 0
 | 
				
			||||||
 | 
					-	add	rFEFE, rFEFE, rTMP
 | 
				
			||||||
 | 
					-	b	L(g1)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(g0):
 | 
				
			||||||
 | 
					-	ldu	rWORD1, 8(rSTR1)
 | 
				
			||||||
 | 
					-	bne-	cr1, L(different)
 | 
				
			||||||
 | 
					-	ldu	rWORD2, 8(rSTR2)
 | 
				
			||||||
 | 
					-L(g1):	add	rTMP, rFEFE, rWORD1
 | 
				
			||||||
 | 
					-	nor	rNEG, r7F7F, rWORD1
 | 
				
			||||||
 | 
					-	bdz	L(tail)
 | 
				
			||||||
 | 
					-	and.	rTMP, rTMP, rNEG
 | 
				
			||||||
 | 
					-	cmpd	cr1, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq+	L(g0)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* OK. We've hit the end of the string. We need to be careful that
 | 
				
			||||||
 | 
					-   we don't compare two strings as different because of gunk beyond
 | 
				
			||||||
 | 
					-   the end of the strings...  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#ifdef __LITTLE_ENDIAN__
 | 
				
			||||||
 | 
					-L(endstring):
 | 
				
			||||||
 | 
					-	addi    rTMP2, rTMP, -1
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	andc    rTMP2, rTMP2, rTMP
 | 
				
			||||||
 | 
					-	rldimi	rTMP2, rTMP2, 1, 0
 | 
				
			||||||
 | 
					-	and	rWORD2, rWORD2, rTMP2	/* Mask off gunk.  */
 | 
				
			||||||
 | 
					-	and	rWORD1, rWORD1, rTMP2
 | 
				
			||||||
 | 
					-	cmpd	cr1, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
 | 
				
			||||||
 | 
					-	neg	rNEG, rBITDIF
 | 
				
			||||||
 | 
					-	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
 | 
				
			||||||
 | 
					-	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
 | 
				
			||||||
 | 
					-	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
 | 
				
			||||||
 | 
					-	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
 | 
				
			||||||
 | 
					-	sld	rWORD2, rWORD2, rNEG
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63		/* must return an int.  */
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(equal):
 | 
				
			||||||
 | 
					-	li	rRTN, 0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(different):
 | 
				
			||||||
 | 
					-	ld	rWORD1, -8(rSTR1)
 | 
				
			||||||
 | 
					-	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
 | 
				
			||||||
 | 
					-	neg	rNEG, rBITDIF
 | 
				
			||||||
 | 
					-	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
 | 
				
			||||||
 | 
					-	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
 | 
				
			||||||
 | 
					-	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
 | 
				
			||||||
 | 
					-	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
 | 
				
			||||||
 | 
					-	sld	rWORD2, rWORD2, rNEG
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(highbit):
 | 
				
			||||||
 | 
					-	sradi	rRTN, rWORD2, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#else
 | 
				
			||||||
 | 
					-L(endstring):
 | 
				
			||||||
 | 
					-	and	rTMP, r7F7F, rWORD1
 | 
				
			||||||
 | 
					-	beq	cr1, L(equal)
 | 
				
			||||||
 | 
					-	add	rTMP, rTMP, r7F7F
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	andc	rNEG, rNEG, rTMP
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	cntlzd	rBITDIF, rBITDIF
 | 
				
			||||||
 | 
					-	cntlzd	rNEG, rNEG
 | 
				
			||||||
 | 
					-	addi	rNEG, rNEG, 7
 | 
				
			||||||
 | 
					-	cmpd	cr1, rNEG, rBITDIF
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	cr1, L(equal)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63		/* must return an int.  */
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(equal):
 | 
				
			||||||
 | 
					-	li	rRTN, 0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(different):
 | 
				
			||||||
 | 
					-	ld	rWORD1, -8(rSTR1)
 | 
				
			||||||
 | 
					-	xor.	rBITDIF, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blt-	L(highbit)
 | 
				
			||||||
 | 
					-	sradi	rRTN, rRTN, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-L(highbit):
 | 
				
			||||||
 | 
					-	sradi	rRTN, rWORD2, 63
 | 
				
			||||||
 | 
					-	ori	rRTN, rRTN, 1
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* Oh well.  In this case, we just do a byte-by-byte comparison.  */
 | 
				
			||||||
 | 
					-	.align 4
 | 
				
			||||||
 | 
					-L(tail):
 | 
				
			||||||
 | 
					-	and.	rTMP, rTMP, rNEG
 | 
				
			||||||
 | 
					-	cmpd	cr1, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	bne-	L(endstring)
 | 
				
			||||||
 | 
					-	addi	rSTR1, rSTR1, 8
 | 
				
			||||||
 | 
					-	bne-	cr1, L(different)
 | 
				
			||||||
 | 
					-	addi	rSTR2, rSTR2, 8
 | 
				
			||||||
 | 
					-	cmpldi	cr1, rN, 0
 | 
				
			||||||
 | 
					-L(unaligned):
 | 
				
			||||||
 | 
					-	mtctr   rN	/* Power4 wants mtctr 1st in dispatch group */
 | 
				
			||||||
 | 
					-	bgt	cr1, L(uz)
 | 
				
			||||||
 | 
					-L(ux):
 | 
				
			||||||
 | 
					-	li	rRTN, 0
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-	.align 4
 | 
				
			||||||
 | 
					-L(uz):
 | 
				
			||||||
 | 
					-	lbz	rWORD1, 0(rSTR1)
 | 
				
			||||||
 | 
					-	lbz	rWORD2, 0(rSTR2)
 | 
				
			||||||
 | 
					-	nop
 | 
				
			||||||
 | 
					-	b	L(u1)
 | 
				
			||||||
 | 
					-L(u0):
 | 
				
			||||||
 | 
					-	lbzu	rWORD2, 1(rSTR2)
 | 
				
			||||||
 | 
					-L(u1):
 | 
				
			||||||
 | 
					-	bdz	L(u3)
 | 
				
			||||||
 | 
					-	cmpdi	cr1, rWORD1, 0
 | 
				
			||||||
 | 
					-	cmpd	rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	beq-	cr1, L(u3)
 | 
				
			||||||
 | 
					-	lbzu	rWORD1, 1(rSTR1)
 | 
				
			||||||
 | 
					-	bne-	L(u2)
 | 
				
			||||||
 | 
					-	lbzu	rWORD2, 1(rSTR2)
 | 
				
			||||||
 | 
					-	bdz	L(u3)
 | 
				
			||||||
 | 
					-	cmpdi	cr1, rWORD1, 0
 | 
				
			||||||
 | 
					-	cmpd	rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	bne-	L(u3)
 | 
				
			||||||
 | 
					-	lbzu	rWORD1, 1(rSTR1)
 | 
				
			||||||
 | 
					-	bne+	cr1, L(u0)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-L(u2):	lbzu	rWORD1, -1(rSTR1)
 | 
				
			||||||
 | 
					-L(u3):	sub	rRTN, rWORD1, rWORD2
 | 
				
			||||||
 | 
					-	blr
 | 
				
			||||||
 | 
					-END (STRNCMP)
 | 
				
			||||||
 | 
					-libc_hidden_builtin_def (strncmp)
 | 
				
			||||||
							
								
								
									
										845
									
								
								SOURCES/glibc-RHEL-67806.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										845
									
								
								SOURCES/glibc-RHEL-67806.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,845 @@
 | 
				
			|||||||
 | 
					From e1d3312015e8f70344620375aedf91afe7e7e7a4 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: lijianglin <lijianglin2@huawei.com>
 | 
				
			||||||
 | 
					Date: Tue, 27 Jun 2023 20:15:49 +0800
 | 
				
			||||||
 | 
					Subject: add GB18030-2022 charmap and test the entire GB18030 charmap [BZ
 | 
				
			||||||
 | 
					 #30243]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					support GB18030-2022 after add and change some transcoding relationship
 | 
				
			||||||
 | 
					of GB18030-2022.Details are as follows:
 | 
				
			||||||
 | 
					add 25 transcoding relationship
 | 
				
			||||||
 | 
					  UE81E 0x82359037
 | 
				
			||||||
 | 
					  UE826 0x82359038
 | 
				
			||||||
 | 
					  UE82B 0x82359039
 | 
				
			||||||
 | 
					  UE82C 0x82359130
 | 
				
			||||||
 | 
					  UE832 0x82359131
 | 
				
			||||||
 | 
					  UE843 0x82359132
 | 
				
			||||||
 | 
					  UE854 0x82359133
 | 
				
			||||||
 | 
					  UE864 0x82359134
 | 
				
			||||||
 | 
					  UE78D 0x84318236
 | 
				
			||||||
 | 
					  UE78F 0x84318237
 | 
				
			||||||
 | 
					  UE78E 0x84318238
 | 
				
			||||||
 | 
					  UE790 0x84318239
 | 
				
			||||||
 | 
					  UE791 0x84318330
 | 
				
			||||||
 | 
					  UE792 0x84318331
 | 
				
			||||||
 | 
					  UE793 0x84318332
 | 
				
			||||||
 | 
					  UE794 0x84318333
 | 
				
			||||||
 | 
					  UE795 0x84318334
 | 
				
			||||||
 | 
					  UE796 0x84318335
 | 
				
			||||||
 | 
					  UE816 0xfe51
 | 
				
			||||||
 | 
					  UE817 0xfe52
 | 
				
			||||||
 | 
					  UE818 0xfe53
 | 
				
			||||||
 | 
					  UE831 0xfe6c
 | 
				
			||||||
 | 
					  UE83B 0xfe76
 | 
				
			||||||
 | 
					  UE855 0xfe91
 | 
				
			||||||
 | 
					change 6 transcoding relationship
 | 
				
			||||||
 | 
					  U20087 0x95329031
 | 
				
			||||||
 | 
					  U20089 0x95329033
 | 
				
			||||||
 | 
					  U200CC 0x95329730
 | 
				
			||||||
 | 
					  U215D7 0x9536b937
 | 
				
			||||||
 | 
					  U2298F 0x9630ba35
 | 
				
			||||||
 | 
					  U241FE 0x9635b630
 | 
				
			||||||
 | 
					Test the entire GB18030 charmap, not only the Unicode BMP part.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Co-authored-by: yangyanchao <yangyanchao6@huawei.com>
 | 
				
			||||||
 | 
					Co-authored-by: liqingqing <liqingqing3@huawei.com>
 | 
				
			||||||
 | 
					Co-authored-by: Bruno Haible <bruno@clisp.org>
 | 
				
			||||||
 | 
					Reviewed-by: Andreas Schwab <schwab@suse.de>
 | 
				
			||||||
 | 
					Reviewed-by: Mike FABIAN <mfabian@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/iconvdata/gb18030.c b/iconvdata/gb18030.c
 | 
				
			||||||
 | 
					index 9996a59eaf..be6cfe652c 100644
 | 
				
			||||||
 | 
					--- a/iconvdata/gb18030.c
 | 
				
			||||||
 | 
					+++ b/iconvdata/gb18030.c
 | 
				
			||||||
 | 
					@@ -6009,49 +6009,50 @@ static const uint16_t __twobyte_to_ucs[] =
 | 
				
			||||||
 | 
					   [0x5dc2] = 0xfa0e, [0x5dc3] = 0xfa0f, [0x5dc4] = 0xfa11, [0x5dc5] = 0xfa13,
 | 
				
			||||||
 | 
					   [0x5dc6] = 0xfa14, [0x5dc7] = 0xfa18, [0x5dc8] = 0xfa1f, [0x5dc9] = 0xfa20,
 | 
				
			||||||
 | 
					   [0x5dca] = 0xfa21, [0x5dcb] = 0xfa23, [0x5dcc] = 0xfa24, [0x5dcd] = 0xfa27,
 | 
				
			||||||
 | 
					-  [0x5dce] = 0xfa28, [0x5dcf] = 0xfa29, [0x5dd0] = 0x2e81, [0x5dd4] = 0x2e84,
 | 
				
			||||||
 | 
					-  [0x5dd5] = 0x3473, [0x5dd6] = 0x3447, [0x5dd7] = 0x2e88, [0x5dd8] = 0x2e8b,
 | 
				
			||||||
 | 
					-  [0x5dd9] = 0x9fb4, [0x5dda] = 0x359e, [0x5ddb] = 0x361a, [0x5ddc] = 0x360e,
 | 
				
			||||||
 | 
					-  [0x5ddd] = 0x2e8c, [0x5dde] = 0x2e97, [0x5ddf] = 0x396e, [0x5de0] = 0x3918,
 | 
				
			||||||
 | 
					-  [0x5de1] = 0x9fb5, [0x5de2] = 0x39cf, [0x5de3] = 0x39df, [0x5de4] = 0x3a73,
 | 
				
			||||||
 | 
					-  [0x5de5] = 0x39d0, [0x5de6] = 0x9fb6, [0x5de7] = 0x9fb7, [0x5de8] = 0x3b4e,
 | 
				
			||||||
 | 
					-  [0x5de9] = 0x3c6e, [0x5dea] = 0x3ce0, [0x5deb] = 0x2ea7, [0x5ded] = 0x9fb8,
 | 
				
			||||||
 | 
					+  [0x5dce] = 0xfa28, [0x5dcf] = 0xfa29, [0x5dd0] = 0x2e81, [0x5dd1] = 0xe816,
 | 
				
			||||||
 | 
					+  [0x5dd2] = 0xe817, [0x5dd3] = 0xe818, [0x5dd4] = 0x2e84, [0x5dd5] = 0x3473,
 | 
				
			||||||
 | 
					+  [0x5dd6] = 0x3447, [0x5dd7] = 0x2e88, [0x5dd8] = 0x2e8b, [0x5dd9] = 0x9fb4,
 | 
				
			||||||
 | 
					+  [0x5dda] = 0x359e, [0x5ddb] = 0x361a, [0x5ddc] = 0x360e, [0x5ddd] = 0x2e8c,
 | 
				
			||||||
 | 
					+  [0x5dde] = 0x2e97, [0x5ddf] = 0x396e, [0x5de0] = 0x3918, [0x5de1] = 0x9fb5,
 | 
				
			||||||
 | 
					+  [0x5de2] = 0x39cf, [0x5de3] = 0x39df, [0x5de4] = 0x3a73, [0x5de5] = 0x39d0,
 | 
				
			||||||
 | 
					+  [0x5de6] = 0x9fb6, [0x5de7] = 0x9fb7, [0x5de8] = 0x3b4e, [0x5de9] = 0x3c6e,
 | 
				
			||||||
 | 
					+  [0x5dea] = 0x3ce0, [0x5deb] = 0x2ea7, [0x5dec] = 0xe831, [0x5ded] = 0x9fb8,
 | 
				
			||||||
 | 
					   [0x5dee] = 0x2eaa, [0x5def] = 0x4056, [0x5df0] = 0x415f, [0x5df1] = 0x2eae,
 | 
				
			||||||
 | 
					   [0x5df2] = 0x4337, [0x5df3] = 0x2eb3, [0x5df4] = 0x2eb6, [0x5df5] = 0x2eb7,
 | 
				
			||||||
 | 
					-  [0x5df7] = 0x43b1, [0x5df8] = 0x43ac, [0x5df9] = 0x2ebb, [0x5dfa] = 0x43dd,
 | 
				
			||||||
 | 
					-  [0x5dfb] = 0x44d6, [0x5dfc] = 0x4661, [0x5dfd] = 0x464c, [0x5dfe] = 0x9fb9,
 | 
				
			||||||
 | 
					-  [0x5e00] = 0x4723, [0x5e01] = 0x4729, [0x5e02] = 0x477c, [0x5e03] = 0x478d,
 | 
				
			||||||
 | 
					-  [0x5e04] = 0x2eca, [0x5e05] = 0x4947, [0x5e06] = 0x497a, [0x5e07] = 0x497d,
 | 
				
			||||||
 | 
					-  [0x5e08] = 0x4982, [0x5e09] = 0x4983, [0x5e0a] = 0x4985, [0x5e0b] = 0x4986,
 | 
				
			||||||
 | 
					-  [0x5e0c] = 0x499f, [0x5e0d] = 0x499b, [0x5e0e] = 0x49b7, [0x5e0f] = 0x49b6,
 | 
				
			||||||
 | 
					-  [0x5e10] = 0x9fba, [0x5e12] = 0x4ca3, [0x5e13] = 0x4c9f, [0x5e14] = 0x4ca0,
 | 
				
			||||||
 | 
					-  [0x5e15] = 0x4ca1, [0x5e16] = 0x4c77, [0x5e17] = 0x4ca2, [0x5e18] = 0x4d13,
 | 
				
			||||||
 | 
					-  [0x5e19] = 0x4d14, [0x5e1a] = 0x4d15, [0x5e1b] = 0x4d16, [0x5e1c] = 0x4d17,
 | 
				
			||||||
 | 
					-  [0x5e1d] = 0x4d18, [0x5e1e] = 0x4d19, [0x5e1f] = 0x4dae, [0x5e20] = 0x9fbb,
 | 
				
			||||||
 | 
					-  [0x5e21] = 0xe468, [0x5e22] = 0xe469, [0x5e23] = 0xe46a, [0x5e24] = 0xe46b,
 | 
				
			||||||
 | 
					-  [0x5e25] = 0xe46c, [0x5e26] = 0xe46d, [0x5e27] = 0xe46e, [0x5e28] = 0xe46f,
 | 
				
			||||||
 | 
					-  [0x5e29] = 0xe470, [0x5e2a] = 0xe471, [0x5e2b] = 0xe472, [0x5e2c] = 0xe473,
 | 
				
			||||||
 | 
					-  [0x5e2d] = 0xe474, [0x5e2e] = 0xe475, [0x5e2f] = 0xe476, [0x5e30] = 0xe477,
 | 
				
			||||||
 | 
					-  [0x5e31] = 0xe478, [0x5e32] = 0xe479, [0x5e33] = 0xe47a, [0x5e34] = 0xe47b,
 | 
				
			||||||
 | 
					-  [0x5e35] = 0xe47c, [0x5e36] = 0xe47d, [0x5e37] = 0xe47e, [0x5e38] = 0xe47f,
 | 
				
			||||||
 | 
					-  [0x5e39] = 0xe480, [0x5e3a] = 0xe481, [0x5e3b] = 0xe482, [0x5e3c] = 0xe483,
 | 
				
			||||||
 | 
					-  [0x5e3d] = 0xe484, [0x5e3e] = 0xe485, [0x5e3f] = 0xe486, [0x5e40] = 0xe487,
 | 
				
			||||||
 | 
					-  [0x5e41] = 0xe488, [0x5e42] = 0xe489, [0x5e43] = 0xe48a, [0x5e44] = 0xe48b,
 | 
				
			||||||
 | 
					-  [0x5e45] = 0xe48c, [0x5e46] = 0xe48d, [0x5e47] = 0xe48e, [0x5e48] = 0xe48f,
 | 
				
			||||||
 | 
					-  [0x5e49] = 0xe490, [0x5e4a] = 0xe491, [0x5e4b] = 0xe492, [0x5e4c] = 0xe493,
 | 
				
			||||||
 | 
					-  [0x5e4d] = 0xe494, [0x5e4e] = 0xe495, [0x5e4f] = 0xe496, [0x5e50] = 0xe497,
 | 
				
			||||||
 | 
					-  [0x5e51] = 0xe498, [0x5e52] = 0xe499, [0x5e53] = 0xe49a, [0x5e54] = 0xe49b,
 | 
				
			||||||
 | 
					-  [0x5e55] = 0xe49c, [0x5e56] = 0xe49d, [0x5e57] = 0xe49e, [0x5e58] = 0xe49f,
 | 
				
			||||||
 | 
					-  [0x5e59] = 0xe4a0, [0x5e5a] = 0xe4a1, [0x5e5b] = 0xe4a2, [0x5e5c] = 0xe4a3,
 | 
				
			||||||
 | 
					-  [0x5e5d] = 0xe4a4, [0x5e5e] = 0xe4a5, [0x5e5f] = 0xe4a6, [0x5e60] = 0xe4a7,
 | 
				
			||||||
 | 
					-  [0x5e61] = 0xe4a8, [0x5e62] = 0xe4a9, [0x5e63] = 0xe4aa, [0x5e64] = 0xe4ab,
 | 
				
			||||||
 | 
					-  [0x5e65] = 0xe4ac, [0x5e66] = 0xe4ad, [0x5e67] = 0xe4ae, [0x5e68] = 0xe4af,
 | 
				
			||||||
 | 
					-  [0x5e69] = 0xe4b0, [0x5e6a] = 0xe4b1, [0x5e6b] = 0xe4b2, [0x5e6c] = 0xe4b3,
 | 
				
			||||||
 | 
					-  [0x5e6d] = 0xe4b4, [0x5e6e] = 0xe4b5, [0x5e6f] = 0xe4b6, [0x5e70] = 0xe4b7,
 | 
				
			||||||
 | 
					-  [0x5e71] = 0xe4b8, [0x5e72] = 0xe4b9, [0x5e73] = 0xe4ba, [0x5e74] = 0xe4bb,
 | 
				
			||||||
 | 
					-  [0x5e75] = 0xe4bc, [0x5e76] = 0xe4bd, [0x5e77] = 0xe4be, [0x5e78] = 0xe4bf,
 | 
				
			||||||
 | 
					-  [0x5e79] = 0xe4c0, [0x5e7a] = 0xe4c1, [0x5e7b] = 0xe4c2, [0x5e7c] = 0xe4c3,
 | 
				
			||||||
 | 
					-  [0x5e7d] = 0xe4c4, [0x5e7e] = 0xe4c5,
 | 
				
			||||||
 | 
					+  [0x5df6] = 0xe83b, [0x5df7] = 0x43b1, [0x5df8] = 0x43ac, [0x5df9] = 0x2ebb,
 | 
				
			||||||
 | 
					+  [0x5dfa] = 0x43dd, [0x5dfb] = 0x44d6, [0x5dfc] = 0x4661, [0x5dfd] = 0x464c,
 | 
				
			||||||
 | 
					+  [0x5dfe] = 0x9fb9, [0x5e00] = 0x4723, [0x5e01] = 0x4729, [0x5e02] = 0x477c,
 | 
				
			||||||
 | 
					+  [0x5e03] = 0x478d, [0x5e04] = 0x2eca, [0x5e05] = 0x4947, [0x5e06] = 0x497a,
 | 
				
			||||||
 | 
					+  [0x5e07] = 0x497d, [0x5e08] = 0x4982, [0x5e09] = 0x4983, [0x5e0a] = 0x4985,
 | 
				
			||||||
 | 
					+  [0x5e0b] = 0x4986, [0x5e0c] = 0x499f, [0x5e0d] = 0x499b, [0x5e0e] = 0x49b7,
 | 
				
			||||||
 | 
					+  [0x5e0f] = 0x49b6, [0x5e10] = 0x9fba, [0x5e11] = 0xe855, [0x5e12] = 0x4ca3,
 | 
				
			||||||
 | 
					+  [0x5e13] = 0x4c9f, [0x5e14] = 0x4ca0, [0x5e15] = 0x4ca1, [0x5e16] = 0x4c77,
 | 
				
			||||||
 | 
					+  [0x5e17] = 0x4ca2, [0x5e18] = 0x4d13, [0x5e19] = 0x4d14, [0x5e1a] = 0x4d15,
 | 
				
			||||||
 | 
					+  [0x5e1b] = 0x4d16, [0x5e1c] = 0x4d17, [0x5e1d] = 0x4d18, [0x5e1e] = 0x4d19,
 | 
				
			||||||
 | 
					+  [0x5e1f] = 0x4dae, [0x5e20] = 0x9fbb, [0x5e21] = 0xe468, [0x5e22] = 0xe469,
 | 
				
			||||||
 | 
					+  [0x5e23] = 0xe46a, [0x5e24] = 0xe46b, [0x5e25] = 0xe46c, [0x5e26] = 0xe46d,
 | 
				
			||||||
 | 
					+  [0x5e27] = 0xe46e, [0x5e28] = 0xe46f, [0x5e29] = 0xe470, [0x5e2a] = 0xe471,
 | 
				
			||||||
 | 
					+  [0x5e2b] = 0xe472, [0x5e2c] = 0xe473, [0x5e2d] = 0xe474, [0x5e2e] = 0xe475,
 | 
				
			||||||
 | 
					+  [0x5e2f] = 0xe476, [0x5e30] = 0xe477, [0x5e31] = 0xe478, [0x5e32] = 0xe479,
 | 
				
			||||||
 | 
					+  [0x5e33] = 0xe47a, [0x5e34] = 0xe47b, [0x5e35] = 0xe47c, [0x5e36] = 0xe47d,
 | 
				
			||||||
 | 
					+  [0x5e37] = 0xe47e, [0x5e38] = 0xe47f, [0x5e39] = 0xe480, [0x5e3a] = 0xe481,
 | 
				
			||||||
 | 
					+  [0x5e3b] = 0xe482, [0x5e3c] = 0xe483, [0x5e3d] = 0xe484, [0x5e3e] = 0xe485,
 | 
				
			||||||
 | 
					+  [0x5e3f] = 0xe486, [0x5e40] = 0xe487, [0x5e41] = 0xe488, [0x5e42] = 0xe489,
 | 
				
			||||||
 | 
					+  [0x5e43] = 0xe48a, [0x5e44] = 0xe48b, [0x5e45] = 0xe48c, [0x5e46] = 0xe48d,
 | 
				
			||||||
 | 
					+  [0x5e47] = 0xe48e, [0x5e48] = 0xe48f, [0x5e49] = 0xe490, [0x5e4a] = 0xe491,
 | 
				
			||||||
 | 
					+  [0x5e4b] = 0xe492, [0x5e4c] = 0xe493, [0x5e4d] = 0xe494, [0x5e4e] = 0xe495,
 | 
				
			||||||
 | 
					+  [0x5e4f] = 0xe496, [0x5e50] = 0xe497, [0x5e51] = 0xe498, [0x5e52] = 0xe499,
 | 
				
			||||||
 | 
					+  [0x5e53] = 0xe49a, [0x5e54] = 0xe49b, [0x5e55] = 0xe49c, [0x5e56] = 0xe49d,
 | 
				
			||||||
 | 
					+  [0x5e57] = 0xe49e, [0x5e58] = 0xe49f, [0x5e59] = 0xe4a0, [0x5e5a] = 0xe4a1,
 | 
				
			||||||
 | 
					+  [0x5e5b] = 0xe4a2, [0x5e5c] = 0xe4a3, [0x5e5d] = 0xe4a4, [0x5e5e] = 0xe4a5,
 | 
				
			||||||
 | 
					+  [0x5e5f] = 0xe4a6, [0x5e60] = 0xe4a7, [0x5e61] = 0xe4a8, [0x5e62] = 0xe4a9,
 | 
				
			||||||
 | 
					+  [0x5e63] = 0xe4aa, [0x5e64] = 0xe4ab, [0x5e65] = 0xe4ac, [0x5e66] = 0xe4ad,
 | 
				
			||||||
 | 
					+  [0x5e67] = 0xe4ae, [0x5e68] = 0xe4af, [0x5e69] = 0xe4b0, [0x5e6a] = 0xe4b1,
 | 
				
			||||||
 | 
					+  [0x5e6b] = 0xe4b2, [0x5e6c] = 0xe4b3, [0x5e6d] = 0xe4b4, [0x5e6e] = 0xe4b5,
 | 
				
			||||||
 | 
					+  [0x5e6f] = 0xe4b6, [0x5e70] = 0xe4b7, [0x5e71] = 0xe4b8, [0x5e72] = 0xe4b9,
 | 
				
			||||||
 | 
					+  [0x5e73] = 0xe4ba, [0x5e74] = 0xe4bb, [0x5e75] = 0xe4bc, [0x5e76] = 0xe4bd,
 | 
				
			||||||
 | 
					+  [0x5e77] = 0xe4be, [0x5e78] = 0xe4bf, [0x5e79] = 0xe4c0, [0x5e7a] = 0xe4c1,
 | 
				
			||||||
 | 
					+  [0x5e7b] = 0xe4c2, [0x5e7c] = 0xe4c3, [0x5e7d] = 0xe4c4, [0x5e7e] = 0xe4c5,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Table for GB18030 -> UCS-4, containing the four-byte characters only,
 | 
				
			||||||
 | 
					@@ -8680,7 +8681,9 @@ static const uint16_t __fourbyte_to_ucs[0x99e2 - 6637 - 2110 - 14404 - 4295] =
 | 
				
			||||||
 | 
					   [0x2838] = 0x9fa6, [0x2839] = 0x9fa7, [0x283a] = 0x9fa8, [0x283b] = 0x9fa9,
 | 
				
			||||||
 | 
					   [0x283c] = 0x9faa, [0x283d] = 0x9fab, [0x283e] = 0x9fac, [0x283f] = 0x9fad,
 | 
				
			||||||
 | 
					   [0x2840] = 0x9fae, [0x2841] = 0x9faf, [0x2842] = 0x9fb0, [0x2843] = 0x9fb1,
 | 
				
			||||||
 | 
					-  [0x2844] = 0x9fb2, [0x2845] = 0x9fb3, [0x284e] = 0xe76c, [0x284f] = 0xe7c8,
 | 
				
			||||||
 | 
					+  [0x2844] = 0x9fb2, [0x2845] = 0x9fb3, [0x2846] = 0xe81e, [0x2847] = 0xe826,
 | 
				
			||||||
 | 
					+  [0x2848] = 0xe82b, [0x2849] = 0xe82c, [0x284a] = 0xe832, [0x284b] = 0xe843,
 | 
				
			||||||
 | 
					+  [0x284c] = 0xe854, [0x284d] = 0xe864, [0x284e] = 0xe76c, [0x284f] = 0xe7c8,
 | 
				
			||||||
 | 
					   [0x2850] = 0xe7e7, [0x2851] = 0xe7e8, [0x2852] = 0xe7e9, [0x2853] = 0xe7ea,
 | 
				
			||||||
 | 
					   [0x2854] = 0xe7eb, [0x2855] = 0xe7ec, [0x2856] = 0xe7ed, [0x2857] = 0xe7ee,
 | 
				
			||||||
 | 
					   [0x2858] = 0xe7ef, [0x2859] = 0xe7f0, [0x285a] = 0xe7f1, [0x285b] = 0xe7f2,
 | 
				
			||||||
 | 
					@@ -9008,84 +9011,86 @@ static const uint16_t __fourbyte_to_ucs[0x99e2 - 6637 - 2110 - 14404 - 4295] =
 | 
				
			||||||
 | 
					   [0x2d60] = 0xfe02, [0x2d61] = 0xfe03, [0x2d62] = 0xfe04, [0x2d63] = 0xfe05,
 | 
				
			||||||
 | 
					   [0x2d64] = 0xfe06, [0x2d65] = 0xfe07, [0x2d66] = 0xfe08, [0x2d67] = 0xfe09,
 | 
				
			||||||
 | 
					   [0x2d68] = 0xfe0a, [0x2d69] = 0xfe0b, [0x2d6a] = 0xfe0c, [0x2d6b] = 0xfe0d,
 | 
				
			||||||
 | 
					-  [0x2d6c] = 0xfe0e, [0x2d6d] = 0xfe0f, [0x2d78] = 0xfe1a, [0x2d79] = 0xfe1b,
 | 
				
			||||||
 | 
					-  [0x2d7a] = 0xfe1c, [0x2d7b] = 0xfe1d, [0x2d7c] = 0xfe1e, [0x2d7d] = 0xfe1f,
 | 
				
			||||||
 | 
					-  [0x2d7e] = 0xfe20, [0x2d7f] = 0xfe21, [0x2d80] = 0xfe22, [0x2d81] = 0xfe23,
 | 
				
			||||||
 | 
					-  [0x2d82] = 0xfe24, [0x2d83] = 0xfe25, [0x2d84] = 0xfe26, [0x2d85] = 0xfe27,
 | 
				
			||||||
 | 
					-  [0x2d86] = 0xfe28, [0x2d87] = 0xfe29, [0x2d88] = 0xfe2a, [0x2d89] = 0xfe2b,
 | 
				
			||||||
 | 
					-  [0x2d8a] = 0xfe2c, [0x2d8b] = 0xfe2d, [0x2d8c] = 0xfe2e, [0x2d8d] = 0xfe2f,
 | 
				
			||||||
 | 
					-  [0x2d8e] = 0xfe32, [0x2d8f] = 0xfe45, [0x2d90] = 0xfe46, [0x2d91] = 0xfe47,
 | 
				
			||||||
 | 
					-  [0x2d92] = 0xfe48, [0x2d93] = 0xfe53, [0x2d94] = 0xfe58, [0x2d95] = 0xfe67,
 | 
				
			||||||
 | 
					-  [0x2d96] = 0xfe6c, [0x2d97] = 0xfe6d, [0x2d98] = 0xfe6e, [0x2d99] = 0xfe6f,
 | 
				
			||||||
 | 
					-  [0x2d9a] = 0xfe70, [0x2d9b] = 0xfe71, [0x2d9c] = 0xfe72, [0x2d9d] = 0xfe73,
 | 
				
			||||||
 | 
					-  [0x2d9e] = 0xfe74, [0x2d9f] = 0xfe75, [0x2da0] = 0xfe76, [0x2da1] = 0xfe77,
 | 
				
			||||||
 | 
					-  [0x2da2] = 0xfe78, [0x2da3] = 0xfe79, [0x2da4] = 0xfe7a, [0x2da5] = 0xfe7b,
 | 
				
			||||||
 | 
					-  [0x2da6] = 0xfe7c, [0x2da7] = 0xfe7d, [0x2da8] = 0xfe7e, [0x2da9] = 0xfe7f,
 | 
				
			||||||
 | 
					-  [0x2daa] = 0xfe80, [0x2dab] = 0xfe81, [0x2dac] = 0xfe82, [0x2dad] = 0xfe83,
 | 
				
			||||||
 | 
					-  [0x2dae] = 0xfe84, [0x2daf] = 0xfe85, [0x2db0] = 0xfe86, [0x2db1] = 0xfe87,
 | 
				
			||||||
 | 
					-  [0x2db2] = 0xfe88, [0x2db3] = 0xfe89, [0x2db4] = 0xfe8a, [0x2db5] = 0xfe8b,
 | 
				
			||||||
 | 
					-  [0x2db6] = 0xfe8c, [0x2db7] = 0xfe8d, [0x2db8] = 0xfe8e, [0x2db9] = 0xfe8f,
 | 
				
			||||||
 | 
					-  [0x2dba] = 0xfe90, [0x2dbb] = 0xfe91, [0x2dbc] = 0xfe92, [0x2dbd] = 0xfe93,
 | 
				
			||||||
 | 
					-  [0x2dbe] = 0xfe94, [0x2dbf] = 0xfe95, [0x2dc0] = 0xfe96, [0x2dc1] = 0xfe97,
 | 
				
			||||||
 | 
					-  [0x2dc2] = 0xfe98, [0x2dc3] = 0xfe99, [0x2dc4] = 0xfe9a, [0x2dc5] = 0xfe9b,
 | 
				
			||||||
 | 
					-  [0x2dc6] = 0xfe9c, [0x2dc7] = 0xfe9d, [0x2dc8] = 0xfe9e, [0x2dc9] = 0xfe9f,
 | 
				
			||||||
 | 
					-  [0x2dca] = 0xfea0, [0x2dcb] = 0xfea1, [0x2dcc] = 0xfea2, [0x2dcd] = 0xfea3,
 | 
				
			||||||
 | 
					-  [0x2dce] = 0xfea4, [0x2dcf] = 0xfea5, [0x2dd0] = 0xfea6, [0x2dd1] = 0xfea7,
 | 
				
			||||||
 | 
					-  [0x2dd2] = 0xfea8, [0x2dd3] = 0xfea9, [0x2dd4] = 0xfeaa, [0x2dd5] = 0xfeab,
 | 
				
			||||||
 | 
					-  [0x2dd6] = 0xfeac, [0x2dd7] = 0xfead, [0x2dd8] = 0xfeae, [0x2dd9] = 0xfeaf,
 | 
				
			||||||
 | 
					-  [0x2dda] = 0xfeb0, [0x2ddb] = 0xfeb1, [0x2ddc] = 0xfeb2, [0x2ddd] = 0xfeb3,
 | 
				
			||||||
 | 
					-  [0x2dde] = 0xfeb4, [0x2ddf] = 0xfeb5, [0x2de0] = 0xfeb6, [0x2de1] = 0xfeb7,
 | 
				
			||||||
 | 
					-  [0x2de2] = 0xfeb8, [0x2de3] = 0xfeb9, [0x2de4] = 0xfeba, [0x2de5] = 0xfebb,
 | 
				
			||||||
 | 
					-  [0x2de6] = 0xfebc, [0x2de7] = 0xfebd, [0x2de8] = 0xfebe, [0x2de9] = 0xfebf,
 | 
				
			||||||
 | 
					-  [0x2dea] = 0xfec0, [0x2deb] = 0xfec1, [0x2dec] = 0xfec2, [0x2ded] = 0xfec3,
 | 
				
			||||||
 | 
					-  [0x2dee] = 0xfec4, [0x2def] = 0xfec5, [0x2df0] = 0xfec6, [0x2df1] = 0xfec7,
 | 
				
			||||||
 | 
					-  [0x2df2] = 0xfec8, [0x2df3] = 0xfec9, [0x2df4] = 0xfeca, [0x2df5] = 0xfecb,
 | 
				
			||||||
 | 
					-  [0x2df6] = 0xfecc, [0x2df7] = 0xfecd, [0x2df8] = 0xfece, [0x2df9] = 0xfecf,
 | 
				
			||||||
 | 
					-  [0x2dfa] = 0xfed0, [0x2dfb] = 0xfed1, [0x2dfc] = 0xfed2, [0x2dfd] = 0xfed3,
 | 
				
			||||||
 | 
					-  [0x2dfe] = 0xfed4, [0x2dff] = 0xfed5, [0x2e00] = 0xfed6, [0x2e01] = 0xfed7,
 | 
				
			||||||
 | 
					-  [0x2e02] = 0xfed8, [0x2e03] = 0xfed9, [0x2e04] = 0xfeda, [0x2e05] = 0xfedb,
 | 
				
			||||||
 | 
					-  [0x2e06] = 0xfedc, [0x2e07] = 0xfedd, [0x2e08] = 0xfede, [0x2e09] = 0xfedf,
 | 
				
			||||||
 | 
					-  [0x2e0a] = 0xfee0, [0x2e0b] = 0xfee1, [0x2e0c] = 0xfee2, [0x2e0d] = 0xfee3,
 | 
				
			||||||
 | 
					-  [0x2e0e] = 0xfee4, [0x2e0f] = 0xfee5, [0x2e10] = 0xfee6, [0x2e11] = 0xfee7,
 | 
				
			||||||
 | 
					-  [0x2e12] = 0xfee8, [0x2e13] = 0xfee9, [0x2e14] = 0xfeea, [0x2e15] = 0xfeeb,
 | 
				
			||||||
 | 
					-  [0x2e16] = 0xfeec, [0x2e17] = 0xfeed, [0x2e18] = 0xfeee, [0x2e19] = 0xfeef,
 | 
				
			||||||
 | 
					-  [0x2e1a] = 0xfef0, [0x2e1b] = 0xfef1, [0x2e1c] = 0xfef2, [0x2e1d] = 0xfef3,
 | 
				
			||||||
 | 
					-  [0x2e1e] = 0xfef4, [0x2e1f] = 0xfef5, [0x2e20] = 0xfef6, [0x2e21] = 0xfef7,
 | 
				
			||||||
 | 
					-  [0x2e22] = 0xfef8, [0x2e23] = 0xfef9, [0x2e24] = 0xfefa, [0x2e25] = 0xfefb,
 | 
				
			||||||
 | 
					-  [0x2e26] = 0xfefc, [0x2e27] = 0xfefd, [0x2e28] = 0xfefe, [0x2e29] = 0xfeff,
 | 
				
			||||||
 | 
					-  [0x2e2a] = 0xff00, [0x2e2b] = 0xff5f, [0x2e2c] = 0xff60, [0x2e2d] = 0xff61,
 | 
				
			||||||
 | 
					-  [0x2e2e] = 0xff62, [0x2e2f] = 0xff63, [0x2e30] = 0xff64, [0x2e31] = 0xff65,
 | 
				
			||||||
 | 
					-  [0x2e32] = 0xff66, [0x2e33] = 0xff67, [0x2e34] = 0xff68, [0x2e35] = 0xff69,
 | 
				
			||||||
 | 
					-  [0x2e36] = 0xff6a, [0x2e37] = 0xff6b, [0x2e38] = 0xff6c, [0x2e39] = 0xff6d,
 | 
				
			||||||
 | 
					-  [0x2e3a] = 0xff6e, [0x2e3b] = 0xff6f, [0x2e3c] = 0xff70, [0x2e3d] = 0xff71,
 | 
				
			||||||
 | 
					-  [0x2e3e] = 0xff72, [0x2e3f] = 0xff73, [0x2e40] = 0xff74, [0x2e41] = 0xff75,
 | 
				
			||||||
 | 
					-  [0x2e42] = 0xff76, [0x2e43] = 0xff77, [0x2e44] = 0xff78, [0x2e45] = 0xff79,
 | 
				
			||||||
 | 
					-  [0x2e46] = 0xff7a, [0x2e47] = 0xff7b, [0x2e48] = 0xff7c, [0x2e49] = 0xff7d,
 | 
				
			||||||
 | 
					-  [0x2e4a] = 0xff7e, [0x2e4b] = 0xff7f, [0x2e4c] = 0xff80, [0x2e4d] = 0xff81,
 | 
				
			||||||
 | 
					-  [0x2e4e] = 0xff82, [0x2e4f] = 0xff83, [0x2e50] = 0xff84, [0x2e51] = 0xff85,
 | 
				
			||||||
 | 
					-  [0x2e52] = 0xff86, [0x2e53] = 0xff87, [0x2e54] = 0xff88, [0x2e55] = 0xff89,
 | 
				
			||||||
 | 
					-  [0x2e56] = 0xff8a, [0x2e57] = 0xff8b, [0x2e58] = 0xff8c, [0x2e59] = 0xff8d,
 | 
				
			||||||
 | 
					-  [0x2e5a] = 0xff8e, [0x2e5b] = 0xff8f, [0x2e5c] = 0xff90, [0x2e5d] = 0xff91,
 | 
				
			||||||
 | 
					-  [0x2e5e] = 0xff92, [0x2e5f] = 0xff93, [0x2e60] = 0xff94, [0x2e61] = 0xff95,
 | 
				
			||||||
 | 
					-  [0x2e62] = 0xff96, [0x2e63] = 0xff97, [0x2e64] = 0xff98, [0x2e65] = 0xff99,
 | 
				
			||||||
 | 
					-  [0x2e66] = 0xff9a, [0x2e67] = 0xff9b, [0x2e68] = 0xff9c, [0x2e69] = 0xff9d,
 | 
				
			||||||
 | 
					-  [0x2e6a] = 0xff9e, [0x2e6b] = 0xff9f, [0x2e6c] = 0xffa0, [0x2e6d] = 0xffa1,
 | 
				
			||||||
 | 
					-  [0x2e6e] = 0xffa2, [0x2e6f] = 0xffa3, [0x2e70] = 0xffa4, [0x2e71] = 0xffa5,
 | 
				
			||||||
 | 
					-  [0x2e72] = 0xffa6, [0x2e73] = 0xffa7, [0x2e74] = 0xffa8, [0x2e75] = 0xffa9,
 | 
				
			||||||
 | 
					-  [0x2e76] = 0xffaa, [0x2e77] = 0xffab, [0x2e78] = 0xffac, [0x2e79] = 0xffad,
 | 
				
			||||||
 | 
					-  [0x2e7a] = 0xffae, [0x2e7b] = 0xffaf, [0x2e7c] = 0xffb0, [0x2e7d] = 0xffb1,
 | 
				
			||||||
 | 
					-  [0x2e7e] = 0xffb2, [0x2e7f] = 0xffb3, [0x2e80] = 0xffb4, [0x2e81] = 0xffb5,
 | 
				
			||||||
 | 
					-  [0x2e82] = 0xffb6, [0x2e83] = 0xffb7, [0x2e84] = 0xffb8, [0x2e85] = 0xffb9,
 | 
				
			||||||
 | 
					-  [0x2e86] = 0xffba, [0x2e87] = 0xffbb, [0x2e88] = 0xffbc, [0x2e89] = 0xffbd,
 | 
				
			||||||
 | 
					-  [0x2e8a] = 0xffbe, [0x2e8b] = 0xffbf, [0x2e8c] = 0xffc0, [0x2e8d] = 0xffc1,
 | 
				
			||||||
 | 
					-  [0x2e8e] = 0xffc2, [0x2e8f] = 0xffc3, [0x2e90] = 0xffc4, [0x2e91] = 0xffc5,
 | 
				
			||||||
 | 
					-  [0x2e92] = 0xffc6, [0x2e93] = 0xffc7, [0x2e94] = 0xffc8, [0x2e95] = 0xffc9,
 | 
				
			||||||
 | 
					-  [0x2e96] = 0xffca, [0x2e97] = 0xffcb, [0x2e98] = 0xffcc, [0x2e99] = 0xffcd,
 | 
				
			||||||
 | 
					-  [0x2e9a] = 0xffce, [0x2e9b] = 0xffcf, [0x2e9c] = 0xffd0, [0x2e9d] = 0xffd1,
 | 
				
			||||||
 | 
					-  [0x2e9e] = 0xffd2, [0x2e9f] = 0xffd3, [0x2ea0] = 0xffd4, [0x2ea1] = 0xffd5,
 | 
				
			||||||
 | 
					-  [0x2ea2] = 0xffd6, [0x2ea3] = 0xffd7, [0x2ea4] = 0xffd8, [0x2ea5] = 0xffd9,
 | 
				
			||||||
 | 
					-  [0x2ea6] = 0xffda, [0x2ea7] = 0xffdb, [0x2ea8] = 0xffdc, [0x2ea9] = 0xffdd,
 | 
				
			||||||
 | 
					-  [0x2eaa] = 0xffde, [0x2eab] = 0xffdf,
 | 
				
			||||||
 | 
					+  [0x2d6c] = 0xfe0e, [0x2d6d] = 0xfe0f, [0x2d6e] = 0xe78d, [0x2d6f] = 0xe78f,
 | 
				
			||||||
 | 
					+  [0x2d70] = 0xe78e, [0x2d71] = 0xe790, [0x2d72] = 0xe791, [0x2d73] = 0xe792,
 | 
				
			||||||
 | 
					+  [0x2d74] = 0xe793, [0x2d75] = 0xe794, [0x2d76] = 0xe795, [0x2d77] = 0xe796,
 | 
				
			||||||
 | 
					+  [0x2d78] = 0xfe1a, [0x2d79] = 0xfe1b, [0x2d7a] = 0xfe1c, [0x2d7b] = 0xfe1d,
 | 
				
			||||||
 | 
					+  [0x2d7c] = 0xfe1e, [0x2d7d] = 0xfe1f, [0x2d7e] = 0xfe20, [0x2d7f] = 0xfe21,
 | 
				
			||||||
 | 
					+  [0x2d80] = 0xfe22, [0x2d81] = 0xfe23, [0x2d82] = 0xfe24, [0x2d83] = 0xfe25,
 | 
				
			||||||
 | 
					+  [0x2d84] = 0xfe26, [0x2d85] = 0xfe27, [0x2d86] = 0xfe28, [0x2d87] = 0xfe29,
 | 
				
			||||||
 | 
					+  [0x2d88] = 0xfe2a, [0x2d89] = 0xfe2b, [0x2d8a] = 0xfe2c, [0x2d8b] = 0xfe2d,
 | 
				
			||||||
 | 
					+  [0x2d8c] = 0xfe2e, [0x2d8d] = 0xfe2f, [0x2d8e] = 0xfe32, [0x2d8f] = 0xfe45,
 | 
				
			||||||
 | 
					+  [0x2d90] = 0xfe46, [0x2d91] = 0xfe47, [0x2d92] = 0xfe48, [0x2d93] = 0xfe53,
 | 
				
			||||||
 | 
					+  [0x2d94] = 0xfe58, [0x2d95] = 0xfe67, [0x2d96] = 0xfe6c, [0x2d97] = 0xfe6d,
 | 
				
			||||||
 | 
					+  [0x2d98] = 0xfe6e, [0x2d99] = 0xfe6f, [0x2d9a] = 0xfe70, [0x2d9b] = 0xfe71,
 | 
				
			||||||
 | 
					+  [0x2d9c] = 0xfe72, [0x2d9d] = 0xfe73, [0x2d9e] = 0xfe74, [0x2d9f] = 0xfe75,
 | 
				
			||||||
 | 
					+  [0x2da0] = 0xfe76, [0x2da1] = 0xfe77, [0x2da2] = 0xfe78, [0x2da3] = 0xfe79,
 | 
				
			||||||
 | 
					+  [0x2da4] = 0xfe7a, [0x2da5] = 0xfe7b, [0x2da6] = 0xfe7c, [0x2da7] = 0xfe7d,
 | 
				
			||||||
 | 
					+  [0x2da8] = 0xfe7e, [0x2da9] = 0xfe7f, [0x2daa] = 0xfe80, [0x2dab] = 0xfe81,
 | 
				
			||||||
 | 
					+  [0x2dac] = 0xfe82, [0x2dad] = 0xfe83, [0x2dae] = 0xfe84, [0x2daf] = 0xfe85,
 | 
				
			||||||
 | 
					+  [0x2db0] = 0xfe86, [0x2db1] = 0xfe87, [0x2db2] = 0xfe88, [0x2db3] = 0xfe89,
 | 
				
			||||||
 | 
					+  [0x2db4] = 0xfe8a, [0x2db5] = 0xfe8b, [0x2db6] = 0xfe8c, [0x2db7] = 0xfe8d,
 | 
				
			||||||
 | 
					+  [0x2db8] = 0xfe8e, [0x2db9] = 0xfe8f, [0x2dba] = 0xfe90, [0x2dbb] = 0xfe91,
 | 
				
			||||||
 | 
					+  [0x2dbc] = 0xfe92, [0x2dbd] = 0xfe93, [0x2dbe] = 0xfe94, [0x2dbf] = 0xfe95,
 | 
				
			||||||
 | 
					+  [0x2dc0] = 0xfe96, [0x2dc1] = 0xfe97, [0x2dc2] = 0xfe98, [0x2dc3] = 0xfe99,
 | 
				
			||||||
 | 
					+  [0x2dc4] = 0xfe9a, [0x2dc5] = 0xfe9b, [0x2dc6] = 0xfe9c, [0x2dc7] = 0xfe9d,
 | 
				
			||||||
 | 
					+  [0x2dc8] = 0xfe9e, [0x2dc9] = 0xfe9f, [0x2dca] = 0xfea0, [0x2dcb] = 0xfea1,
 | 
				
			||||||
 | 
					+  [0x2dcc] = 0xfea2, [0x2dcd] = 0xfea3, [0x2dce] = 0xfea4, [0x2dcf] = 0xfea5,
 | 
				
			||||||
 | 
					+  [0x2dd0] = 0xfea6, [0x2dd1] = 0xfea7, [0x2dd2] = 0xfea8, [0x2dd3] = 0xfea9,
 | 
				
			||||||
 | 
					+  [0x2dd4] = 0xfeaa, [0x2dd5] = 0xfeab, [0x2dd6] = 0xfeac, [0x2dd7] = 0xfead,
 | 
				
			||||||
 | 
					+  [0x2dd8] = 0xfeae, [0x2dd9] = 0xfeaf, [0x2dda] = 0xfeb0, [0x2ddb] = 0xfeb1,
 | 
				
			||||||
 | 
					+  [0x2ddc] = 0xfeb2, [0x2ddd] = 0xfeb3, [0x2dde] = 0xfeb4, [0x2ddf] = 0xfeb5,
 | 
				
			||||||
 | 
					+  [0x2de0] = 0xfeb6, [0x2de1] = 0xfeb7, [0x2de2] = 0xfeb8, [0x2de3] = 0xfeb9,
 | 
				
			||||||
 | 
					+  [0x2de4] = 0xfeba, [0x2de5] = 0xfebb, [0x2de6] = 0xfebc, [0x2de7] = 0xfebd,
 | 
				
			||||||
 | 
					+  [0x2de8] = 0xfebe, [0x2de9] = 0xfebf, [0x2dea] = 0xfec0, [0x2deb] = 0xfec1,
 | 
				
			||||||
 | 
					+  [0x2dec] = 0xfec2, [0x2ded] = 0xfec3, [0x2dee] = 0xfec4, [0x2def] = 0xfec5,
 | 
				
			||||||
 | 
					+  [0x2df0] = 0xfec6, [0x2df1] = 0xfec7, [0x2df2] = 0xfec8, [0x2df3] = 0xfec9,
 | 
				
			||||||
 | 
					+  [0x2df4] = 0xfeca, [0x2df5] = 0xfecb, [0x2df6] = 0xfecc, [0x2df7] = 0xfecd,
 | 
				
			||||||
 | 
					+  [0x2df8] = 0xfece, [0x2df9] = 0xfecf, [0x2dfa] = 0xfed0, [0x2dfb] = 0xfed1,
 | 
				
			||||||
 | 
					+  [0x2dfc] = 0xfed2, [0x2dfd] = 0xfed3, [0x2dfe] = 0xfed4, [0x2dff] = 0xfed5,
 | 
				
			||||||
 | 
					+  [0x2e00] = 0xfed6, [0x2e01] = 0xfed7, [0x2e02] = 0xfed8, [0x2e03] = 0xfed9,
 | 
				
			||||||
 | 
					+  [0x2e04] = 0xfeda, [0x2e05] = 0xfedb, [0x2e06] = 0xfedc, [0x2e07] = 0xfedd,
 | 
				
			||||||
 | 
					+  [0x2e08] = 0xfede, [0x2e09] = 0xfedf, [0x2e0a] = 0xfee0, [0x2e0b] = 0xfee1,
 | 
				
			||||||
 | 
					+  [0x2e0c] = 0xfee2, [0x2e0d] = 0xfee3, [0x2e0e] = 0xfee4, [0x2e0f] = 0xfee5,
 | 
				
			||||||
 | 
					+  [0x2e10] = 0xfee6, [0x2e11] = 0xfee7, [0x2e12] = 0xfee8, [0x2e13] = 0xfee9,
 | 
				
			||||||
 | 
					+  [0x2e14] = 0xfeea, [0x2e15] = 0xfeeb, [0x2e16] = 0xfeec, [0x2e17] = 0xfeed,
 | 
				
			||||||
 | 
					+  [0x2e18] = 0xfeee, [0x2e19] = 0xfeef, [0x2e1a] = 0xfef0, [0x2e1b] = 0xfef1,
 | 
				
			||||||
 | 
					+  [0x2e1c] = 0xfef2, [0x2e1d] = 0xfef3, [0x2e1e] = 0xfef4, [0x2e1f] = 0xfef5,
 | 
				
			||||||
 | 
					+  [0x2e20] = 0xfef6, [0x2e21] = 0xfef7, [0x2e22] = 0xfef8, [0x2e23] = 0xfef9,
 | 
				
			||||||
 | 
					+  [0x2e24] = 0xfefa, [0x2e25] = 0xfefb, [0x2e26] = 0xfefc, [0x2e27] = 0xfefd,
 | 
				
			||||||
 | 
					+  [0x2e28] = 0xfefe, [0x2e29] = 0xfeff, [0x2e2a] = 0xff00, [0x2e2b] = 0xff5f,
 | 
				
			||||||
 | 
					+  [0x2e2c] = 0xff60, [0x2e2d] = 0xff61, [0x2e2e] = 0xff62, [0x2e2f] = 0xff63,
 | 
				
			||||||
 | 
					+  [0x2e30] = 0xff64, [0x2e31] = 0xff65, [0x2e32] = 0xff66, [0x2e33] = 0xff67,
 | 
				
			||||||
 | 
					+  [0x2e34] = 0xff68, [0x2e35] = 0xff69, [0x2e36] = 0xff6a, [0x2e37] = 0xff6b,
 | 
				
			||||||
 | 
					+  [0x2e38] = 0xff6c, [0x2e39] = 0xff6d, [0x2e3a] = 0xff6e, [0x2e3b] = 0xff6f,
 | 
				
			||||||
 | 
					+  [0x2e3c] = 0xff70, [0x2e3d] = 0xff71, [0x2e3e] = 0xff72, [0x2e3f] = 0xff73,
 | 
				
			||||||
 | 
					+  [0x2e40] = 0xff74, [0x2e41] = 0xff75, [0x2e42] = 0xff76, [0x2e43] = 0xff77,
 | 
				
			||||||
 | 
					+  [0x2e44] = 0xff78, [0x2e45] = 0xff79, [0x2e46] = 0xff7a, [0x2e47] = 0xff7b,
 | 
				
			||||||
 | 
					+  [0x2e48] = 0xff7c, [0x2e49] = 0xff7d, [0x2e4a] = 0xff7e, [0x2e4b] = 0xff7f,
 | 
				
			||||||
 | 
					+  [0x2e4c] = 0xff80, [0x2e4d] = 0xff81, [0x2e4e] = 0xff82, [0x2e4f] = 0xff83,
 | 
				
			||||||
 | 
					+  [0x2e50] = 0xff84, [0x2e51] = 0xff85, [0x2e52] = 0xff86, [0x2e53] = 0xff87,
 | 
				
			||||||
 | 
					+  [0x2e54] = 0xff88, [0x2e55] = 0xff89, [0x2e56] = 0xff8a, [0x2e57] = 0xff8b,
 | 
				
			||||||
 | 
					+  [0x2e58] = 0xff8c, [0x2e59] = 0xff8d, [0x2e5a] = 0xff8e, [0x2e5b] = 0xff8f,
 | 
				
			||||||
 | 
					+  [0x2e5c] = 0xff90, [0x2e5d] = 0xff91, [0x2e5e] = 0xff92, [0x2e5f] = 0xff93,
 | 
				
			||||||
 | 
					+  [0x2e60] = 0xff94, [0x2e61] = 0xff95, [0x2e62] = 0xff96, [0x2e63] = 0xff97,
 | 
				
			||||||
 | 
					+  [0x2e64] = 0xff98, [0x2e65] = 0xff99, [0x2e66] = 0xff9a, [0x2e67] = 0xff9b,
 | 
				
			||||||
 | 
					+  [0x2e68] = 0xff9c, [0x2e69] = 0xff9d, [0x2e6a] = 0xff9e, [0x2e6b] = 0xff9f,
 | 
				
			||||||
 | 
					+  [0x2e6c] = 0xffa0, [0x2e6d] = 0xffa1, [0x2e6e] = 0xffa2, [0x2e6f] = 0xffa3,
 | 
				
			||||||
 | 
					+  [0x2e70] = 0xffa4, [0x2e71] = 0xffa5, [0x2e72] = 0xffa6, [0x2e73] = 0xffa7,
 | 
				
			||||||
 | 
					+  [0x2e74] = 0xffa8, [0x2e75] = 0xffa9, [0x2e76] = 0xffaa, [0x2e77] = 0xffab,
 | 
				
			||||||
 | 
					+  [0x2e78] = 0xffac, [0x2e79] = 0xffad, [0x2e7a] = 0xffae, [0x2e7b] = 0xffaf,
 | 
				
			||||||
 | 
					+  [0x2e7c] = 0xffb0, [0x2e7d] = 0xffb1, [0x2e7e] = 0xffb2, [0x2e7f] = 0xffb3,
 | 
				
			||||||
 | 
					+  [0x2e80] = 0xffb4, [0x2e81] = 0xffb5, [0x2e82] = 0xffb6, [0x2e83] = 0xffb7,
 | 
				
			||||||
 | 
					+  [0x2e84] = 0xffb8, [0x2e85] = 0xffb9, [0x2e86] = 0xffba, [0x2e87] = 0xffbb,
 | 
				
			||||||
 | 
					+  [0x2e88] = 0xffbc, [0x2e89] = 0xffbd, [0x2e8a] = 0xffbe, [0x2e8b] = 0xffbf,
 | 
				
			||||||
 | 
					+  [0x2e8c] = 0xffc0, [0x2e8d] = 0xffc1, [0x2e8e] = 0xffc2, [0x2e8f] = 0xffc3,
 | 
				
			||||||
 | 
					+  [0x2e90] = 0xffc4, [0x2e91] = 0xffc5, [0x2e92] = 0xffc6, [0x2e93] = 0xffc7,
 | 
				
			||||||
 | 
					+  [0x2e94] = 0xffc8, [0x2e95] = 0xffc9, [0x2e96] = 0xffca, [0x2e97] = 0xffcb,
 | 
				
			||||||
 | 
					+  [0x2e98] = 0xffcc, [0x2e99] = 0xffcd, [0x2e9a] = 0xffce, [0x2e9b] = 0xffcf,
 | 
				
			||||||
 | 
					+  [0x2e9c] = 0xffd0, [0x2e9d] = 0xffd1, [0x2e9e] = 0xffd2, [0x2e9f] = 0xffd3,
 | 
				
			||||||
 | 
					+  [0x2ea0] = 0xffd4, [0x2ea1] = 0xffd5, [0x2ea2] = 0xffd6, [0x2ea3] = 0xffd7,
 | 
				
			||||||
 | 
					+  [0x2ea4] = 0xffd8, [0x2ea5] = 0xffd9, [0x2ea6] = 0xffda, [0x2ea7] = 0xffdb,
 | 
				
			||||||
 | 
					+  [0x2ea8] = 0xffdc, [0x2ea9] = 0xffdd, [0x2eaa] = 0xffde, [0x2eab] = 0xffdf,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Table for UCS-4 -> GB18030, for the range U+0080..U+9FBB.
 | 
				
			||||||
 | 
					@@ -23437,71 +23442,79 @@ static const unsigned char __ucs_to_gb18030_tab2[][2] =
 | 
				
			||||||
 | 
					   [0x0783] = "\xa5\xfd", [0x0784] = "\xa5\xfe", [0x0785] = "\xa6\xb9",
 | 
				
			||||||
 | 
					   [0x0786] = "\xa6\xba", [0x0787] = "\xa6\xbb", [0x0788] = "\xa6\xbc",
 | 
				
			||||||
 | 
					   [0x0789] = "\xa6\xbd", [0x078a] = "\xa6\xbe", [0x078b] = "\xa6\xbf",
 | 
				
			||||||
 | 
					-  [0x078c] = "\xa6\xc0", [0x0797] = "\xa6\xf6", [0x0798] = "\xa6\xf7",
 | 
				
			||||||
 | 
					-  [0x0799] = "\xa6\xf8", [0x079a] = "\xa6\xf9", [0x079b] = "\xa6\xfa",
 | 
				
			||||||
 | 
					-  [0x079c] = "\xa6\xfb", [0x079d] = "\xa6\xfc", [0x079e] = "\xa6\xfd",
 | 
				
			||||||
 | 
					-  [0x079f] = "\xa6\xfe", [0x07a0] = "\xa7\xc2", [0x07a1] = "\xa7\xc3",
 | 
				
			||||||
 | 
					-  [0x07a2] = "\xa7\xc4", [0x07a3] = "\xa7\xc5", [0x07a4] = "\xa7\xc6",
 | 
				
			||||||
 | 
					-  [0x07a5] = "\xa7\xc7", [0x07a6] = "\xa7\xc8", [0x07a7] = "\xa7\xc9",
 | 
				
			||||||
 | 
					-  [0x07a8] = "\xa7\xca", [0x07a9] = "\xa7\xcb", [0x07aa] = "\xa7\xcc",
 | 
				
			||||||
 | 
					-  [0x07ab] = "\xa7\xcd", [0x07ac] = "\xa7\xce", [0x07ad] = "\xa7\xcf",
 | 
				
			||||||
 | 
					-  [0x07ae] = "\xa7\xd0", [0x07af] = "\xa7\xf2", [0x07b0] = "\xa7\xf3",
 | 
				
			||||||
 | 
					-  [0x07b1] = "\xa7\xf4", [0x07b2] = "\xa7\xf5", [0x07b3] = "\xa7\xf6",
 | 
				
			||||||
 | 
					-  [0x07b4] = "\xa7\xf7", [0x07b5] = "\xa7\xf8", [0x07b6] = "\xa7\xf9",
 | 
				
			||||||
 | 
					-  [0x07b7] = "\xa7\xfa", [0x07b8] = "\xa7\xfb", [0x07b9] = "\xa7\xfc",
 | 
				
			||||||
 | 
					-  [0x07ba] = "\xa7\xfd", [0x07bb] = "\xa7\xfe", [0x07bc] = "\xa8\x96",
 | 
				
			||||||
 | 
					-  [0x07bd] = "\xa8\x97", [0x07be] = "\xa8\x98", [0x07bf] = "\xa8\x99",
 | 
				
			||||||
 | 
					-  [0x07c0] = "\xa8\x9a", [0x07c1] = "\xa8\x9b", [0x07c2] = "\xa8\x9c",
 | 
				
			||||||
 | 
					-  [0x07c3] = "\xa8\x9d", [0x07c4] = "\xa8\x9e", [0x07c5] = "\xa8\x9f",
 | 
				
			||||||
 | 
					-  [0x07c6] = "\xa8\xa0", [0x07c7] = "\x00\x01", [0x07c8] = "\x65\x9e",
 | 
				
			||||||
 | 
					-  [0x07c9] = "\xa8\xc1", [0x07ca] = "\xa8\xc2", [0x07cb] = "\xa8\xc3",
 | 
				
			||||||
 | 
					-  [0x07cc] = "\xa8\xc4", [0x07cd] = "\xa8\xea", [0x07ce] = "\xa8\xeb",
 | 
				
			||||||
 | 
					-  [0x07cf] = "\xa8\xec", [0x07d0] = "\xa8\xed", [0x07d1] = "\xa8\xee",
 | 
				
			||||||
 | 
					-  [0x07d2] = "\xa8\xef", [0x07d3] = "\xa8\xf0", [0x07d4] = "\xa8\xf1",
 | 
				
			||||||
 | 
					-  [0x07d5] = "\xa8\xf2", [0x07d6] = "\xa8\xf3", [0x07d7] = "\xa8\xf4",
 | 
				
			||||||
 | 
					-  [0x07d8] = "\xa8\xf5", [0x07d9] = "\xa8\xf6", [0x07da] = "\xa8\xf7",
 | 
				
			||||||
 | 
					-  [0x07db] = "\xa8\xf8", [0x07dc] = "\xa8\xf9", [0x07dd] = "\xa8\xfa",
 | 
				
			||||||
 | 
					-  [0x07de] = "\xa8\xfb", [0x07df] = "\xa8\xfc", [0x07e0] = "\xa8\xfd",
 | 
				
			||||||
 | 
					-  [0x07e1] = "\xa8\xfe", [0x07e2] = "\xa9\x58", [0x07e3] = "\xa9\x5b",
 | 
				
			||||||
 | 
					-  [0x07e4] = "\xa9\x5d", [0x07e5] = "\xa9\x5e", [0x07e6] = "\xa9\x5f",
 | 
				
			||||||
 | 
					-  [0x07e7] = "\x65\x9f", [0x07e8] = "\x65\xa0", [0x07e9] = "\x65\xa1",
 | 
				
			||||||
 | 
					-  [0x07ea] = "\x65\xa2", [0x07eb] = "\x65\xa3", [0x07ec] = "\x65\xa4",
 | 
				
			||||||
 | 
					-  [0x07ed] = "\x65\xa5", [0x07ee] = "\x65\xa6", [0x07ef] = "\x65\xa7",
 | 
				
			||||||
 | 
					-  [0x07f0] = "\x65\xa8", [0x07f1] = "\x65\xa9", [0x07f2] = "\x65\xaa",
 | 
				
			||||||
 | 
					-  [0x07f3] = "\x65\xab", [0x07f4] = "\xa9\x97", [0x07f5] = "\xa9\x98",
 | 
				
			||||||
 | 
					-  [0x07f6] = "\xa9\x99", [0x07f7] = "\xa9\x9a", [0x07f8] = "\xa9\x9b",
 | 
				
			||||||
 | 
					-  [0x07f9] = "\xa9\x9c", [0x07fa] = "\xa9\x9d", [0x07fb] = "\xa9\x9e",
 | 
				
			||||||
 | 
					-  [0x07fc] = "\xa9\x9f", [0x07fd] = "\xa9\xa0", [0x07fe] = "\xa9\xa1",
 | 
				
			||||||
 | 
					-  [0x07ff] = "\xa9\xa2", [0x0800] = "\xa9\xa3", [0x0801] = "\xa9\xf0",
 | 
				
			||||||
 | 
					-  [0x0802] = "\xa9\xf1", [0x0803] = "\xa9\xf2", [0x0804] = "\xa9\xf3",
 | 
				
			||||||
 | 
					-  [0x0805] = "\xa9\xf4", [0x0806] = "\xa9\xf5", [0x0807] = "\xa9\xf6",
 | 
				
			||||||
 | 
					-  [0x0808] = "\xa9\xf7", [0x0809] = "\xa9\xf8", [0x080a] = "\xa9\xf9",
 | 
				
			||||||
 | 
					-  [0x080b] = "\xa9\xfa", [0x080c] = "\xa9\xfb", [0x080d] = "\xa9\xfc",
 | 
				
			||||||
 | 
					-  [0x080e] = "\xa9\xfd", [0x080f] = "\xa9\xfe", [0x0810] = "\xd7\xfa",
 | 
				
			||||||
 | 
					-  [0x0811] = "\xd7\xfb", [0x0812] = "\xd7\xfc", [0x0813] = "\xd7\xfd",
 | 
				
			||||||
 | 
					-  [0x0814] = "\xd7\xfe", [0x0815] = "\x65\xac", [0x0819] = "\x65\xad",
 | 
				
			||||||
 | 
					-  [0x081a] = "\x65\xae", [0x081b] = "\x65\xaf", [0x081c] = "\x65\xb0",
 | 
				
			||||||
 | 
					-  [0x081d] = "\x65\xb1", [0x081f] = "\x65\xb2", [0x0820] = "\x65\xb3",
 | 
				
			||||||
 | 
					-  [0x0821] = "\x65\xb4", [0x0822] = "\x65\xb5", [0x0823] = "\x65\xb6",
 | 
				
			||||||
 | 
					-  [0x0824] = "\x65\xb7", [0x0825] = "\x65\xb8", [0x0827] = "\x65\xb9",
 | 
				
			||||||
 | 
					+  [0x078c] = "\xa6\xc0", [0x078d] = "\x7b\x84", [0x078e] = "\x7b\x86",
 | 
				
			||||||
 | 
					+  [0x078f] = "\x7b\x85", [0x0790] = "\x7b\x87", [0x0791] = "\x7b\x88",
 | 
				
			||||||
 | 
					+  [0x0792] = "\x7b\x89", [0x0793] = "\x7b\x8a", [0x0794] = "\x7b\x8b",
 | 
				
			||||||
 | 
					+  [0x0795] = "\x7b\x8c", [0x0796] = "\x7b\x8d", [0x0797] = "\xa6\xf6",
 | 
				
			||||||
 | 
					+  [0x0798] = "\xa6\xf7", [0x0799] = "\xa6\xf8", [0x079a] = "\xa6\xf9",
 | 
				
			||||||
 | 
					+  [0x079b] = "\xa6\xfa", [0x079c] = "\xa6\xfb", [0x079d] = "\xa6\xfc",
 | 
				
			||||||
 | 
					+  [0x079e] = "\xa6\xfd", [0x079f] = "\xa6\xfe", [0x07a0] = "\xa7\xc2",
 | 
				
			||||||
 | 
					+  [0x07a1] = "\xa7\xc3", [0x07a2] = "\xa7\xc4", [0x07a3] = "\xa7\xc5",
 | 
				
			||||||
 | 
					+  [0x07a4] = "\xa7\xc6", [0x07a5] = "\xa7\xc7", [0x07a6] = "\xa7\xc8",
 | 
				
			||||||
 | 
					+  [0x07a7] = "\xa7\xc9", [0x07a8] = "\xa7\xca", [0x07a9] = "\xa7\xcb",
 | 
				
			||||||
 | 
					+  [0x07aa] = "\xa7\xcc", [0x07ab] = "\xa7\xcd", [0x07ac] = "\xa7\xce",
 | 
				
			||||||
 | 
					+  [0x07ad] = "\xa7\xcf", [0x07ae] = "\xa7\xd0", [0x07af] = "\xa7\xf2",
 | 
				
			||||||
 | 
					+  [0x07b0] = "\xa7\xf3", [0x07b1] = "\xa7\xf4", [0x07b2] = "\xa7\xf5",
 | 
				
			||||||
 | 
					+  [0x07b3] = "\xa7\xf6", [0x07b4] = "\xa7\xf7", [0x07b5] = "\xa7\xf8",
 | 
				
			||||||
 | 
					+  [0x07b6] = "\xa7\xf9", [0x07b7] = "\xa7\xfa", [0x07b8] = "\xa7\xfb",
 | 
				
			||||||
 | 
					+  [0x07b9] = "\xa7\xfc", [0x07ba] = "\xa7\xfd", [0x07bb] = "\xa7\xfe",
 | 
				
			||||||
 | 
					+  [0x07bc] = "\xa8\x96", [0x07bd] = "\xa8\x97", [0x07be] = "\xa8\x98",
 | 
				
			||||||
 | 
					+  [0x07bf] = "\xa8\x99", [0x07c0] = "\xa8\x9a", [0x07c1] = "\xa8\x9b",
 | 
				
			||||||
 | 
					+  [0x07c2] = "\xa8\x9c", [0x07c3] = "\xa8\x9d", [0x07c4] = "\xa8\x9e",
 | 
				
			||||||
 | 
					+  [0x07c5] = "\xa8\x9f", [0x07c6] = "\xa8\xa0", [0x07c7] = "\x00\x01",
 | 
				
			||||||
 | 
					+  [0x07c8] = "\x65\x9e", [0x07c9] = "\xa8\xc1", [0x07ca] = "\xa8\xc2",
 | 
				
			||||||
 | 
					+  [0x07cb] = "\xa8\xc3", [0x07cc] = "\xa8\xc4", [0x07cd] = "\xa8\xea",
 | 
				
			||||||
 | 
					+  [0x07ce] = "\xa8\xeb", [0x07cf] = "\xa8\xec", [0x07d0] = "\xa8\xed",
 | 
				
			||||||
 | 
					+  [0x07d1] = "\xa8\xee", [0x07d2] = "\xa8\xef", [0x07d3] = "\xa8\xf0",
 | 
				
			||||||
 | 
					+  [0x07d4] = "\xa8\xf1", [0x07d5] = "\xa8\xf2", [0x07d6] = "\xa8\xf3",
 | 
				
			||||||
 | 
					+  [0x07d7] = "\xa8\xf4", [0x07d8] = "\xa8\xf5", [0x07d9] = "\xa8\xf6",
 | 
				
			||||||
 | 
					+  [0x07da] = "\xa8\xf7", [0x07db] = "\xa8\xf8", [0x07dc] = "\xa8\xf9",
 | 
				
			||||||
 | 
					+  [0x07dd] = "\xa8\xfa", [0x07de] = "\xa8\xfb", [0x07df] = "\xa8\xfc",
 | 
				
			||||||
 | 
					+  [0x07e0] = "\xa8\xfd", [0x07e1] = "\xa8\xfe", [0x07e2] = "\xa9\x58",
 | 
				
			||||||
 | 
					+  [0x07e3] = "\xa9\x5b", [0x07e4] = "\xa9\x5d", [0x07e5] = "\xa9\x5e",
 | 
				
			||||||
 | 
					+  [0x07e6] = "\xa9\x5f", [0x07e7] = "\x65\x9f", [0x07e8] = "\x65\xa0",
 | 
				
			||||||
 | 
					+  [0x07e9] = "\x65\xa1", [0x07ea] = "\x65\xa2", [0x07eb] = "\x65\xa3",
 | 
				
			||||||
 | 
					+  [0x07ec] = "\x65\xa4", [0x07ed] = "\x65\xa5", [0x07ee] = "\x65\xa6",
 | 
				
			||||||
 | 
					+  [0x07ef] = "\x65\xa7", [0x07f0] = "\x65\xa8", [0x07f1] = "\x65\xa9",
 | 
				
			||||||
 | 
					+  [0x07f2] = "\x65\xaa", [0x07f3] = "\x65\xab", [0x07f4] = "\xa9\x97",
 | 
				
			||||||
 | 
					+  [0x07f5] = "\xa9\x98", [0x07f6] = "\xa9\x99", [0x07f7] = "\xa9\x9a",
 | 
				
			||||||
 | 
					+  [0x07f8] = "\xa9\x9b", [0x07f9] = "\xa9\x9c", [0x07fa] = "\xa9\x9d",
 | 
				
			||||||
 | 
					+  [0x07fb] = "\xa9\x9e", [0x07fc] = "\xa9\x9f", [0x07fd] = "\xa9\xa0",
 | 
				
			||||||
 | 
					+  [0x07fe] = "\xa9\xa1", [0x07ff] = "\xa9\xa2", [0x0800] = "\xa9\xa3",
 | 
				
			||||||
 | 
					+  [0x0801] = "\xa9\xf0", [0x0802] = "\xa9\xf1", [0x0803] = "\xa9\xf2",
 | 
				
			||||||
 | 
					+  [0x0804] = "\xa9\xf3", [0x0805] = "\xa9\xf4", [0x0806] = "\xa9\xf5",
 | 
				
			||||||
 | 
					+  [0x0807] = "\xa9\xf6", [0x0808] = "\xa9\xf7", [0x0809] = "\xa9\xf8",
 | 
				
			||||||
 | 
					+  [0x080a] = "\xa9\xf9", [0x080b] = "\xa9\xfa", [0x080c] = "\xa9\xfb",
 | 
				
			||||||
 | 
					+  [0x080d] = "\xa9\xfc", [0x080e] = "\xa9\xfd", [0x080f] = "\xa9\xfe",
 | 
				
			||||||
 | 
					+  [0x0810] = "\xd7\xfa", [0x0811] = "\xd7\xfb", [0x0812] = "\xd7\xfc",
 | 
				
			||||||
 | 
					+  [0x0813] = "\xd7\xfd", [0x0814] = "\xd7\xfe", [0x0815] = "\x65\xac",
 | 
				
			||||||
 | 
					+  [0x0816] = "\xfe\x51", [0x0817] = "\xfe\x52", [0x0818] = "\xfe\x53",
 | 
				
			||||||
 | 
					+  [0x0819] = "\x65\xad", [0x081a] = "\x65\xae", [0x081b] = "\x65\xaf",
 | 
				
			||||||
 | 
					+  [0x081c] = "\x65\xb0", [0x081d] = "\x65\xb1", [0x081e] = "\x2d\x51",
 | 
				
			||||||
 | 
					+  [0x081f] = "\x65\xb2", [0x0820] = "\x65\xb3", [0x0821] = "\x65\xb4",
 | 
				
			||||||
 | 
					+  [0x0822] = "\x65\xb5", [0x0823] = "\x65\xb6", [0x0824] = "\x65\xb7",
 | 
				
			||||||
 | 
					+  [0x0825] = "\x65\xb8", [0x0826] = "\x2d\x52", [0x0827] = "\x65\xb9",
 | 
				
			||||||
 | 
					   [0x0828] = "\x65\xba", [0x0829] = "\x65\xbb", [0x082a] = "\x65\xbc",
 | 
				
			||||||
 | 
					-  [0x082d] = "\x65\xbd", [0x082e] = "\x65\xbe", [0x082f] = "\x65\xbf",
 | 
				
			||||||
 | 
					-  [0x0830] = "\x65\xc0", [0x0833] = "\x65\xc1", [0x0834] = "\x65\xc2",
 | 
				
			||||||
 | 
					-  [0x0835] = "\x65\xc3", [0x0836] = "\x65\xc4", [0x0837] = "\x65\xc5",
 | 
				
			||||||
 | 
					-  [0x0838] = "\x65\xc6", [0x0839] = "\x65\xc7", [0x083a] = "\x65\xc8",
 | 
				
			||||||
 | 
					-  [0x083c] = "\x65\xc9", [0x083d] = "\x65\xca", [0x083e] = "\x65\xcb",
 | 
				
			||||||
 | 
					-  [0x083f] = "\x65\xcc", [0x0840] = "\x65\xcd", [0x0841] = "\x65\xce",
 | 
				
			||||||
 | 
					-  [0x0842] = "\x65\xcf", [0x0844] = "\x65\xd0", [0x0845] = "\x65\xd1",
 | 
				
			||||||
 | 
					+  [0x082b] = "\x2d\x53", [0x082c] = "\x2d\x54", [0x082d] = "\x65\xbd",
 | 
				
			||||||
 | 
					+  [0x082e] = "\x65\xbe", [0x082f] = "\x65\xbf", [0x0830] = "\x65\xc0",
 | 
				
			||||||
 | 
					+  [0x0831] = "\xfe\x6c", [0x0832] = "\x2d\x55", [0x0833] = "\x65\xc1",
 | 
				
			||||||
 | 
					+  [0x0834] = "\x65\xc2", [0x0835] = "\x65\xc3", [0x0836] = "\x65\xc4",
 | 
				
			||||||
 | 
					+  [0x0837] = "\x65\xc5", [0x0838] = "\x65\xc6", [0x0839] = "\x65\xc7",
 | 
				
			||||||
 | 
					+  [0x083a] = "\x65\xc8", [0x083b] = "\xfe\x76", [0x083c] = "\x65\xc9",
 | 
				
			||||||
 | 
					+  [0x083d] = "\x65\xca", [0x083e] = "\x65\xcb", [0x083f] = "\x65\xcc",
 | 
				
			||||||
 | 
					+  [0x0840] = "\x65\xcd", [0x0841] = "\x65\xce", [0x0842] = "\x65\xcf",
 | 
				
			||||||
 | 
					+  [0x0843] = "\x2d\x56", [0x0844] = "\x65\xd0", [0x0845] = "\x65\xd1",
 | 
				
			||||||
 | 
					   [0x0846] = "\x65\xd2", [0x0847] = "\x65\xd3", [0x0848] = "\x65\xd4",
 | 
				
			||||||
 | 
					   [0x0849] = "\x65\xd5", [0x084a] = "\x65\xd6", [0x084b] = "\x65\xd7",
 | 
				
			||||||
 | 
					   [0x084c] = "\x65\xd8", [0x084d] = "\x65\xd9", [0x084e] = "\x65\xda",
 | 
				
			||||||
 | 
					   [0x084f] = "\x65\xdb", [0x0850] = "\x65\xdc", [0x0851] = "\x65\xdd",
 | 
				
			||||||
 | 
					-  [0x0852] = "\x65\xde", [0x0853] = "\x65\xdf", [0x0856] = "\x65\xe0",
 | 
				
			||||||
 | 
					-  [0x0857] = "\x65\xe1", [0x0858] = "\x65\xe2", [0x0859] = "\x65\xe3",
 | 
				
			||||||
 | 
					-  [0x085a] = "\x65\xe4", [0x085b] = "\x65\xe5", [0x085c] = "\x65\xe6",
 | 
				
			||||||
 | 
					-  [0x085d] = "\x65\xe7", [0x085e] = "\x65\xe8", [0x085f] = "\x65\xe9",
 | 
				
			||||||
 | 
					-  [0x0860] = "\x65\xea", [0x0861] = "\x65\xeb", [0x0862] = "\x65\xec",
 | 
				
			||||||
 | 
					-  [0x0863] = "\x65\xed", [0x0865] = "\xfd\x9c", [0x0866] = "\x76\xb5",
 | 
				
			||||||
 | 
					+  [0x0852] = "\x65\xde", [0x0853] = "\x65\xdf", [0x0854] = "\x2d\x57",
 | 
				
			||||||
 | 
					+  [0x0855] = "\xfe\x91", [0x0856] = "\x65\xe0", [0x0857] = "\x65\xe1",
 | 
				
			||||||
 | 
					+  [0x0858] = "\x65\xe2", [0x0859] = "\x65\xe3", [0x085a] = "\x65\xe4",
 | 
				
			||||||
 | 
					+  [0x085b] = "\x65\xe5", [0x085c] = "\x65\xe6", [0x085d] = "\x65\xe7",
 | 
				
			||||||
 | 
					+  [0x085e] = "\x65\xe8", [0x085f] = "\x65\xe9", [0x0860] = "\x65\xea",
 | 
				
			||||||
 | 
					+  [0x0861] = "\x65\xeb", [0x0862] = "\x65\xec", [0x0863] = "\x65\xed",
 | 
				
			||||||
 | 
					+  [0x0864] = "\x2d\x58", [0x0865] = "\xfd\x9c", [0x0866] = "\x76\xb5",
 | 
				
			||||||
 | 
					   [0x0867] = "\x76\xb6", [0x0868] = "\x76\xb7", [0x0869] = "\x76\xb8",
 | 
				
			||||||
 | 
					   [0x086a] = "\x76\xb9", [0x086b] = "\x76\xba", [0x086c] = "\x76\xbb",
 | 
				
			||||||
 | 
					   [0x086d] = "\x76\xbc", [0x086e] = "\x76\xbd", [0x086f] = "\x76\xbe",
 | 
				
			||||||
 | 
					@@ -24211,24 +24224,8 @@ static const unsigned char __ucs_to_gb18030_tab2[][2] =
 | 
				
			||||||
 | 
					 		  || (ch = __twobyte_to_ucs[idx],			      \
 | 
				
			||||||
 | 
					 		      ch == 0 && *inptr != '\0'))			      \
 | 
				
			||||||
 | 
					 		{							      \
 | 
				
			||||||
 | 
					-		  /* Handle a few special cases.  */			      \
 | 
				
			||||||
 | 
					-		  if (idx == 0x5dd1)					      \
 | 
				
			||||||
 | 
					-		    ch = 0x20087;					      \
 | 
				
			||||||
 | 
					-		  else if (idx == 0x5dd2)				      \
 | 
				
			||||||
 | 
					-		    ch = 0x20089;					      \
 | 
				
			||||||
 | 
					-		  else if (idx == 0x5dd3)				      \
 | 
				
			||||||
 | 
					-		    ch = 0x200cc;					      \
 | 
				
			||||||
 | 
					-		  else if (idx == 0x5dec)				      \
 | 
				
			||||||
 | 
					-		    ch = 0x215D7;					      \
 | 
				
			||||||
 | 
					-		  else if (idx == 0x5df6)				      \
 | 
				
			||||||
 | 
					-		    ch = 0x2298F;					      \
 | 
				
			||||||
 | 
					-		  else if (idx == 0x5e11)				      \
 | 
				
			||||||
 | 
					-		    ch = 0x241FE;					      \
 | 
				
			||||||
 | 
					-		  else							      \
 | 
				
			||||||
 | 
					-		    {							      \
 | 
				
			||||||
 | 
					-		      /* This is an illegal character.  */		      \
 | 
				
			||||||
 | 
					-		      STANDARD_FROM_LOOP_ERR_HANDLER (2);		      \
 | 
				
			||||||
 | 
					-		    }							      \
 | 
				
			||||||
 | 
					+		  /* This is an illegal character.  */		      \
 | 
				
			||||||
 | 
					+		  STANDARD_FROM_LOOP_ERR_HANDLER (2);		      \
 | 
				
			||||||
 | 
					 		}							      \
 | 
				
			||||||
 | 
					 									      \
 | 
				
			||||||
 | 
					 	      inptr += 2;						      \
 | 
				
			||||||
 | 
					@@ -24320,17 +24317,35 @@ static const unsigned char __ucs_to_gb18030_tab2[][2] =
 | 
				
			||||||
 | 
					 	    len = 4;							      \
 | 
				
			||||||
 | 
					 	  }								      \
 | 
				
			||||||
 | 
					 	else if (ch == 0x20087)						      \
 | 
				
			||||||
 | 
					-	  cp = (const unsigned char *) "\xfe\x51";			      \
 | 
				
			||||||
 | 
					+	  {								      \
 | 
				
			||||||
 | 
					+	    idx = 0x3E2CF;						      \
 | 
				
			||||||
 | 
					+	    len = 4;							      \
 | 
				
			||||||
 | 
					+	  }	                      \
 | 
				
			||||||
 | 
					 	else if (ch == 0x20089)						      \
 | 
				
			||||||
 | 
					-	  cp = (const unsigned char *) "\xfe\x52";			      \
 | 
				
			||||||
 | 
					+	  {								      \
 | 
				
			||||||
 | 
					+	    idx = 0x3E2D1;						      \
 | 
				
			||||||
 | 
					+	    len = 4;							      \
 | 
				
			||||||
 | 
					+	  }	                       \
 | 
				
			||||||
 | 
					 	else if (ch == 0x200CC)						      \
 | 
				
			||||||
 | 
					-	  cp = (const unsigned char *) "\xfe\x53";			      \
 | 
				
			||||||
 | 
					+	  {								      \
 | 
				
			||||||
 | 
					+	    idx = 0x3E314;						      \
 | 
				
			||||||
 | 
					+	    len = 4;							      \
 | 
				
			||||||
 | 
					+	  }	                        \
 | 
				
			||||||
 | 
					 	else if (ch == 0x215d7)						      \
 | 
				
			||||||
 | 
					-	  cp = (const unsigned char *) "\xfe\x6c";			      \
 | 
				
			||||||
 | 
					+	  {								      \
 | 
				
			||||||
 | 
					+	    idx = 0x3F81F;						      \
 | 
				
			||||||
 | 
					+	    len = 4;							      \
 | 
				
			||||||
 | 
					+	  }	                        \
 | 
				
			||||||
 | 
					 	else if (ch == 0x2298F)						      \
 | 
				
			||||||
 | 
					-	  cp = (const unsigned char *) "\xfe\x76";			      \
 | 
				
			||||||
 | 
					+	  {								      \
 | 
				
			||||||
 | 
					+	    idx = 0x40BD7;						      \
 | 
				
			||||||
 | 
					+	    len = 4;							      \
 | 
				
			||||||
 | 
					+	  }	                        \
 | 
				
			||||||
 | 
					 	else if (ch == 0x241FE)						      \
 | 
				
			||||||
 | 
					-	  cp = (const unsigned char *) "\xfe\x91";			      \
 | 
				
			||||||
 | 
					+	  {								      \
 | 
				
			||||||
 | 
					+	    idx = 0x42446;						      \
 | 
				
			||||||
 | 
					+	    len = 4;							      \
 | 
				
			||||||
 | 
					+	  }	                        \
 | 
				
			||||||
 | 
					 	else if (ch >= 0x10000 && ch <= 0x10FFFF)			      \
 | 
				
			||||||
 | 
					 	  {								      \
 | 
				
			||||||
 | 
					 	    idx = ch + 0x1E248;						      \
 | 
				
			||||||
 | 
					diff --git a/iconvdata/tst-table-from.c b/iconvdata/tst-table-from.c
 | 
				
			||||||
 | 
					index 09aaaf0942..55a7113d8c 100644
 | 
				
			||||||
 | 
					--- a/iconvdata/tst-table-from.c
 | 
				
			||||||
 | 
					+++ b/iconvdata/tst-table-from.c
 | 
				
			||||||
 | 
					@@ -194,10 +194,9 @@ main (int argc, char *argv[])
 | 
				
			||||||
 | 
					       exit (1);
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* When testing UTF-8 or GB18030, stop at 0x10000, otherwise the output
 | 
				
			||||||
 | 
					+  /* When testing UTF-8, stop at 0x10000, otherwise the output
 | 
				
			||||||
 | 
					      file gets too big.  */
 | 
				
			||||||
 | 
					-  bmp_only = (strcmp (charset, "UTF-8") == 0
 | 
				
			||||||
 | 
					-	      || strcmp (charset, "GB18030") == 0);
 | 
				
			||||||
 | 
					+  bmp_only = (strcmp (charset, "UTF-8") == 0);
 | 
				
			||||||
 | 
					   search_depth = (strcmp (charset, "UTF-8") == 0 ? 3 : 4);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					diff --git a/iconvdata/tst-table-to.c b/iconvdata/tst-table-to.c
 | 
				
			||||||
 | 
					index 4dec4acad1..2b75f0c6e8 100644
 | 
				
			||||||
 | 
					--- a/iconvdata/tst-table-to.c
 | 
				
			||||||
 | 
					+++ b/iconvdata/tst-table-to.c
 | 
				
			||||||
 | 
					@@ -32,6 +32,7 @@ main (int argc, char *argv[])
 | 
				
			||||||
 | 
					   const char *charset;
 | 
				
			||||||
 | 
					   iconv_t cd;
 | 
				
			||||||
 | 
					   int bmp_only;
 | 
				
			||||||
 | 
					+  int no_tags;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   if (argc != 2)
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					@@ -47,16 +48,19 @@ main (int argc, char *argv[])
 | 
				
			||||||
 | 
					       return 1;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* When testing UTF-8 or GB18030, stop at 0x10000, otherwise the output
 | 
				
			||||||
 | 
					+  /* When testing UTF-8, stop at 0x10000, otherwise the output
 | 
				
			||||||
 | 
					      file gets too big.  */
 | 
				
			||||||
 | 
					-  bmp_only = (strcmp (charset, "UTF-8") == 0
 | 
				
			||||||
 | 
					+  bmp_only = (strcmp (charset, "UTF-8") == 0);
 | 
				
			||||||
 | 
					+  /* When testing any encoding other than UTF-8 or GB18030, stop at 0xE0000,
 | 
				
			||||||
 | 
					+     because the conversion drops Unicode tag characters (range
 | 
				
			||||||
 | 
					+     U+E0000..U+E007F).  */
 | 
				
			||||||
 | 
					+  no_tags = !(strcmp (charset, "UTF-8") == 0
 | 
				
			||||||
 | 
					 	      || strcmp (charset, "GB18030") == 0);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					     unsigned int i;
 | 
				
			||||||
 | 
					     unsigned char buf[10];
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-    for (i = 0; i < (bmp_only ? 0x10000 : 0x30000); i++)
 | 
				
			||||||
 | 
					+    for (i = 0; i < (bmp_only ? 0x10000 : no_tags ? 0xE0000 : 0x110000); i++)
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					 	unsigned char in[6];
 | 
				
			||||||
 | 
					 	unsigned int incount =
 | 
				
			||||||
 | 
					diff --git a/iconvdata/tst-table.sh b/iconvdata/tst-table.sh
 | 
				
			||||||
 | 
					index bc6f542b24..7ba15bbf5c 100755
 | 
				
			||||||
 | 
					--- a/iconvdata/tst-table.sh
 | 
				
			||||||
 | 
					+++ b/iconvdata/tst-table.sh
 | 
				
			||||||
 | 
					@@ -37,7 +37,8 @@ set -e
 | 
				
			||||||
 | 
					   < ../localedata/charmaps/${charmap:-$charset} \
 | 
				
			||||||
 | 
					   > ${objpfx}tst-${charset}.charmap.table
 | 
				
			||||||
 | 
					 # When the charset is GB18030, truncate this table because for this encoding,
 | 
				
			||||||
 | 
					-# the tst-table-from and tst-table-to programs scan the Unicode BMP only.
 | 
				
			||||||
 | 
					+# the charmap contains ranges (<Unnnn>..<Ummmm> notation), which the
 | 
				
			||||||
 | 
					+# tst-table-charmap.sh script does not grok.
 | 
				
			||||||
 | 
					 if test ${charset} = GB18030; then
 | 
				
			||||||
 | 
					   grep '0x....$' < ${objpfx}tst-${charset}.charmap.table \
 | 
				
			||||||
 | 
					     > ${objpfx}tst-${charset}.truncated.table
 | 
				
			||||||
 | 
					@@ -73,25 +74,42 @@ diff ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 # Check 1: charmap and iconv forward should be identical, except for
 | 
				
			||||||
 | 
					 # precomposed characters.
 | 
				
			||||||
 | 
					-if test -f ${precomposed}; then
 | 
				
			||||||
 | 
					-  cat ${objpfx}tst-${charset}.table ${precomposed} | sort | uniq -u \
 | 
				
			||||||
 | 
					-    > ${objpfx}tst-${charset}.tmp.table
 | 
				
			||||||
 | 
					-  cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.tmp.table ||
 | 
				
			||||||
 | 
					+{ if test -f ${precomposed}; then
 | 
				
			||||||
 | 
					+    cat ${objpfx}tst-${charset}.table ${precomposed} | sort | uniq -u
 | 
				
			||||||
 | 
					+  else
 | 
				
			||||||
 | 
					+    cat ${objpfx}tst-${charset}.table
 | 
				
			||||||
 | 
					+  fi
 | 
				
			||||||
 | 
					+} | { if test ${charset} = GB18030; then grep '0x....$'; else cat; fi; } \
 | 
				
			||||||
 | 
					+  > ${objpfx}tst-${charset}.tmp1.table
 | 
				
			||||||
 | 
					+cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.tmp1.table ||
 | 
				
			||||||
 | 
					   exit 1
 | 
				
			||||||
 | 
					-else
 | 
				
			||||||
 | 
					-  cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.table ||
 | 
				
			||||||
 | 
					-  exit 1
 | 
				
			||||||
 | 
					-fi
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 # Check 2: the difference between the charmap and iconv backward.
 | 
				
			||||||
 | 
					-if test -f ${irreversible}; then
 | 
				
			||||||
 | 
					-  cat ${objpfx}tst-${charset}.charmap.table ${irreversible} | sort | uniq -u \
 | 
				
			||||||
 | 
					-    > ${objpfx}tst-${charset}.tmp.table
 | 
				
			||||||
 | 
					-  cmp -s ${objpfx}tst-${charset}.tmp.table ${objpfx}tst-${charset}.inverse.table ||
 | 
				
			||||||
 | 
					-  exit 1
 | 
				
			||||||
 | 
					-else
 | 
				
			||||||
 | 
					-  cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table ||
 | 
				
			||||||
 | 
					+{ if test -f ${irreversible}; then
 | 
				
			||||||
 | 
					+    cat ${objpfx}tst-${charset}.charmap.table ${irreversible} | sort | uniq -u
 | 
				
			||||||
 | 
					+  else
 | 
				
			||||||
 | 
					+    cat ${objpfx}tst-${charset}.charmap.table
 | 
				
			||||||
 | 
					+  fi
 | 
				
			||||||
 | 
					+} | { if test ${charset} = GB18030; then grep '0x....$'; else cat; fi; } \
 | 
				
			||||||
 | 
					+  > ${objpfx}tst-${charset}.tmp2c.table
 | 
				
			||||||
 | 
					+cat ${objpfx}tst-${charset}.inverse.table \
 | 
				
			||||||
 | 
					+  | { if test ${charset} = GB18030; then grep '0x....$'; else cat; fi; } \
 | 
				
			||||||
 | 
					+  > ${objpfx}tst-${charset}.tmp2i.table
 | 
				
			||||||
 | 
					+cmp -s ${objpfx}tst-${charset}.tmp2c.table ${objpfx}tst-${charset}.tmp2i.table ||
 | 
				
			||||||
 | 
					   exit 1
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+# Check 3: the difference between iconv forward and iconv backward. This is
 | 
				
			||||||
 | 
					+# necessary only for GB18030, because ${objpfx}tst-${charset}.charmap.table
 | 
				
			||||||
 | 
					+# is truncated for this encoding (see above).
 | 
				
			||||||
 | 
					+if test ${charset} = GB18030; then
 | 
				
			||||||
 | 
					+  { if test -f ${irreversible}; then
 | 
				
			||||||
 | 
					+      cat ${objpfx}tst-${charset}.table ${irreversible} | sort | uniq -u
 | 
				
			||||||
 | 
					+    else
 | 
				
			||||||
 | 
					+      cat ${objpfx}tst-${charset}.table
 | 
				
			||||||
 | 
					+    fi
 | 
				
			||||||
 | 
					+  } > ${objpfx}tst-${charset}.tmp3.table
 | 
				
			||||||
 | 
					+  cmp -s ${objpfx}tst-${charset}.tmp3.table ${objpfx}tst-${charset}.inverse.table ||
 | 
				
			||||||
 | 
					+    exit 1
 | 
				
			||||||
 | 
					 fi
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 exit 0
 | 
				
			||||||
 | 
					diff --git a/localedata/charmaps/GB18030 b/localedata/charmaps/GB18030
 | 
				
			||||||
 | 
					index ad6728c5bd..fc3b1d2d40 100644
 | 
				
			||||||
 | 
					--- a/localedata/charmaps/GB18030
 | 
				
			||||||
 | 
					+++ b/localedata/charmaps/GB18030
 | 
				
			||||||
 | 
					@@ -57234,32 +57234,16 @@ CHARMAP
 | 
				
			||||||
 | 
					 <UE78A>     /xa6/xbe         <Private Use>
 | 
				
			||||||
 | 
					 <UE78B>     /xa6/xbf         <Private Use>
 | 
				
			||||||
 | 
					 <UE78C>     /xa6/xc0         <Private Use>
 | 
				
			||||||
 | 
					-% The newest GB 18030-2005 standard still uses some private use area
 | 
				
			||||||
 | 
					-% code points.  Any implementation which has Unicode 4.1 or newer
 | 
				
			||||||
 | 
					-% support should not use these PUA code points, and instead should
 | 
				
			||||||
 | 
					-% map these entries to their equivalent non-PUA code points. There
 | 
				
			||||||
 | 
					-% are 24 idiograms in GB 18030-2005 which have non-PUA equivalents.
 | 
				
			||||||
 | 
					-% In glibc we only support roundtrip code points, and so must choose
 | 
				
			||||||
 | 
					-% between supporting the old PUA code points, or using the newer
 | 
				
			||||||
 | 
					-% non-PUA code points. We choose to use the non-PUA code points to
 | 
				
			||||||
 | 
					-% be compatible with ICU's similar choice. In choosing the non-PUA
 | 
				
			||||||
 | 
					-% code points we can no longer convert the old PUA code points back
 | 
				
			||||||
 | 
					-% to GB-18030-2005 (technically only fixable if we added support
 | 
				
			||||||
 | 
					-% for non-roundtrip code points e.g. ICU's "fallback mapping").
 | 
				
			||||||
 | 
					-% The recommendation to use the non-PUA code points, where available,
 | 
				
			||||||
 | 
					-% is based on "CJKV Information Processing" 2nd Ed. by Dr. Ken Lunde.
 | 
				
			||||||
 | 
					-%
 | 
				
			||||||
 | 
					-% These 10 PUA mappings use equivalents from <UFE10> to <UFE19>.
 | 
				
			||||||
 | 
					-% <UE78D>     /xa6/xd9         <Private Use>
 | 
				
			||||||
 | 
					-% <UE78E>     /xa6/xda         <Private Use>
 | 
				
			||||||
 | 
					-% <UE78F>     /xa6/xdb         <Private Use>
 | 
				
			||||||
 | 
					-% <UE790>     /xa6/xdc         <Private Use>
 | 
				
			||||||
 | 
					-% <UE791>     /xa6/xdd         <Private Use>
 | 
				
			||||||
 | 
					-% <UE792>     /xa6/xde         <Private Use>
 | 
				
			||||||
 | 
					-% <UE793>     /xa6/xdf         <Private Use>
 | 
				
			||||||
 | 
					-% <UE794>     /xa6/xec         <Private Use>
 | 
				
			||||||
 | 
					-% <UE795>     /xa6/xed         <Private Use>
 | 
				
			||||||
 | 
					-% <UE796>     /xa6/xf3         <Private Use>
 | 
				
			||||||
 | 
					+<UE78D>     /x84/x31/x82/x36 <Private Use>
 | 
				
			||||||
 | 
					+<UE78E>     /x84/x31/x82/x38 <Private Use>
 | 
				
			||||||
 | 
					+<UE78F>     /x84/x31/x82/x37 <Private Use>
 | 
				
			||||||
 | 
					+<UE790>     /x84/x31/x82/x39 <Private Use>
 | 
				
			||||||
 | 
					+<UE791>     /x84/x31/x83/x30 <Private Use>
 | 
				
			||||||
 | 
					+<UE792>     /x84/x31/x83/x31 <Private Use>
 | 
				
			||||||
 | 
					+<UE793>     /x84/x31/x83/x32 <Private Use>
 | 
				
			||||||
 | 
					+<UE794>     /x84/x31/x83/x33 <Private Use>
 | 
				
			||||||
 | 
					+<UE795>     /x84/x31/x83/x34 <Private Use>
 | 
				
			||||||
 | 
					+<UE796>     /x84/x31/x83/x35 <Private Use>
 | 
				
			||||||
 | 
					 <UE797>     /xa6/xf6         <Private Use>
 | 
				
			||||||
 | 
					 <UE798>     /xa6/xf7         <Private Use>
 | 
				
			||||||
 | 
					 <UE799>     /xa6/xf8         <Private Use>
 | 
				
			||||||
 | 
					@@ -57387,17 +57371,15 @@ CHARMAP
 | 
				
			||||||
 | 
					 <UE813>     /xd7/xfd         <Private Use>
 | 
				
			||||||
 | 
					 <UE814>     /xd7/xfe         <Private Use>
 | 
				
			||||||
 | 
					 <UE815>     /x83/x36/xc9/x34 <Private Use>
 | 
				
			||||||
 | 
					-% These 3 PUA mappings use equivalents <U20087>, <U20089> and <U200CC>.
 | 
				
			||||||
 | 
					-% <UE816>     /xfe/x51         <Private Use>
 | 
				
			||||||
 | 
					-% <UE817>     /xfe/x52         <Private Use>
 | 
				
			||||||
 | 
					-% <UE818>     /xfe/x53         <Private Use>
 | 
				
			||||||
 | 
					+<UE816>     /xfe/x51         <Private Use>
 | 
				
			||||||
 | 
					+<UE817>     /xfe/x52         <Private Use>
 | 
				
			||||||
 | 
					+<UE818>     /xfe/x53         <Private Use>
 | 
				
			||||||
 | 
					 <UE819>     /x83/x36/xc9/x35 <Private Use>
 | 
				
			||||||
 | 
					 <UE81A>     /x83/x36/xc9/x36 <Private Use>
 | 
				
			||||||
 | 
					 <UE81B>     /x83/x36/xc9/x37 <Private Use>
 | 
				
			||||||
 | 
					 <UE81C>     /x83/x36/xc9/x38 <Private Use>
 | 
				
			||||||
 | 
					 <UE81D>     /x83/x36/xc9/x39 <Private Use>
 | 
				
			||||||
 | 
					-% This 1 PUA mapping uses the equivalent <U9FB4>.
 | 
				
			||||||
 | 
					-% <UE81E>     /xfe/x59         <Private Use>
 | 
				
			||||||
 | 
					+<UE81E>     /x82/x35/x90/x37 <Private Use>
 | 
				
			||||||
 | 
					 <UE81F>     /x83/x36/xca/x30 <Private Use>
 | 
				
			||||||
 | 
					 <UE820>     /x83/x36/xca/x31 <Private Use>
 | 
				
			||||||
 | 
					 <UE821>     /x83/x36/xca/x32 <Private Use>
 | 
				
			||||||
 | 
					@@ -57405,22 +57387,19 @@ CHARMAP
 | 
				
			||||||
 | 
					 <UE823>     /x83/x36/xca/x34 <Private Use>
 | 
				
			||||||
 | 
					 <UE824>     /x83/x36/xca/x35 <Private Use>
 | 
				
			||||||
 | 
					 <UE825>     /x83/x36/xca/x36 <Private Use>
 | 
				
			||||||
 | 
					-% This 1 PUA mapping uses the equivalent <U9FB5>.
 | 
				
			||||||
 | 
					-% <UE826>     /xfe/x61         <Private Use>
 | 
				
			||||||
 | 
					+<UE826>     /x82/x35/x90/x38 <Private Use>
 | 
				
			||||||
 | 
					 <UE827>     /x83/x36/xca/x37 <Private Use>
 | 
				
			||||||
 | 
					 <UE828>     /x83/x36/xca/x38 <Private Use>
 | 
				
			||||||
 | 
					 <UE829>     /x83/x36/xca/x39 <Private Use>
 | 
				
			||||||
 | 
					 <UE82A>     /x83/x36/xcb/x30 <Private Use>
 | 
				
			||||||
 | 
					-% These 2 PUA mappings use the equivalents <U9FB6> and <U9FB7>.
 | 
				
			||||||
 | 
					-% <UE82B>     /xfe/x66         <Private Use>
 | 
				
			||||||
 | 
					-% <UE82C>     /xfe/x67         <Private Use>
 | 
				
			||||||
 | 
					+<UE82B>     /x82/x35/x90/x39 <Private Use>
 | 
				
			||||||
 | 
					+<UE82C>     /x82/x35/x91/x30 <Private Use>
 | 
				
			||||||
 | 
					 <UE82D>     /x83/x36/xcb/x31 <Private Use>
 | 
				
			||||||
 | 
					 <UE82E>     /x83/x36/xcb/x32 <Private Use>
 | 
				
			||||||
 | 
					 <UE82F>     /x83/x36/xcb/x33 <Private Use>
 | 
				
			||||||
 | 
					 <UE830>     /x83/x36/xcb/x34 <Private Use>
 | 
				
			||||||
 | 
					-% These 2 PUA mappings use the equivalents <U215D7> and <U9FB8>.
 | 
				
			||||||
 | 
					-% <UE831>     /xfe/x6c         <Private Use>
 | 
				
			||||||
 | 
					-% <UE832>     /xfe/x6d         <Private Use>
 | 
				
			||||||
 | 
					+<UE831>     /xfe/x6c         <Private Use>
 | 
				
			||||||
 | 
					+<UE832>     /x82/x35/x91/x31 <Private Use>
 | 
				
			||||||
 | 
					 <UE833>     /x83/x36/xcb/x35 <Private Use>
 | 
				
			||||||
 | 
					 <UE834>     /x83/x36/xcb/x36 <Private Use>
 | 
				
			||||||
 | 
					 <UE835>     /x83/x36/xcb/x37 <Private Use>
 | 
				
			||||||
 | 
					@@ -57429,8 +57408,7 @@ CHARMAP
 | 
				
			||||||
 | 
					 <UE838>     /x83/x36/xcc/x30 <Private Use>
 | 
				
			||||||
 | 
					 <UE839>     /x83/x36/xcc/x31 <Private Use>
 | 
				
			||||||
 | 
					 <UE83A>     /x83/x36/xcc/x32 <Private Use>
 | 
				
			||||||
 | 
					-% This 1 PUA mapping uses the equivalent <U2298F>.
 | 
				
			||||||
 | 
					-% <UE83B>     /xfe/x76         <Private Use>
 | 
				
			||||||
 | 
					+<UE83B>     /xfe/x76         <Private Use>
 | 
				
			||||||
 | 
					 <UE83C>     /x83/x36/xcc/x33 <Private Use>
 | 
				
			||||||
 | 
					 <UE83D>     /x83/x36/xcc/x34 <Private Use>
 | 
				
			||||||
 | 
					 <UE83E>     /x83/x36/xcc/x35 <Private Use>
 | 
				
			||||||
 | 
					@@ -57438,8 +57416,7 @@ CHARMAP
 | 
				
			||||||
 | 
					 <UE840>     /x83/x36/xcc/x37 <Private Use>
 | 
				
			||||||
 | 
					 <UE841>     /x83/x36/xcc/x38 <Private Use>
 | 
				
			||||||
 | 
					 <UE842>     /x83/x36/xcc/x39 <Private Use>
 | 
				
			||||||
 | 
					-% This 1 PUA mapping uses the equivalent <U9FB9>.
 | 
				
			||||||
 | 
					-% <UE843>     /xfe/x7e         <Private Use>
 | 
				
			||||||
 | 
					+<UE843>     /x82/x35/x91/x32 <Private Use>
 | 
				
			||||||
 | 
					 <UE844>     /x83/x36/xcd/x30 <Private Use>
 | 
				
			||||||
 | 
					 <UE845>     /x83/x36/xcd/x31 <Private Use>
 | 
				
			||||||
 | 
					 <UE846>     /x83/x36/xcd/x32 <Private Use>
 | 
				
			||||||
 | 
					@@ -57456,9 +57433,8 @@ CHARMAP
 | 
				
			||||||
 | 
					 <UE851>     /x83/x36/xce/x33 <Private Use>
 | 
				
			||||||
 | 
					 <UE852>     /x83/x36/xce/x34 <Private Use>
 | 
				
			||||||
 | 
					 <UE853>     /x83/x36/xce/x35 <Private Use>
 | 
				
			||||||
 | 
					-% These 2 PUA mappings use the equivalents <U9FBA> and <U241FE>.
 | 
				
			||||||
 | 
					-% <UE854>     /xfe/x90         <Private Use>
 | 
				
			||||||
 | 
					-% <UE855>     /xfe/x91         <Private Use>
 | 
				
			||||||
 | 
					+<UE854>     /x82/x35/x91/x33 <Private Use>
 | 
				
			||||||
 | 
					+<UE855>     /xfe/x91         <Private Use>
 | 
				
			||||||
 | 
					 <UE856>     /x83/x36/xce/x36 <Private Use>
 | 
				
			||||||
 | 
					 <UE857>     /x83/x36/xce/x37 <Private Use>
 | 
				
			||||||
 | 
					 <UE858>     /x83/x36/xce/x38 <Private Use>
 | 
				
			||||||
 | 
					@@ -57473,8 +57449,7 @@ CHARMAP
 | 
				
			||||||
 | 
					 <UE861>     /x83/x36/xcf/x37 <Private Use>
 | 
				
			||||||
 | 
					 <UE862>     /x83/x36/xcf/x38 <Private Use>
 | 
				
			||||||
 | 
					 <UE863>     /x83/x36/xcf/x39 <Private Use>
 | 
				
			||||||
 | 
					-% This 1 PUA mapping uses the equivalent <U9FBB>.
 | 
				
			||||||
 | 
					-% <UE864>     /xfe/xa0         <Private Use>
 | 
				
			||||||
 | 
					+<UE864>     /x82/x35/x91/x34 <Private Use>
 | 
				
			||||||
 | 
					 <UE865>     /x83/x36/xd0/x30 <Private Use>
 | 
				
			||||||
 | 
					 <UE866>     /x83/x36/xd0/x31 <Private Use>
 | 
				
			||||||
 | 
					 <UE867>     /x83/x36/xd0/x32 <Private Use>
 | 
				
			||||||
 | 
					@@ -70447,19 +70422,14 @@ CHARMAP
 | 
				
			||||||
 | 
					 <U00020068>..<U00020071> /x95/x32/x8d/x30 <CJK>
 | 
				
			||||||
 | 
					 <U00020072>..<U0002007B> /x95/x32/x8e/x30 <CJK>
 | 
				
			||||||
 | 
					 <U0002007C>..<U00020085> /x95/x32/x8f/x30 <CJK>
 | 
				
			||||||
 | 
					-<U00020086> /x95/x32/x90/x30 <CJK>
 | 
				
			||||||
 | 
					-<U00020087> /xfe/x51         <CJK>
 | 
				
			||||||
 | 
					-<U00020088> /x95/x32/x90/x32 <CJK>
 | 
				
			||||||
 | 
					-<U00020089> /xfe/x52         <CJK>
 | 
				
			||||||
 | 
					-<U0002008A>..<U0002008F> /x95/x32/x90/x34 <CJK>
 | 
				
			||||||
 | 
					+<U00020086>..<U0002008F> /x95/x32/x90/x30 <CJK>
 | 
				
			||||||
 | 
					 <U00020090>..<U00020099> /x95/x32/x91/x30 <CJK>
 | 
				
			||||||
 | 
					 <U0002009A>..<U000200A3> /x95/x32/x92/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000200A4>..<U000200AD> /x95/x32/x93/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000200AE>..<U000200B7> /x95/x32/x94/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000200B8>..<U000200C1> /x95/x32/x95/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000200C2>..<U000200CB> /x95/x32/x96/x30 <CJK>
 | 
				
			||||||
 | 
					-<U000200CC> /xfe/x53         <CJK>
 | 
				
			||||||
 | 
					-<U000200CD>..<U000200D5> /x95/x32/x97/x31 <CJK>
 | 
				
			||||||
 | 
					+<U000200CC>..<U000200D5> /x95/x32/x97/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000200D6>..<U000200DF> /x95/x32/x98/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000200E0>..<U000200E9> /x95/x32/x99/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000200EA>..<U000200F3> /x95/x32/x9a/x30 <CJK>
 | 
				
			||||||
 | 
					@@ -70998,8 +70968,7 @@ CHARMAP
 | 
				
			||||||
 | 
					 <U000215BC>..<U000215C5> /x95/x36/xb7/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000215C6>..<U000215CF> /x95/x36/xb8/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000215D0>..<U000215D6> /x95/x36/xb9/x30 <CJK>
 | 
				
			||||||
 | 
					-<U000215D7> /xfe/x6c         <CJK>
 | 
				
			||||||
 | 
					-<U000215D8>..<U000215D9> /x95/x36/xb9/x38 <CJK>
 | 
				
			||||||
 | 
					+<U000215D7>..<U000215D9> /x95/x36/xb9/x37 <CJK>
 | 
				
			||||||
 | 
					 <U000215DA>..<U000215E3> /x95/x36/xba/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000215E4>..<U000215ED> /x95/x36/xbb/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000215EE>..<U000215F7> /x95/x36/xbc/x30 <CJK>
 | 
				
			||||||
 | 
					@@ -71505,8 +71474,7 @@ CHARMAP
 | 
				
			||||||
 | 
					 <U00022976>..<U0002297F> /x96/x30/xb8/x30 <CJK>
 | 
				
			||||||
 | 
					 <U00022980>..<U00022989> /x96/x30/xb9/x30 <CJK>
 | 
				
			||||||
 | 
					 <U0002298A>..<U0002298E> /x96/x30/xba/x30 <CJK>
 | 
				
			||||||
 | 
					-<U0002298F> /xfe/x76         <CJK>
 | 
				
			||||||
 | 
					-<U00022990>..<U00022993> /x96/x30/xba/x36 <CJK>
 | 
				
			||||||
 | 
					+<U0002298F>..<U00022993> /x96/x30/xba/x35 <CJK>
 | 
				
			||||||
 | 
					 <U00022994>..<U0002299D> /x96/x30/xbb/x30 <CJK>
 | 
				
			||||||
 | 
					 <U0002299E>..<U000229A7> /x96/x30/xbc/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000229A8>..<U000229B1> /x96/x30/xbd/x30 <CJK>
 | 
				
			||||||
 | 
					@@ -72132,8 +72100,7 @@ CHARMAP
 | 
				
			||||||
 | 
					 <U000241E0>..<U000241E9> /x96/x35/xb3/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000241EA>..<U000241F3> /x96/x35/xb4/x30 <CJK>
 | 
				
			||||||
 | 
					 <U000241F4>..<U000241FD> /x96/x35/xb5/x30 <CJK>
 | 
				
			||||||
 | 
					-<U000241FE> /xfe/x91         <CJK>
 | 
				
			||||||
 | 
					-<U000241FF>..<U00024207> /x96/x35/xb6/x31 <CJK>
 | 
				
			||||||
 | 
					+<U000241FE>..<U00024207> /x96/x35/xb6/x30 <CJK>
 | 
				
			||||||
 | 
					 <U00024208>..<U00024211> /x96/x35/xb7/x30 <CJK>
 | 
				
			||||||
 | 
					 <U00024212>..<U0002421B> /x96/x35/xb8/x30 <CJK>
 | 
				
			||||||
 | 
					 <U0002421C>..<U00024225> /x96/x35/xb9/x30 <CJK>
 | 
				
			||||||
							
								
								
									
										188
									
								
								SOURCES/glibc-RHEL-71921.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								SOURCES/glibc-RHEL-71921.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,188 @@
 | 
				
			|||||||
 | 
					commit aa3d7bd5299b33bffc118aa618b59bfa66059bcb
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Thu Feb 13 21:56:52 2025 +0100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elf: Keep using minimal malloc after early DTV resize (bug 32412)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    If an auditor loads many TLS-using modules during startup, it is
 | 
				
			||||||
 | 
					    possible to trigger DTV resizing.  Previously, the DTV was marked
 | 
				
			||||||
 | 
					    as allocated by the main malloc afterwards, even if the minimal
 | 
				
			||||||
 | 
					    malloc was still in use.  With this change, _dl_resize_dtv marks
 | 
				
			||||||
 | 
					    the resized DTV as allocated with the minimal malloc.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The new test reuses TLS-using modules from other auditing tests.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: DJ Delorie <dj@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						elf/Makefile
 | 
				
			||||||
 | 
						  (Add $(libdl), Usual conflicts due to test backport differences.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/elf/Makefile b/elf/Makefile
 | 
				
			||||||
 | 
					--- a/elf/Makefile	2025-05-06 18:12:04.588668410 -0400
 | 
				
			||||||
 | 
					+++ b/elf/Makefile	2025-05-12 16:35:57.997071294 -0400
 | 
				
			||||||
 | 
					@@ -333,6 +333,7 @@ tests += \
 | 
				
			||||||
 | 
					   tst-align2 \
 | 
				
			||||||
 | 
					   tst-audit-tlsdesc \
 | 
				
			||||||
 | 
					   tst-audit-tlsdesc-dlopen \
 | 
				
			||||||
 | 
					+  tst-audit-tlsdesc-dlopen2 \
 | 
				
			||||||
 | 
					   tst-audit1 \
 | 
				
			||||||
 | 
					   tst-audit11 \
 | 
				
			||||||
 | 
					   tst-audit12 \
 | 
				
			||||||
 | 
					@@ -694,6 +695,7 @@ modules-names = \
 | 
				
			||||||
 | 
					   tst-auditmanymod8 \
 | 
				
			||||||
 | 
					   tst-auditmanymod9 \
 | 
				
			||||||
 | 
					   tst-auditmod-tlsdesc  \
 | 
				
			||||||
 | 
					+  tst-auditmod-tlsdesc2 \
 | 
				
			||||||
 | 
					   tst-auditmod1 \
 | 
				
			||||||
 | 
					   tst-auditmod9a \
 | 
				
			||||||
 | 
					   tst-auditmod9b \
 | 
				
			||||||
 | 
					@@ -1383,6 +1385,7 @@ $(objpfx)tst-tlsalign: $(objpfx)tst-tlsa
 | 
				
			||||||
 | 
					 $(objpfx)tst-nodelete-opened.out: $(objpfx)tst-nodelete-opened-lib.so
 | 
				
			||||||
 | 
					 $(objpfx)tst-nodelete-opened: $(libdl)
 | 
				
			||||||
 | 
					 $(objpfx)tst-noload: $(libdl)
 | 
				
			||||||
 | 
					+$(objpfx)tst-auditmod-tlsdesc2.so: $(libdl)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 $(objpfx)tst-tlsalign-extern: $(objpfx)tst-tlsalign-vars.o
 | 
				
			||||||
 | 
					 $(objpfx)tst-tlsalign-extern-static: $(objpfx)tst-tlsalign-vars.o
 | 
				
			||||||
 | 
					@@ -2736,6 +2739,10 @@ tst-audit-tlsdesc-ENV = LD_AUDIT=$(objpf
 | 
				
			||||||
 | 
					 $(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-auditmod-tlsdesc.so
 | 
				
			||||||
 | 
					 tst-audit-tlsdesc-dlopen-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+$(objpfx)tst-audit-tlsdesc-dlopen2: $(shared-thread-library) $(libdl)
 | 
				
			||||||
 | 
					+$(objpfx)tst-audit-tlsdesc-dlopen2.out: $(objpfx)tst-auditmod-tlsdesc2.so \
 | 
				
			||||||
 | 
					+  $(patsubst %, $(objpfx)%.so, $(tlsmod17a-modules))
 | 
				
			||||||
 | 
					+tst-audit-tlsdesc-dlopen2-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc2.so
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 $(objpfx)tst-dlmopen-twice: $(libdl)
 | 
				
			||||||
 | 
					 $(objpfx)tst-dlmopen-twice.out: \
 | 
				
			||||||
 | 
					diff -Nrup a/elf/dl-tls.c b/elf/dl-tls.c
 | 
				
			||||||
 | 
					--- a/elf/dl-tls.c	2025-05-06 18:12:04.585668394 -0400
 | 
				
			||||||
 | 
					+++ b/elf/dl-tls.c	2025-05-07 08:21:56.363042714 -0400
 | 
				
			||||||
 | 
					@@ -529,6 +529,13 @@ _dl_resize_dtv (dtv_t *dtv, size_t max_m
 | 
				
			||||||
 | 
					       if (newp == NULL)
 | 
				
			||||||
 | 
					 	oom ();
 | 
				
			||||||
 | 
					       memcpy (newp, &dtv[-1], (2 + oldsize) * sizeof (dtv_t));
 | 
				
			||||||
 | 
					+#ifdef SHARED
 | 
				
			||||||
 | 
					+      /* Auditors can trigger a DTV resize event while the full malloc
 | 
				
			||||||
 | 
					+	 is not yet in use.  Mark the new DTV allocation as the
 | 
				
			||||||
 | 
					+	 initial allocation.  */
 | 
				
			||||||
 | 
					+      if (!__rtld_malloc_is_complete ())
 | 
				
			||||||
 | 
					+	GL(dl_initial_dtv) = &newp[1];
 | 
				
			||||||
 | 
					+#endif
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					   else
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					diff -Nrup a/elf/tst-audit-tlsdesc-dlopen2.c b/elf/tst-audit-tlsdesc-dlopen2.c
 | 
				
			||||||
 | 
					--- a/elf/tst-audit-tlsdesc-dlopen2.c	1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/elf/tst-audit-tlsdesc-dlopen2.c	2025-05-07 08:21:56.363042714 -0400
 | 
				
			||||||
 | 
					@@ -0,0 +1,46 @@
 | 
				
			||||||
 | 
					+/* Loading TLS-using modules from auditors (bug 32412).  Main program.
 | 
				
			||||||
 | 
					+   Copyright (C) 2021-2025 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/xdlfcn.h>
 | 
				
			||||||
 | 
					+#include <stdio.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+do_test (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  puts ("info: start of main program");
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Load TLS-using modules, to trigger DTV resizing.  The dynamic
 | 
				
			||||||
 | 
					+     linker will load them again (requiring their own TLS) because the
 | 
				
			||||||
 | 
					+     dlopen calls from the auditor were in the auditing namespace.  */
 | 
				
			||||||
 | 
					+  for (int i = 1; i <= 19; ++i)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      char dso[30];
 | 
				
			||||||
 | 
					+      snprintf (dso, sizeof (dso), "tst-tlsmod17a%d.so", i);
 | 
				
			||||||
 | 
					+      char sym[30];
 | 
				
			||||||
 | 
					+      snprintf (sym, sizeof(sym), "tlsmod17a%d", i);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      void *handle = xdlopen (dso, RTLD_LAZY);
 | 
				
			||||||
 | 
					+      int (*func) (void) = xdlsym (handle, sym);
 | 
				
			||||||
 | 
					+      /* Trigger TLS allocation.  */
 | 
				
			||||||
 | 
					+      func ();
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
 | 
					diff -Nrup a/elf/tst-auditmod-tlsdesc2.c b/elf/tst-auditmod-tlsdesc2.c
 | 
				
			||||||
 | 
					--- a/elf/tst-auditmod-tlsdesc2.c	1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/elf/tst-auditmod-tlsdesc2.c	2025-05-07 08:21:56.363042714 -0400
 | 
				
			||||||
 | 
					@@ -0,0 +1,59 @@
 | 
				
			||||||
 | 
					+/* Loading TLS-using modules from auditors (bug 32412).  Audit module.
 | 
				
			||||||
 | 
					+   Copyright (C) 2021-2025 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <dlfcn.h>
 | 
				
			||||||
 | 
					+#include <link.h>
 | 
				
			||||||
 | 
					+#include <stdbool.h>
 | 
				
			||||||
 | 
					+#include <stdio.h>
 | 
				
			||||||
 | 
					+#include <unistd.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+unsigned int
 | 
				
			||||||
 | 
					+la_version (unsigned int version)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  /* Open some modules, to trigger DTV resizing before the switch to
 | 
				
			||||||
 | 
					+     the main malloc.  */
 | 
				
			||||||
 | 
					+  for (int i = 1; i <= 19; ++i)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      char dso[30];
 | 
				
			||||||
 | 
					+      snprintf (dso, sizeof (dso), "tst-tlsmod17a%d.so", i);
 | 
				
			||||||
 | 
					+      char sym[30];
 | 
				
			||||||
 | 
					+      snprintf (sym, sizeof(sym), "tlsmod17a%d", i);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      void *handle = dlopen (dso, RTLD_LAZY);
 | 
				
			||||||
 | 
					+      if (handle == NULL)
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          printf ("error: dlmopen from auditor: %s\n", dlerror  ());
 | 
				
			||||||
 | 
					+          fflush (stdout);
 | 
				
			||||||
 | 
					+          _exit (1);
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+      int (*func) (void) = dlsym (handle, sym);
 | 
				
			||||||
 | 
					+      if (func == NULL)
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          printf ("error: dlsym from auditor: %s\n", dlerror  ());
 | 
				
			||||||
 | 
					+          fflush (stdout);
 | 
				
			||||||
 | 
					+          _exit (1);
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+      /* Trigger TLS allocation.  */
 | 
				
			||||||
 | 
					+      func ();
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  puts ("info: TLS-using modules loaded from auditor");
 | 
				
			||||||
 | 
					+  fflush (stdout);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return LAV_CURRENT;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
							
								
								
									
										69
									
								
								SOURCES/glibc-RHEL-76211.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								SOURCES/glibc-RHEL-76211.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
				
			|||||||
 | 
					commit 1493622f4f9048ffede3fbedb64695efa49d662a
 | 
				
			||||||
 | 
					Author: H.J. Lu <hjl.tools@gmail.com>
 | 
				
			||||||
 | 
					Date:   Mon Aug 28 12:08:14 2023 -0700
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    x86: Check the lower byte of EAX of CPUID leaf 2 [BZ #30643]
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The old Intel software developer manual specified that the low byte of
 | 
				
			||||||
 | 
					    EAX of CPUID leaf 2 returned 1 which indicated the number of rounds of
 | 
				
			||||||
 | 
					    CPUDID leaf 2 was needed to retrieve the complete cache information. The
 | 
				
			||||||
 | 
					    newer Intel manual has been changed to that it should always return 1
 | 
				
			||||||
 | 
					    and be ignored.  If the lower byte isn't 1, CPUID leaf 2 can't be used.
 | 
				
			||||||
 | 
					    In this case, we ignore CPUID leaf 2 and use CPUID leaf 4 instead.  If
 | 
				
			||||||
 | 
					    CPUID leaf 4 doesn't contain the cache information, cache information
 | 
				
			||||||
 | 
					    isn't available at all.  This addresses BZ #30643.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
 | 
				
			||||||
 | 
					index 5ddb35c9d9..87486054f9 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/x86/dl-cacheinfo.h
 | 
				
			||||||
 | 
					+++ b/sysdeps/x86/dl-cacheinfo.h
 | 
				
			||||||
 | 
					@@ -187,7 +187,7 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
 | 
				
			||||||
 | 
					 	      ++round;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 	  /* There is no other cache information anywhere else.  */
 | 
				
			||||||
 | 
					-	  break;
 | 
				
			||||||
 | 
					+	  return -1;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					       else
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					@@ -257,28 +257,23 @@ handle_intel (int name, const struct cpu_features *cpu_features)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* OK, we can use the CPUID instruction to get all info about the
 | 
				
			||||||
 | 
					      caches.  */
 | 
				
			||||||
 | 
					-  unsigned int cnt = 0;
 | 
				
			||||||
 | 
					-  unsigned int max = 1;
 | 
				
			||||||
 | 
					   long int result = 0;
 | 
				
			||||||
 | 
					   bool no_level_2_or_3 = false;
 | 
				
			||||||
 | 
					   bool has_level_2 = false;
 | 
				
			||||||
 | 
					+  unsigned int eax;
 | 
				
			||||||
 | 
					+  unsigned int ebx;
 | 
				
			||||||
 | 
					+  unsigned int ecx;
 | 
				
			||||||
 | 
					+  unsigned int edx;
 | 
				
			||||||
 | 
					+  __cpuid (2, eax, ebx, ecx, edx);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  while (cnt++ < max)
 | 
				
			||||||
 | 
					+  /* The low byte of EAX of CPUID leaf 2 should always return 1 and it
 | 
				
			||||||
 | 
					+     should be ignored.  If it isn't 1, use CPUID leaf 4 instead.  */
 | 
				
			||||||
 | 
					+  if ((eax & 0xff) != 1)
 | 
				
			||||||
 | 
					+    return intel_check_word (name, 0xff, &has_level_2, &no_level_2_or_3,
 | 
				
			||||||
 | 
					+			     cpu_features);
 | 
				
			||||||
 | 
					+  else
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					-      unsigned int eax;
 | 
				
			||||||
 | 
					-      unsigned int ebx;
 | 
				
			||||||
 | 
					-      unsigned int ecx;
 | 
				
			||||||
 | 
					-      unsigned int edx;
 | 
				
			||||||
 | 
					-      __cpuid (2, eax, ebx, ecx, edx);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      /* The low byte of EAX in the first round contain the number of
 | 
				
			||||||
 | 
					-	 rounds we have to make.  At least one, the one we are already
 | 
				
			||||||
 | 
					-	 doing.  */
 | 
				
			||||||
 | 
					-      if (cnt == 1)
 | 
				
			||||||
 | 
					-	{
 | 
				
			||||||
 | 
					-	  max = eax & 0xff;
 | 
				
			||||||
 | 
					-	  eax &= 0xffffff00;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+      eax &= 0xffffff00;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       /* Process the individual registers' value.  */
 | 
				
			||||||
 | 
					       result = intel_check_word (name, eax, &has_level_2,
 | 
				
			||||||
							
								
								
									
										32
									
								
								SOURCES/glibc-RHEL-76387.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								SOURCES/glibc-RHEL-76387.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					commit 61c3450db96dce96ad2b24b4f0b548e6a46d68e5
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Tue Dec 17 18:12:03 2024 +0100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    x86: Avoid integer truncation with large cache sizes (bug 32470)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Some hypervisors report 1 TiB L3 cache size.  This results
 | 
				
			||||||
 | 
					    in some variables incorrectly getting zeroed, causing crashes
 | 
				
			||||||
 | 
					    in memcpy/memmove because invariants are violated.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						sysdeps/x86/dl-cacheinfo.h
 | 
				
			||||||
 | 
						  (missing backport of commit 2d651eb9265d1366d7b9e881bfddd4
 | 
				
			||||||
 | 
						  ("x86: Move x86 processor cache info to cpu_features"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/sysdeps/x86/cacheinfo.h b/sysdeps/x86/cacheinfo.h
 | 
				
			||||||
 | 
					--- a/sysdeps/x86/cacheinfo.h	2025-04-09 11:11:06.532319998 -0400
 | 
				
			||||||
 | 
					+++ b/sysdeps/x86/cacheinfo.h	2025-04-09 11:17:39.493355111 -0400
 | 
				
			||||||
 | 
					@@ -388,11 +388,11 @@ init_cacheinfo (void)
 | 
				
			||||||
 | 
					        : non_temporal_threshold);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* NB: The REP MOVSB threshold must be greater than VEC_SIZE * 8.  */
 | 
				
			||||||
 | 
					-  unsigned int minimum_rep_movsb_threshold;
 | 
				
			||||||
 | 
					+  unsigned long int minimum_rep_movsb_threshold;
 | 
				
			||||||
 | 
					   /* NB: The default REP MOVSB threshold is 4096 * (VEC_SIZE / 16) for
 | 
				
			||||||
 | 
					      VEC_SIZE == 64 or 32.  For VEC_SIZE == 16, the default REP MOVSB
 | 
				
			||||||
 | 
					      threshold is 2048 * (VEC_SIZE / 16).  */
 | 
				
			||||||
 | 
					-  unsigned int rep_movsb_threshold;
 | 
				
			||||||
 | 
					+  unsigned long int rep_movsb_threshold;
 | 
				
			||||||
 | 
					   if (CPU_FEATURE_USABLE_P (cpu_features, AVX512F)
 | 
				
			||||||
 | 
					       && !CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_No_AVX512))
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
							
								
								
									
										114
									
								
								SOURCES/glibc-RHEL-78390.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								SOURCES/glibc-RHEL-78390.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,114 @@
 | 
				
			|||||||
 | 
					commit c4e4b2e149705559d28b16a9b47ba2f6142d6a6c
 | 
				
			||||||
 | 
					Author: Andreas Schwab <schwab@suse.de>
 | 
				
			||||||
 | 
					Date:   Tue Jun 23 12:55:49 2020 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Correct locking and cancellation cleanup in syslog functions (bug 26100)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Properly serialize the access to the global state shared between the
 | 
				
			||||||
 | 
					    syslog functions, to avoid races in multithreaded processes.  Protect a
 | 
				
			||||||
 | 
					    local allocation in the __vsyslog_internal function from leaking during
 | 
				
			||||||
 | 
					    cancellation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/misc/syslog.c b/misc/syslog.c
 | 
				
			||||||
 | 
					index fd6537edf6..2cc63ef287 100644
 | 
				
			||||||
 | 
					--- a/misc/syslog.c
 | 
				
			||||||
 | 
					+++ b/misc/syslog.c
 | 
				
			||||||
 | 
					@@ -91,14 +91,20 @@ struct cleanup_arg
 | 
				
			||||||
 | 
					 static void
 | 
				
			||||||
 | 
					 cancel_handler (void *ptr)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-#ifndef NO_SIGPIPE
 | 
				
			||||||
 | 
					   /* Restore the old signal handler.  */
 | 
				
			||||||
 | 
					   struct cleanup_arg *clarg = (struct cleanup_arg *) ptr;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  if (clarg != NULL && clarg->oldaction != NULL)
 | 
				
			||||||
 | 
					-    __sigaction (SIGPIPE, clarg->oldaction, NULL);
 | 
				
			||||||
 | 
					+  if (clarg != NULL)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+#ifndef NO_SIGPIPE
 | 
				
			||||||
 | 
					+      if (clarg->oldaction != NULL)
 | 
				
			||||||
 | 
					+	__sigaction (SIGPIPE, clarg->oldaction, NULL);
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+      /* Free the memstream buffer,  */
 | 
				
			||||||
 | 
					+      free (clarg->buf);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					   /* Free the lock.  */
 | 
				
			||||||
 | 
					   __libc_lock_unlock (syslog_lock);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					@@ -169,9 +175,17 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
 | 
				
			||||||
 | 
					 		pri &= LOG_PRIMASK|LOG_FACMASK;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	/* Prepare for multiple users.  We have to take care: most
 | 
				
			||||||
 | 
					+	   syscalls we are using are cancellation points.  */
 | 
				
			||||||
 | 
					+	struct cleanup_arg clarg;
 | 
				
			||||||
 | 
					+	clarg.buf = NULL;
 | 
				
			||||||
 | 
					+	clarg.oldaction = NULL;
 | 
				
			||||||
 | 
					+	__libc_cleanup_push (cancel_handler, &clarg);
 | 
				
			||||||
 | 
					+	__libc_lock_lock (syslog_lock);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	/* Check priority against setlogmask values. */
 | 
				
			||||||
 | 
					 	if ((LOG_MASK (LOG_PRI (pri)) & LogMask) == 0)
 | 
				
			||||||
 | 
					-		return;
 | 
				
			||||||
 | 
					+		goto out;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* Set default facility if none specified. */
 | 
				
			||||||
 | 
					 	if ((pri & LOG_FACMASK) == 0)
 | 
				
			||||||
 | 
					@@ -235,6 +249,9 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
 | 
				
			||||||
 | 
					 	    /* Close the memory stream; this will finalize the data
 | 
				
			||||||
 | 
					 	       into a malloc'd buffer in BUF.  */
 | 
				
			||||||
 | 
					 	    fclose (f);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	    /* Tell the cancellation handler to free this buffer.  */
 | 
				
			||||||
 | 
					+	    clarg.buf = buf;
 | 
				
			||||||
 | 
					 	  }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* Output to stderr if requested. */
 | 
				
			||||||
 | 
					@@ -252,22 +269,10 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
 | 
				
			||||||
 | 
					 		    v->iov_len = 1;
 | 
				
			||||||
 | 
					 		  }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-		__libc_cleanup_push (free, buf == failbuf ? NULL : buf);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 		/* writev is a cancellation point.  */
 | 
				
			||||||
 | 
					 		(void)__writev(STDERR_FILENO, iov, v - iov + 1);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-		__libc_cleanup_pop (0);
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Prepare for multiple users.  We have to take care: open and
 | 
				
			||||||
 | 
					-	   write are cancellation points.  */
 | 
				
			||||||
 | 
					-	struct cleanup_arg clarg;
 | 
				
			||||||
 | 
					-	clarg.buf = buf;
 | 
				
			||||||
 | 
					-	clarg.oldaction = NULL;
 | 
				
			||||||
 | 
					-	__libc_cleanup_push (cancel_handler, &clarg);
 | 
				
			||||||
 | 
					-	__libc_lock_lock (syslog_lock);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 #ifndef NO_SIGPIPE
 | 
				
			||||||
 | 
					 	/* Prepare for a broken connection.  */
 | 
				
			||||||
 | 
					  	memset (&action, 0, sizeof (action));
 | 
				
			||||||
 | 
					@@ -320,6 +325,7 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
 | 
				
			||||||
 | 
					 		__sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+ out:
 | 
				
			||||||
 | 
					 	/* End of critical section.  */
 | 
				
			||||||
 | 
					 	__libc_cleanup_pop (0);
 | 
				
			||||||
 | 
					 	__libc_lock_unlock (syslog_lock);
 | 
				
			||||||
 | 
					@@ -430,8 +436,14 @@ setlogmask (int pmask)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	int omask;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	/* Protect against multiple users.  */
 | 
				
			||||||
 | 
					+	__libc_lock_lock (syslog_lock);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	omask = LogMask;
 | 
				
			||||||
 | 
					 	if (pmask != 0)
 | 
				
			||||||
 | 
					 		LogMask = pmask;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	__libc_lock_unlock (syslog_lock);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	return (omask);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
							
								
								
									
										62
									
								
								SOURCES/glibc-RHEL-83306-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								SOURCES/glibc-RHEL-83306-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					commit 68ee0f704cb81e9ad0a78c644a83e1e9cd2ee578
 | 
				
			||||||
 | 
					Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					Date:   Tue Jan 21 16:11:06 2025 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Fix underallocation of abort_msg_s struct (CVE-2025-0395)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Include the space needed to store the length of the message itself, in
 | 
				
			||||||
 | 
					    addition to the message string.  This resolves BZ #32582.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					    Reviewed: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						sysdeps/posix/libc_fatal.c: Adjust for skipped upstream commit:
 | 
				
			||||||
 | 
						cca9684f2d7a74fc0b28bfb1859955e0e28d7b4b
 | 
				
			||||||
 | 
						(stdio: Clean up __libc_message after unconditional abort)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/assert/assert.c b/assert/assert.c
 | 
				
			||||||
 | 
					index 8ed691bd323c876a..f81d751cdab5ff92 100644
 | 
				
			||||||
 | 
					--- a/assert/assert.c
 | 
				
			||||||
 | 
					+++ b/assert/assert.c
 | 
				
			||||||
 | 
					@@ -18,6 +18,7 @@
 | 
				
			||||||
 | 
					 #include <assert.h>
 | 
				
			||||||
 | 
					 #include <atomic.h>
 | 
				
			||||||
 | 
					 #include <ldsodefs.h>
 | 
				
			||||||
 | 
					+#include <libc-pointer-arith.h>
 | 
				
			||||||
 | 
					 #include <libintl.h>
 | 
				
			||||||
 | 
					 #include <stdio.h>
 | 
				
			||||||
 | 
					 #include <stdlib.h>
 | 
				
			||||||
 | 
					@@ -64,7 +65,8 @@ __assert_fail_base (const char *fmt, const char *assertion, const char *file,
 | 
				
			||||||
 | 
					       (void) __fxprintf (NULL, "%s", str);
 | 
				
			||||||
 | 
					       (void) fflush (stderr);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-      total = (total + 1 + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1);
 | 
				
			||||||
 | 
					+      total = ALIGN_UP (total + sizeof (struct abort_msg_s) + 1,
 | 
				
			||||||
 | 
					+			GLRO(dl_pagesize));
 | 
				
			||||||
 | 
					       struct abort_msg_s *buf = __mmap (NULL, total, PROT_READ | PROT_WRITE,
 | 
				
			||||||
 | 
					 					MAP_ANON | MAP_PRIVATE, -1, 0);
 | 
				
			||||||
 | 
					       if (__glibc_likely (buf != MAP_FAILED))
 | 
				
			||||||
 | 
					diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c
 | 
				
			||||||
 | 
					index 89a20080e16558b5..89d5782a44e251a8 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/posix/libc_fatal.c
 | 
				
			||||||
 | 
					+++ b/sysdeps/posix/libc_fatal.c
 | 
				
			||||||
 | 
					@@ -20,6 +20,7 @@
 | 
				
			||||||
 | 
					 #include <errno.h>
 | 
				
			||||||
 | 
					 #include <fcntl.h>
 | 
				
			||||||
 | 
					 #include <ldsodefs.h>
 | 
				
			||||||
 | 
					+#include <libc-pointer-arith.h>
 | 
				
			||||||
 | 
					 #include <paths.h>
 | 
				
			||||||
 | 
					 #include <stdarg.h>
 | 
				
			||||||
 | 
					 #include <stdbool.h>
 | 
				
			||||||
 | 
					@@ -147,8 +148,8 @@ __libc_message (enum __libc_message_action action, const char *fmt, ...)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       if ((action & do_abort))
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					-	  total = ((total + 1 + GLRO(dl_pagesize) - 1)
 | 
				
			||||||
 | 
					-		   & ~(GLRO(dl_pagesize) - 1));
 | 
				
			||||||
 | 
					+	  total = ALIGN_UP (total + sizeof (struct abort_msg_s) + 1,
 | 
				
			||||||
 | 
					+			    GLRO(dl_pagesize));
 | 
				
			||||||
 | 
					 	  struct abort_msg_s *buf = __mmap (NULL, total,
 | 
				
			||||||
 | 
					 					    PROT_READ | PROT_WRITE,
 | 
				
			||||||
 | 
					 					    MAP_ANON | MAP_PRIVATE, -1, 0);
 | 
				
			||||||
							
								
								
									
										135
									
								
								SOURCES/glibc-RHEL-83306-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								SOURCES/glibc-RHEL-83306-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,135 @@
 | 
				
			|||||||
 | 
					commit cdb9ba84191ce72e86346fb8b1d906e7cd930ea2
 | 
				
			||||||
 | 
					Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					Date:   Fri Jan 31 12:16:30 2025 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert: Add test for CVE-2025-0395
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Use the __progname symbol to override the program name to induce the
 | 
				
			||||||
 | 
					    failure that CVE-2025-0395 describes.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This is related to BZ #32582
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						assert/Makefile: Unsorted test list downstream; now sorted.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/assert/Makefile b/assert/Makefile
 | 
				
			||||||
 | 
					index e2141e120014c362..2af46926e280deb1 100644
 | 
				
			||||||
 | 
					--- a/assert/Makefile
 | 
				
			||||||
 | 
					+++ b/assert/Makefile
 | 
				
			||||||
 | 
					@@ -25,7 +25,14 @@ include ../Makeconfig
 | 
				
			||||||
 | 
					 headers	:= assert.h
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 routines := assert assert-perr __assert
 | 
				
			||||||
 | 
					-tests := test-assert test-assert-perr tst-assert-c++ tst-assert-g++
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+tests := \
 | 
				
			||||||
 | 
					+  test-assert \
 | 
				
			||||||
 | 
					+  test-assert-perr \
 | 
				
			||||||
 | 
					+  tst-assert-c++ \
 | 
				
			||||||
 | 
					+  tst-assert-g++ \
 | 
				
			||||||
 | 
					+  tst-assert-sa-2025-0001 \
 | 
				
			||||||
 | 
					+  # tests
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 ifeq ($(have-cxx-thread_local),yes)
 | 
				
			||||||
 | 
					 CFLAGS-tst-assert-c++.o = -std=c++11
 | 
				
			||||||
 | 
					diff --git a/assert/tst-assert-sa-2025-0001.c b/assert/tst-assert-sa-2025-0001.c
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 0000000000000000..102cb0078dafa9c1
 | 
				
			||||||
 | 
					--- /dev/null
 | 
				
			||||||
 | 
					+++ b/assert/tst-assert-sa-2025-0001.c
 | 
				
			||||||
 | 
					@@ -0,0 +1,92 @@
 | 
				
			||||||
 | 
					+/* Test for CVE-2025-0395.
 | 
				
			||||||
 | 
					+   Copyright The GNU Toolchain Authors.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Test that a large enough __progname does not result in a buffer overflow
 | 
				
			||||||
 | 
					+   when printing an assertion failure.  This was CVE-2025-0395.  */
 | 
				
			||||||
 | 
					+#include <assert.h>
 | 
				
			||||||
 | 
					+#include <inttypes.h>
 | 
				
			||||||
 | 
					+#include <signal.h>
 | 
				
			||||||
 | 
					+#include <stdbool.h>
 | 
				
			||||||
 | 
					+#include <string.h>
 | 
				
			||||||
 | 
					+#include <sys/mman.h>
 | 
				
			||||||
 | 
					+#include <support/check.h>
 | 
				
			||||||
 | 
					+#include <support/support.h>
 | 
				
			||||||
 | 
					+#include <support/xstdio.h>
 | 
				
			||||||
 | 
					+#include <support/xunistd.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+extern const char *__progname;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+int
 | 
				
			||||||
 | 
					+do_test (int argc, char **argv)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  support_need_proc ("Reads /proc/self/maps to add guards to writable maps.");
 | 
				
			||||||
 | 
					+  ignore_stderr ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* XXX assumes that the assert is on a 2 digit line number.  */
 | 
				
			||||||
 | 
					+  const char *prompt = ": %s:99: do_test: Assertion `argc < 1' failed.\n";
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  int ret = fprintf (stderr, prompt, __FILE__);
 | 
				
			||||||
 | 
					+  if (ret < 0)
 | 
				
			||||||
 | 
					+    FAIL_EXIT1 ("fprintf failed: %m\n");
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  size_t pagesize = getpagesize ();
 | 
				
			||||||
 | 
					+  size_t namesize = pagesize - 1 - ret;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Alter the progname so that the assert message fills the entire page.  */
 | 
				
			||||||
 | 
					+  char progname[namesize];
 | 
				
			||||||
 | 
					+  memset (progname, 'A', namesize - 1);
 | 
				
			||||||
 | 
					+  progname[namesize - 1] = '\0';
 | 
				
			||||||
 | 
					+  __progname = progname;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  FILE *f = xfopen ("/proc/self/maps", "r");
 | 
				
			||||||
 | 
					+  char *line = NULL;
 | 
				
			||||||
 | 
					+  size_t len = 0;
 | 
				
			||||||
 | 
					+  uintptr_t prev_to = 0;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Pad the beginning of every writable mapping with a PROT_NONE map.  This
 | 
				
			||||||
 | 
					+     ensures that the mmap in the assert_fail path never ends up below a
 | 
				
			||||||
 | 
					+     writable map and will terminate immediately in case of a buffer
 | 
				
			||||||
 | 
					+     overflow.  */
 | 
				
			||||||
 | 
					+  while (xgetline (&line, &len, f))
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      uintptr_t from, to;
 | 
				
			||||||
 | 
					+      char perm[4];
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      sscanf (line, "%" SCNxPTR "-%" SCNxPTR " %c%c%c%c ",
 | 
				
			||||||
 | 
					+	      &from, &to,
 | 
				
			||||||
 | 
					+	      &perm[0], &perm[1], &perm[2], &perm[3]);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      bool writable = (memchr (perm, 'w', 4) != NULL);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      if (prev_to != 0 && from - prev_to > pagesize && writable)
 | 
				
			||||||
 | 
					+	xmmap ((void *) from - pagesize, pagesize, PROT_NONE,
 | 
				
			||||||
 | 
					+	       MAP_ANONYMOUS | MAP_PRIVATE, 0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      prev_to = to;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  xfclose (f);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  assert (argc < 1);
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#define EXPECTED_SIGNAL SIGABRT
 | 
				
			||||||
 | 
					+#define TEST_FUNCTION_ARGV do_test
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
							
								
								
									
										463
									
								
								SOURCES/glibc-RHEL-8381-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										463
									
								
								SOURCES/glibc-RHEL-8381-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,463 @@
 | 
				
			|||||||
 | 
					commit 1db84775f831a1494993ce9c118deaf9537cc50a
 | 
				
			||||||
 | 
					Author: Frank Barrus <frankbarrus_sw@shaggy.cc>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 07:55:02 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pthreads NPTL: lost wakeup fix 2
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This fixes the lost wakeup (from a bug in signal stealing) with a change
 | 
				
			||||||
 | 
					    in the usage of g_signals[] in the condition variable internal state.
 | 
				
			||||||
 | 
					    It also completely eliminates the concept and handling of signal stealing,
 | 
				
			||||||
 | 
					    as well as the need for signalers to block to wait for waiters to wake
 | 
				
			||||||
 | 
					    up every time there is a G1/G2 switch.  This greatly reduces the average
 | 
				
			||||||
 | 
					    and maximum latency for pthread_cond_signal.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The g_signals[] field now contains a signal count that is relative to
 | 
				
			||||||
 | 
					    the current g1_start value.  Since it is a 32-bit field, and the LSB is
 | 
				
			||||||
 | 
					    still reserved (though not currently used anymore), it has a 31-bit value
 | 
				
			||||||
 | 
					    that corresponds to the low 31 bits of the sequence number in g1_start.
 | 
				
			||||||
 | 
					    (since g1_start also has an LSB flag, this means bits 31:1 in g_signals
 | 
				
			||||||
 | 
					    correspond to bits 31:1 in g1_start, plus the current signal count)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    By making the signal count relative to g1_start, there is no longer
 | 
				
			||||||
 | 
					    any ambiguity or A/B/A issue, and thus any checks before blocking,
 | 
				
			||||||
 | 
					    including the futex call itself, are guaranteed not to block if the G1/G2
 | 
				
			||||||
 | 
					    switch occurs, even if the signal count remains the same.  This allows
 | 
				
			||||||
 | 
					    initially safely blocking in G2 until the switch to G1 occurs, and
 | 
				
			||||||
 | 
					    then transitioning from G1 to a new G1 or G2, and always being able to
 | 
				
			||||||
 | 
					    distinguish the state change.  This removes the race condition and A/B/A
 | 
				
			||||||
 | 
					    problems that otherwise ocurred if a late (pre-empted) waiter were to
 | 
				
			||||||
 | 
					    resume just as the futex call attempted to block on g_signal since
 | 
				
			||||||
 | 
					    otherwise there was no last opportunity to re-check things like whether
 | 
				
			||||||
 | 
					    the current G1 group was already closed.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    By fixing these issues, the signal stealing code can be eliminated,
 | 
				
			||||||
 | 
					    since there is no concept of signal stealing anymore.  The code to block
 | 
				
			||||||
 | 
					    for all waiters to exit g_refs can also be removed, since any waiters
 | 
				
			||||||
 | 
					    that are still in the g_refs region can be guaranteed to safely wake
 | 
				
			||||||
 | 
					    up and exit.  If there are still any left at this time, they are all
 | 
				
			||||||
 | 
					    sent one final futex wakeup to ensure that they are not blocked any
 | 
				
			||||||
 | 
					    longer, but there is no need for the signaller to block and wait for
 | 
				
			||||||
 | 
					    them to wake up and exit the g_refs region.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The signal count is then effectively "zeroed" but since it is now
 | 
				
			||||||
 | 
					    relative to g1_start, this is done by advancing it to a new value that
 | 
				
			||||||
 | 
					    can be observed by any pending blocking waiters.  Any late waiters can
 | 
				
			||||||
 | 
					    always tell the difference, and can thus just cleanly exit if they are
 | 
				
			||||||
 | 
					    in a stale G1 or G2.  They can never steal a signal from the current
 | 
				
			||||||
 | 
					    G1 if they are not in the current G1, since the signal value that has
 | 
				
			||||||
 | 
					    to match in the cmpxchg has the low 31 bits of the g1_start value
 | 
				
			||||||
 | 
					    contained in it, and that's first checked, and then it won't match if
 | 
				
			||||||
 | 
					    there's a G1/G2 change.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Note: the 31-bit sequence number used in g_signals is designed to
 | 
				
			||||||
 | 
					    handle wrap-around when checking the signal count, but if the entire
 | 
				
			||||||
 | 
					    31-bit wraparound (2 billion signals) occurs while there is still a
 | 
				
			||||||
 | 
					    late waiter that has not yet resumed, and it happens to then match
 | 
				
			||||||
 | 
					    the current g1_start low bits, and the pre-emption occurs after the
 | 
				
			||||||
 | 
					    normal "closed group" checks (which are 64-bit) but then hits the
 | 
				
			||||||
 | 
					    futex syscall and signal consuming code, then an A/B/A issue could
 | 
				
			||||||
 | 
					    still result and cause an incorrect assumption about whether it
 | 
				
			||||||
 | 
					    should block.  This particular scenario seems unlikely in practice.
 | 
				
			||||||
 | 
					    Note that once awake from the futex, the waiter would notice the
 | 
				
			||||||
 | 
					    closed group before consuming the signal (since that's still a 64-bit
 | 
				
			||||||
 | 
					    check that would not be aliased in the wrap-around in g_signals),
 | 
				
			||||||
 | 
					    so the biggest impact would be blocking on the futex until the next
 | 
				
			||||||
 | 
					    full wakeup from a G1/G2 switch.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Frank Barrus <frankbarrus_sw@shaggy.cc>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Conflicts:
 | 
				
			||||||
 | 
					#	nptl/pthread_cond_common.c (timed wait refactor)
 | 
				
			||||||
 | 
					#	nptl/pthread_cond_wait.c (textual conflicts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					index 479e54febb417675..9175e6779ebff244 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					@@ -341,7 +341,6 @@ static bool __attribute__ ((unused))
 | 
				
			||||||
 | 
					 __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					     unsigned int *g1index, int private)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-  const unsigned int maxspin = 0;
 | 
				
			||||||
 | 
					   unsigned int g1 = *g1index;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* If there is no waiter in G2, we don't do anything.  The expression may
 | 
				
			||||||
 | 
					@@ -362,84 +361,46 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					      * New waiters arriving concurrently with the group switching will all go
 | 
				
			||||||
 | 
					        into G2 until we atomically make the switch.  Waiters existing in G2
 | 
				
			||||||
 | 
					        are not affected.
 | 
				
			||||||
 | 
					-     * Waiters in G1 will be closed out immediately by setting a flag in
 | 
				
			||||||
 | 
					-       __g_signals, which will prevent waiters from blocking using a futex on
 | 
				
			||||||
 | 
					-       __g_signals and also notifies them that the group is closed.  As a
 | 
				
			||||||
 | 
					-       result, they will eventually remove their group reference, allowing us
 | 
				
			||||||
 | 
					-       to close switch group roles.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  /* First, set the closed flag on __g_signals.  This tells waiters that are
 | 
				
			||||||
 | 
					-     about to wait that they shouldn't do that anymore.  This basically
 | 
				
			||||||
 | 
					-     serves as an advance notificaton of the upcoming change to __g1_start;
 | 
				
			||||||
 | 
					-     waiters interpret it as if __g1_start was larger than their waiter
 | 
				
			||||||
 | 
					-     sequence position.  This allows us to change __g1_start after waiting
 | 
				
			||||||
 | 
					-     for all existing waiters with group references to leave, which in turn
 | 
				
			||||||
 | 
					-     makes recovery after stealing a signal simpler because it then can be
 | 
				
			||||||
 | 
					-     skipped if __g1_start indicates that the group is closed (otherwise,
 | 
				
			||||||
 | 
					-     we would have to recover always because waiters don't know how big their
 | 
				
			||||||
 | 
					-     groups are).  Relaxed MO is fine.  */
 | 
				
			||||||
 | 
					-  atomic_fetch_or_relaxed (cond->__data.__g_signals + g1, 1);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  /* Wait until there are no group references anymore.  The fetch-or operation
 | 
				
			||||||
 | 
					-     injects us into the modification order of __g_refs; release MO ensures
 | 
				
			||||||
 | 
					-     that waiters incrementing __g_refs after our fetch-or see the previous
 | 
				
			||||||
 | 
					-     changes to __g_signals and to __g1_start that had to happen before we can
 | 
				
			||||||
 | 
					-     switch this G1 and alias with an older group (we have two groups, so
 | 
				
			||||||
 | 
					-     aliasing requires switching group roles twice).  Note that nobody else
 | 
				
			||||||
 | 
					-     can have set the wake-request flag, so we do not have to act upon it.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-     Also note that it is harmless if older waiters or waiters from this G1
 | 
				
			||||||
 | 
					-     get a group reference after we have quiesced the group because it will
 | 
				
			||||||
 | 
					-     remain closed for them either because of the closed flag in __g_signals
 | 
				
			||||||
 | 
					-     or the later update to __g1_start.  New waiters will never arrive here
 | 
				
			||||||
 | 
					-     but instead continue to go into the still current G2.  */
 | 
				
			||||||
 | 
					-  unsigned r = atomic_fetch_or_release (cond->__data.__g_refs + g1, 0);
 | 
				
			||||||
 | 
					-  while ((r >> 1) > 0)
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					-      for (unsigned int spin = maxspin; ((r >> 1) > 0) && (spin > 0); spin--)
 | 
				
			||||||
 | 
					-	{
 | 
				
			||||||
 | 
					-	  /* TODO Back off.  */
 | 
				
			||||||
 | 
					-	  r = atomic_load_relaxed (cond->__data.__g_refs + g1);
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-      if ((r >> 1) > 0)
 | 
				
			||||||
 | 
					-	{
 | 
				
			||||||
 | 
					-	  /* There is still a waiter after spinning.  Set the wake-request
 | 
				
			||||||
 | 
					-	     flag and block.  Relaxed MO is fine because this is just about
 | 
				
			||||||
 | 
					-	     this futex word.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	     Update r to include the set wake-request flag so that the upcoming
 | 
				
			||||||
 | 
					-	     futex_wait only blocks if the flag is still set (otherwise, we'd
 | 
				
			||||||
 | 
					-	     violate the basic client-side futex protocol).  */
 | 
				
			||||||
 | 
					-	  r = atomic_fetch_or_relaxed (cond->__data.__g_refs + g1, 1) | 1;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  if ((r >> 1) > 0)
 | 
				
			||||||
 | 
					-	    futex_wait_simple (cond->__data.__g_refs + g1, r, private);
 | 
				
			||||||
 | 
					-	  /* Reload here so we eventually see the most recent value even if we
 | 
				
			||||||
 | 
					-	     do not spin.   */
 | 
				
			||||||
 | 
					-	  r = atomic_load_relaxed (cond->__data.__g_refs + g1);
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					-  /* Acquire MO so that we synchronize with the release operation that waiters
 | 
				
			||||||
 | 
					-     use to decrement __g_refs and thus happen after the waiters we waited
 | 
				
			||||||
 | 
					-     for.  */
 | 
				
			||||||
 | 
					-  atomic_thread_fence_acquire ();
 | 
				
			||||||
 | 
					+     * Waiters in G1 will be closed out immediately by the advancing of
 | 
				
			||||||
 | 
					+       __g_signals to the next "lowseq" (low 31 bits of the new g1_start),
 | 
				
			||||||
 | 
					+       which will prevent waiters from blocking using a futex on
 | 
				
			||||||
 | 
					+       __g_signals since it provides enough signals for all possible
 | 
				
			||||||
 | 
					+       remaining waiters.  As a result, they can each consume a signal
 | 
				
			||||||
 | 
					+       and they will eventually remove their group reference.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* Update __g1_start, which finishes closing this group.  The value we add
 | 
				
			||||||
 | 
					      will never be negative because old_orig_size can only be zero when we
 | 
				
			||||||
 | 
					      switch groups the first time after a condvar was initialized, in which
 | 
				
			||||||
 | 
					-     case G1 will be at index 1 and we will add a value of 1.  See above for
 | 
				
			||||||
 | 
					-     why this takes place after waiting for quiescence of the group.
 | 
				
			||||||
 | 
					+     case G1 will be at index 1 and we will add a value of 1.
 | 
				
			||||||
 | 
					      Relaxed MO is fine because the change comes with no additional
 | 
				
			||||||
 | 
					      constraints that others would have to observe.  */
 | 
				
			||||||
 | 
					   __condvar_add_g1_start_relaxed (cond,
 | 
				
			||||||
 | 
					       (old_orig_size << 1) + (g1 == 1 ? 1 : - 1));
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* Now reopen the group, thus enabling waiters to again block using the
 | 
				
			||||||
 | 
					-     futex controlled by __g_signals.  Release MO so that observers that see
 | 
				
			||||||
 | 
					-     no signals (and thus can block) also see the write __g1_start and thus
 | 
				
			||||||
 | 
					-     that this is now a new group (see __pthread_cond_wait_common for the
 | 
				
			||||||
 | 
					-     matching acquire MO loads).  */
 | 
				
			||||||
 | 
					-  atomic_store_release (cond->__data.__g_signals + g1, 0);
 | 
				
			||||||
 | 
					+  unsigned int lowseq = ((old_g1_start + old_orig_size) << 1) & ~1U;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* If any waiters still hold group references (and thus could be blocked),
 | 
				
			||||||
 | 
					+     then wake them all up now and prevent any running ones from blocking.
 | 
				
			||||||
 | 
					+     This is effectively a catch-all for any possible current or future
 | 
				
			||||||
 | 
					+     bugs that can allow the group size to reach 0 before all G1 waiters
 | 
				
			||||||
 | 
					+     have been awakened or at least given signals to consume, or any
 | 
				
			||||||
 | 
					+     other case that can leave blocked (or about to block) older waiters..  */
 | 
				
			||||||
 | 
					+  if ((atomic_fetch_or_release (cond->__data.__g_refs + g1, 0) >> 1) > 0)
 | 
				
			||||||
 | 
					+   {
 | 
				
			||||||
 | 
					+    /* First advance signals to the end of the group (i.e. enough signals
 | 
				
			||||||
 | 
					+       for the entire G1 group) to ensure that waiters which have not
 | 
				
			||||||
 | 
					+       yet blocked in the futex will not block.
 | 
				
			||||||
 | 
					+       Note that in the vast majority of cases, this should never
 | 
				
			||||||
 | 
					+       actually be necessary, since __g_signals will have enough
 | 
				
			||||||
 | 
					+       signals for the remaining g_refs waiters.  As an optimization,
 | 
				
			||||||
 | 
					+       we could check this first before proceeding, although that
 | 
				
			||||||
 | 
					+       could still leave the potential for futex lost wakeup bugs
 | 
				
			||||||
 | 
					+       if the signal count was non-zero but the futex wakeup
 | 
				
			||||||
 | 
					+       was somehow lost.  */
 | 
				
			||||||
 | 
					+    atomic_store_release (cond->__data.__g_signals + g1, lowseq);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+    futex_wake (cond->__data.__g_signals + g1, INT_MAX, private);
 | 
				
			||||||
 | 
					+   }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* At this point, the old G1 is now a valid new G2 (but not in use yet).
 | 
				
			||||||
 | 
					      No old waiter can neither grab a signal nor acquire a reference without
 | 
				
			||||||
 | 
					@@ -451,6 +412,10 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					   g1 ^= 1;
 | 
				
			||||||
 | 
					   *g1index ^= 1;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+  /* Now advance the new G1 g_signals to the new lowseq, giving it
 | 
				
			||||||
 | 
					+     an effective signal count of 0 to start.  */
 | 
				
			||||||
 | 
					+  atomic_store_release (cond->__data.__g_signals + g1, lowseq);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					   /* These values are just observed by signalers, and thus protected by the
 | 
				
			||||||
 | 
					      lock.  */
 | 
				
			||||||
 | 
					   unsigned int orig_size = wseq - (old_g1_start + old_orig_size);
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index ebf07ca82d87de7d..4fb22b28a7a20ecd 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -239,9 +239,7 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					    signaled), and a reference count.
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					    The group reference count is used to maintain the number of waiters that
 | 
				
			||||||
 | 
					-   are using the group's futex.  Before a group can change its role, the
 | 
				
			||||||
 | 
					-   reference count must show that no waiters are using the futex anymore; this
 | 
				
			||||||
 | 
					-   prevents ABA issues on the futex word.
 | 
				
			||||||
 | 
					+   are using the group's futex.
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					    To represent which intervals in the waiter sequence the groups cover (and
 | 
				
			||||||
 | 
					    thus also which group slot contains G1 or G2), we use a 64b counter to
 | 
				
			||||||
 | 
					@@ -301,11 +299,12 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					        last reference.
 | 
				
			||||||
 | 
					      * Reference count used by waiters concurrently with signalers that have
 | 
				
			||||||
 | 
					        acquired the condvar-internal lock.
 | 
				
			||||||
 | 
					-   __g_signals: The number of signals that can still be consumed.
 | 
				
			||||||
 | 
					+   __g_signals: The number of signals that can still be consumed, relative to
 | 
				
			||||||
 | 
					+     the current g1_start.  (i.e. bits 31 to 1 of __g_signals are bits
 | 
				
			||||||
 | 
					+     31 to 1 of g1_start with the signal count added)
 | 
				
			||||||
 | 
					      * Used as a futex word by waiters.  Used concurrently by waiters and
 | 
				
			||||||
 | 
					        signalers.
 | 
				
			||||||
 | 
					-     * LSB is true iff this group has been completely signaled (i.e., it is
 | 
				
			||||||
 | 
					-       closed).
 | 
				
			||||||
 | 
					+     * LSB is currently reserved and 0.
 | 
				
			||||||
 | 
					    __g_size: Waiters remaining in this group (i.e., which have not been
 | 
				
			||||||
 | 
					      signaled yet.
 | 
				
			||||||
 | 
					      * Accessed by signalers and waiters that cancel waiting (both do so only
 | 
				
			||||||
 | 
					@@ -329,18 +328,6 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					    sufficient because if a waiter can see a sufficiently large value, it could
 | 
				
			||||||
 | 
					    have also consume a signal in the waiters group.
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-   Waiters try to grab a signal from __g_signals without holding a reference
 | 
				
			||||||
 | 
					-   count, which can lead to stealing a signal from a more recent group after
 | 
				
			||||||
 | 
					-   their own group was already closed.  They cannot always detect whether they
 | 
				
			||||||
 | 
					-   in fact did because they do not know when they stole, but they can
 | 
				
			||||||
 | 
					-   conservatively add a signal back to the group they stole from; if they
 | 
				
			||||||
 | 
					-   did so unnecessarily, all that happens is a spurious wake-up.  To make this
 | 
				
			||||||
 | 
					-   even less likely, __g1_start contains the index of the current g2 too,
 | 
				
			||||||
 | 
					-   which allows waiters to check if there aliasing on the group slots; if
 | 
				
			||||||
 | 
					-   there wasn't, they didn't steal from the current G1, which means that the
 | 
				
			||||||
 | 
					-   G1 they stole from must have been already closed and they do not need to
 | 
				
			||||||
 | 
					-   fix anything.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					    It is essential that the last field in pthread_cond_t is __g_signals[1]:
 | 
				
			||||||
 | 
					    The previous condvar used a pointer-sized field in pthread_cond_t, so a
 | 
				
			||||||
 | 
					    PTHREAD_COND_INITIALIZER from that condvar implementation might only
 | 
				
			||||||
 | 
					@@ -431,6 +418,9 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       while (1)
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					+          uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+          unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	  /* Spin-wait first.
 | 
				
			||||||
 | 
					 	     Note that spinning first without checking whether a timeout
 | 
				
			||||||
 | 
					 	     passed might lead to what looks like a spurious wake-up even
 | 
				
			||||||
 | 
					@@ -442,35 +432,45 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	     having to compare against the current time seems to be the right
 | 
				
			||||||
 | 
					 	     choice from a performance perspective for most use cases.  */
 | 
				
			||||||
 | 
					 	  unsigned int spin = maxspin;
 | 
				
			||||||
 | 
					-	  while (signals == 0 && spin > 0)
 | 
				
			||||||
 | 
					+	  while (spin > 0 && ((int)(signals - lowseq) < 2))
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					 	      /* Check that we are not spinning on a group that's already
 | 
				
			||||||
 | 
					 		 closed.  */
 | 
				
			||||||
 | 
					-	      if (seq < (__condvar_load_g1_start_relaxed (cond) >> 1))
 | 
				
			||||||
 | 
					-		goto done;
 | 
				
			||||||
 | 
					+	      if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					+		break;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	      /* TODO Back off.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	      /* Reload signals.  See above for MO.  */
 | 
				
			||||||
 | 
					 	      signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					+              g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+              lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					 	      spin--;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	  /* If our group will be closed as indicated by the flag on signals,
 | 
				
			||||||
 | 
					-	     don't bother grabbing a signal.  */
 | 
				
			||||||
 | 
					-	  if (signals & 1)
 | 
				
			||||||
 | 
					-	    goto done;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  /* If there is an available signal, don't block.  */
 | 
				
			||||||
 | 
					-	  if (signals != 0)
 | 
				
			||||||
 | 
					+          if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					+	    {
 | 
				
			||||||
 | 
					+              /* If the group is closed already,
 | 
				
			||||||
 | 
					+	         then this waiter originally had enough extra signals to
 | 
				
			||||||
 | 
					+	         consume, up until the time its group was closed.  */
 | 
				
			||||||
 | 
					+	       goto done;
 | 
				
			||||||
 | 
					+            }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	  /* If there is an available signal, don't block.
 | 
				
			||||||
 | 
					+             If __g1_start has advanced at all, then we must be in G1
 | 
				
			||||||
 | 
					+	     by now, perhaps in the process of switching back to an older
 | 
				
			||||||
 | 
					+	     G2, but in either case we're allowed to consume the available
 | 
				
			||||||
 | 
					+	     signal and should not block anymore.  */
 | 
				
			||||||
 | 
					+	  if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					 	    break;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  /* No signals available after spinning, so prepare to block.
 | 
				
			||||||
 | 
					 	     We first acquire a group reference and use acquire MO for that so
 | 
				
			||||||
 | 
					 	     that we synchronize with the dummy read-modify-write in
 | 
				
			||||||
 | 
					 	     __condvar_quiesce_and_switch_g1 if we read from that.  In turn,
 | 
				
			||||||
 | 
					-	     in this case this will make us see the closed flag on __g_signals
 | 
				
			||||||
 | 
					-	     that designates a concurrent attempt to reuse the group's slot.
 | 
				
			||||||
 | 
					+	     in this case this will make us see the advancement of __g_signals
 | 
				
			||||||
 | 
					+	     to the upcoming new g1_start that occurs with a concurrent
 | 
				
			||||||
 | 
					+	     attempt to reuse the group's slot.
 | 
				
			||||||
 | 
					 	     We use acquire MO for the __g_signals check to make the
 | 
				
			||||||
 | 
					 	     __g1_start check work (see spinning above).
 | 
				
			||||||
 | 
					 	     Note that the group reference acquisition will not mask the
 | 
				
			||||||
 | 
					@@ -478,15 +478,24 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	     an atomic read-modify-write operation and thus extend the release
 | 
				
			||||||
 | 
					 	     sequence.  */
 | 
				
			||||||
 | 
					 	  atomic_fetch_add_acquire (cond->__data.__g_refs + g, 2);
 | 
				
			||||||
 | 
					-	  if (((atomic_load_acquire (cond->__data.__g_signals + g) & 1) != 0)
 | 
				
			||||||
 | 
					-	      || (seq < (__condvar_load_g1_start_relaxed (cond) >> 1)))
 | 
				
			||||||
 | 
					+	  signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					+          g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+          lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+          if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					-	      /* Our group is closed.  Wake up any signalers that might be
 | 
				
			||||||
 | 
					-		 waiting.  */
 | 
				
			||||||
 | 
					+              /* group is closed already, so don't block */
 | 
				
			||||||
 | 
					 	      __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					 	      goto done;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	  if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					+	    {
 | 
				
			||||||
 | 
					+	      /* a signal showed up or G1/G2 switched after we grabbed the refcount */
 | 
				
			||||||
 | 
					+	      __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					+	      break;
 | 
				
			||||||
 | 
					+            }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	  // Now block.
 | 
				
			||||||
 | 
					 	  struct _pthread_cleanup_buffer buffer;
 | 
				
			||||||
 | 
					 	  struct _condvar_cleanup_buffer cbuffer;
 | 
				
			||||||
 | 
					@@ -500,7 +509,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					 	      /* Block without a timeout.  */
 | 
				
			||||||
 | 
					 	      err = futex_wait_cancelable (
 | 
				
			||||||
 | 
					-		  cond->__data.__g_signals + g, 0, private);
 | 
				
			||||||
 | 
					+		  cond->__data.__g_signals + g, signals, private);
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 	  else
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					@@ -531,13 +540,13 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 		    err = ETIMEDOUT;
 | 
				
			||||||
 | 
					 		  else
 | 
				
			||||||
 | 
					 		    err = futex_reltimed_wait_cancelable
 | 
				
			||||||
 | 
					-			(cond->__data.__g_signals + g, 0, &rt, private);
 | 
				
			||||||
 | 
					+			(cond->__data.__g_signals + g, signals, &rt, private);
 | 
				
			||||||
 | 
					 		}
 | 
				
			||||||
 | 
					 	      else
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 		  /* Use CLOCK_REALTIME.  */
 | 
				
			||||||
 | 
					 		  err = futex_abstimed_wait_cancelable
 | 
				
			||||||
 | 
					-		      (cond->__data.__g_signals + g, 0, abstime, private);
 | 
				
			||||||
 | 
					+		      (cond->__data.__g_signals + g, signals, abstime, private);
 | 
				
			||||||
 | 
					 		}
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -562,6 +571,8 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	  signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+       if (seq < (__condvar_load_g1_start_relaxed (cond) >> 1))
 | 
				
			||||||
 | 
					+	 goto done;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					   /* Try to grab a signal.  Use acquire MO so that we see an up-to-date value
 | 
				
			||||||
 | 
					      of __g1_start below (see spinning above for a similar case).  In
 | 
				
			||||||
 | 
					@@ -570,69 +581,6 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					   while (!atomic_compare_exchange_weak_acquire (cond->__data.__g_signals + g,
 | 
				
			||||||
 | 
					 						&signals, signals - 2));
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* We consumed a signal but we could have consumed from a more recent group
 | 
				
			||||||
 | 
					-     that aliased with ours due to being in the same group slot.  If this
 | 
				
			||||||
 | 
					-     might be the case our group must be closed as visible through
 | 
				
			||||||
 | 
					-     __g1_start.  */
 | 
				
			||||||
 | 
					-  uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-  if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					-      /* We potentially stole a signal from a more recent group but we do not
 | 
				
			||||||
 | 
					-	 know which group we really consumed from.
 | 
				
			||||||
 | 
					-	 We do not care about groups older than current G1 because they are
 | 
				
			||||||
 | 
					-	 closed; we could have stolen from these, but then we just add a
 | 
				
			||||||
 | 
					-	 spurious wake-up for the current groups.
 | 
				
			||||||
 | 
					-	 We will never steal a signal from current G2 that was really intended
 | 
				
			||||||
 | 
					-	 for G2 because G2 never receives signals (until it becomes G1).  We
 | 
				
			||||||
 | 
					-	 could have stolen a signal from G2 that was conservatively added by a
 | 
				
			||||||
 | 
					-	 previous waiter that also thought it stole a signal -- but given that
 | 
				
			||||||
 | 
					-	 that signal was added unnecessarily, it's not a problem if we steal
 | 
				
			||||||
 | 
					-	 it.
 | 
				
			||||||
 | 
					-	 Thus, the remaining case is that we could have stolen from the current
 | 
				
			||||||
 | 
					-	 G1, where "current" means the __g1_start value we observed.  However,
 | 
				
			||||||
 | 
					-	 if the current G1 does not have the same slot index as we do, we did
 | 
				
			||||||
 | 
					-	 not steal from it and do not need to undo that.  This is the reason
 | 
				
			||||||
 | 
					-	 for putting a bit with G2's index into__g1_start as well.  */
 | 
				
			||||||
 | 
					-      if (((g1_start & 1) ^ 1) == g)
 | 
				
			||||||
 | 
					-	{
 | 
				
			||||||
 | 
					-	  /* We have to conservatively undo our potential mistake of stealing
 | 
				
			||||||
 | 
					-	     a signal.  We can stop trying to do that when the current G1
 | 
				
			||||||
 | 
					-	     changes because other spinning waiters will notice this too and
 | 
				
			||||||
 | 
					-	     __condvar_quiesce_and_switch_g1 has checked that there are no
 | 
				
			||||||
 | 
					-	     futex waiters anymore before switching G1.
 | 
				
			||||||
 | 
					-	     Relaxed MO is fine for the __g1_start load because we need to
 | 
				
			||||||
 | 
					-	     merely be able to observe this fact and not have to observe
 | 
				
			||||||
 | 
					-	     something else as well.
 | 
				
			||||||
 | 
					-	     ??? Would it help to spin for a little while to see whether the
 | 
				
			||||||
 | 
					-	     current G1 gets closed?  This might be worthwhile if the group is
 | 
				
			||||||
 | 
					-	     small or close to being closed.  */
 | 
				
			||||||
 | 
					-	  unsigned int s = atomic_load_relaxed (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					-	  while (__condvar_load_g1_start_relaxed (cond) == g1_start)
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      /* Try to add a signal.  We don't need to acquire the lock
 | 
				
			||||||
 | 
					-		 because at worst we can cause a spurious wake-up.  If the
 | 
				
			||||||
 | 
					-		 group is in the process of being closed (LSB is true), this
 | 
				
			||||||
 | 
					-		 has an effect similar to us adding a signal.  */
 | 
				
			||||||
 | 
					-	      if (((s & 1) != 0)
 | 
				
			||||||
 | 
					-		  || atomic_compare_exchange_weak_relaxed
 | 
				
			||||||
 | 
					-		       (cond->__data.__g_signals + g, &s, s + 2))
 | 
				
			||||||
 | 
					-		{
 | 
				
			||||||
 | 
					-		  /* If we added a signal, we also need to add a wake-up on
 | 
				
			||||||
 | 
					-		     the futex.  We also need to do that if we skipped adding
 | 
				
			||||||
 | 
					-		     a signal because the group is being closed because
 | 
				
			||||||
 | 
					-		     while __condvar_quiesce_and_switch_g1 could have closed
 | 
				
			||||||
 | 
					-		     the group, it might stil be waiting for futex waiters to
 | 
				
			||||||
 | 
					-		     leave (and one of those waiters might be the one we stole
 | 
				
			||||||
 | 
					-		     the signal from, which cause it to block using the
 | 
				
			||||||
 | 
					-		     futex).  */
 | 
				
			||||||
 | 
					-		  futex_wake (cond->__data.__g_signals + g, 1, private);
 | 
				
			||||||
 | 
					-		  break;
 | 
				
			||||||
 | 
					-		}
 | 
				
			||||||
 | 
					-	      /* TODO Back off.  */
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  done:
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* Confirm that we have been woken.  We do that before acquiring the mutex
 | 
				
			||||||
							
								
								
									
										39
									
								
								SOURCES/glibc-RHEL-8381-10.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								SOURCES/glibc-RHEL-8381-10.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					Partial revert of commit c36fc50781995e6758cae2b6927839d0157f213c
 | 
				
			||||||
 | 
					to restore the layout of pthread_cond_t and avoid a downstream
 | 
				
			||||||
 | 
					rpminspect and abidiff (libabigail tooling) spurious warning
 | 
				
			||||||
 | 
					about internal ABI changes.  Without this change all RHEL developers
 | 
				
			||||||
 | 
					using pthread_cond_t would have to audit and waive the warning.
 | 
				
			||||||
 | 
					The alternative is to update the supression lists used in abidiff,
 | 
				
			||||||
 | 
					propagate that to the rpminspect service, and wait for that to
 | 
				
			||||||
 | 
					complete before doing the update. The more conservative position
 | 
				
			||||||
 | 
					is the partial revert of the layout change.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This is a downstream-only change and is not required upstream.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sysdeps/nptl/bits/thread-shared-types.h b/sysdeps/nptl/bits/thread-shared-types.h
 | 
				
			||||||
 | 
					index dcb799b130178f3f..798e0de31680065b 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/nptl/bits/thread-shared-types.h
 | 
				
			||||||
 | 
					+++ b/sysdeps/nptl/bits/thread-shared-types.h
 | 
				
			||||||
 | 
					@@ -188,7 +188,8 @@ struct __pthread_cond_s
 | 
				
			||||||
 | 
					       unsigned int __high;
 | 
				
			||||||
 | 
					     } __g1_start32;
 | 
				
			||||||
 | 
					   };
 | 
				
			||||||
 | 
					-  unsigned int __g_size[2] __LOCK_ALIGNMENT;
 | 
				
			||||||
 | 
					+  unsigned int __glibc_unused___g_refs[2] __LOCK_ALIGNMENT;
 | 
				
			||||||
 | 
					+  unsigned int __g_size[2];
 | 
				
			||||||
 | 
					   unsigned int __g1_orig_size;
 | 
				
			||||||
 | 
					   unsigned int __wrefs;
 | 
				
			||||||
 | 
					   unsigned int __g_signals[2];
 | 
				
			||||||
 | 
					diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
 | 
				
			||||||
 | 
					index 4f7adccdab1d6e9e..df049abf74d47522 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/nptl/pthread.h
 | 
				
			||||||
 | 
					+++ b/sysdeps/nptl/pthread.h
 | 
				
			||||||
 | 
					@@ -184,7 +184,7 @@ enum
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Conditional variable handling.  */
 | 
				
			||||||
 | 
					-#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, 0, 0, {0, 0} } }
 | 
				
			||||||
 | 
					+#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Cleanup buffers */
 | 
				
			||||||
							
								
								
									
										133
									
								
								SOURCES/glibc-RHEL-8381-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								SOURCES/glibc-RHEL-8381-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,133 @@
 | 
				
			|||||||
 | 
					commit 0cc973160c23bb67f895bc887dd6942d29f8fee3
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 07:55:22 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: Update comments and indentation for new condvar implementation
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Some comments were wrong after the most recent commit. This fixes that.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Also fixing indentation where it was using spaces instead of tabs.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					index 9175e6779ebff244..36ec30a103390b3e 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					@@ -361,8 +361,9 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					      * New waiters arriving concurrently with the group switching will all go
 | 
				
			||||||
 | 
					        into G2 until we atomically make the switch.  Waiters existing in G2
 | 
				
			||||||
 | 
					        are not affected.
 | 
				
			||||||
 | 
					-     * Waiters in G1 will be closed out immediately by the advancing of
 | 
				
			||||||
 | 
					-       __g_signals to the next "lowseq" (low 31 bits of the new g1_start),
 | 
				
			||||||
 | 
					+     * Waiters in G1 have already received a signal and been woken. If they
 | 
				
			||||||
 | 
					+       haven't woken yet, they will be closed out immediately by the advancing
 | 
				
			||||||
 | 
					+       of __g_signals to the next "lowseq" (low 31 bits of the new g1_start),
 | 
				
			||||||
 | 
					        which will prevent waiters from blocking using a futex on
 | 
				
			||||||
 | 
					        __g_signals since it provides enough signals for all possible
 | 
				
			||||||
 | 
					        remaining waiters.  As a result, they can each consume a signal
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index 4fb22b28a7a20ecd..2964c2d1be046b8a 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -250,7 +250,7 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					    figure out whether they are in a group that has already been completely
 | 
				
			||||||
 | 
					    signaled (i.e., if the current G1 starts at a later position that the
 | 
				
			||||||
 | 
					    waiter's position).  Waiters cannot determine whether they are currently
 | 
				
			||||||
 | 
					-   in G2 or G1 -- but they do not have too because all they are interested in
 | 
				
			||||||
 | 
					+   in G2 or G1 -- but they do not have to because all they are interested in
 | 
				
			||||||
 | 
					    is whether there are available signals, and they always start in G2 (whose
 | 
				
			||||||
 | 
					    group slot they know because of the bit in the waiter sequence.  Signalers
 | 
				
			||||||
 | 
					    will simply fill the right group until it is completely signaled and can
 | 
				
			||||||
 | 
					@@ -408,7 +408,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* Now wait until a signal is available in our group or it is closed.
 | 
				
			||||||
 | 
					-     Acquire MO so that if we observe a value of zero written after group
 | 
				
			||||||
 | 
					+     Acquire MO so that if we observe (signals == lowseq) after group
 | 
				
			||||||
 | 
					      switching in __condvar_quiesce_and_switch_g1, we synchronize with that
 | 
				
			||||||
 | 
					      store and will see the prior update of __g1_start done while switching
 | 
				
			||||||
 | 
					      groups too.  */
 | 
				
			||||||
 | 
					@@ -418,8 +418,8 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       while (1)
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					-          uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-          unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					+	  uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+	  unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  /* Spin-wait first.
 | 
				
			||||||
 | 
					 	     Note that spinning first without checking whether a timeout
 | 
				
			||||||
 | 
					@@ -443,21 +443,21 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	      /* Reload signals.  See above for MO.  */
 | 
				
			||||||
 | 
					 	      signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					-              g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-              lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					+	      g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+	      lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					 	      spin--;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-          if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					+	  if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					-              /* If the group is closed already,
 | 
				
			||||||
 | 
					+	      /* If the group is closed already,
 | 
				
			||||||
 | 
					 	         then this waiter originally had enough extra signals to
 | 
				
			||||||
 | 
					 	         consume, up until the time its group was closed.  */
 | 
				
			||||||
 | 
					 	       goto done;
 | 
				
			||||||
 | 
					-            }
 | 
				
			||||||
 | 
					+	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  /* If there is an available signal, don't block.
 | 
				
			||||||
 | 
					-             If __g1_start has advanced at all, then we must be in G1
 | 
				
			||||||
 | 
					+	     If __g1_start has advanced at all, then we must be in G1
 | 
				
			||||||
 | 
					 	     by now, perhaps in the process of switching back to an older
 | 
				
			||||||
 | 
					 	     G2, but in either case we're allowed to consume the available
 | 
				
			||||||
 | 
					 	     signal and should not block anymore.  */
 | 
				
			||||||
 | 
					@@ -479,22 +479,23 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	     sequence.  */
 | 
				
			||||||
 | 
					 	  atomic_fetch_add_acquire (cond->__data.__g_refs + g, 2);
 | 
				
			||||||
 | 
					 	  signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					-          g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-          lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					+	  g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+	  lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-          if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					+	  if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					-              /* group is closed already, so don't block */
 | 
				
			||||||
 | 
					+	      /* group is closed already, so don't block */
 | 
				
			||||||
 | 
					 	      __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					 	      goto done;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					-	      /* a signal showed up or G1/G2 switched after we grabbed the refcount */
 | 
				
			||||||
 | 
					+	      /* a signal showed up or G1/G2 switched after we grabbed the
 | 
				
			||||||
 | 
					+	         refcount */
 | 
				
			||||||
 | 
					 	      __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					 	      break;
 | 
				
			||||||
 | 
					-            }
 | 
				
			||||||
 | 
					+	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  // Now block.
 | 
				
			||||||
 | 
					 	  struct _pthread_cleanup_buffer buffer;
 | 
				
			||||||
 | 
					@@ -574,10 +575,8 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					        if (seq < (__condvar_load_g1_start_relaxed (cond) >> 1))
 | 
				
			||||||
 | 
					 	 goto done;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					-  /* Try to grab a signal.  Use acquire MO so that we see an up-to-date value
 | 
				
			||||||
 | 
					-     of __g1_start below (see spinning above for a similar case).  In
 | 
				
			||||||
 | 
					-     particular, if we steal from a more recent group, we will also see a
 | 
				
			||||||
 | 
					-     more recent __g1_start below.  */
 | 
				
			||||||
 | 
					+  /* Try to grab a signal.  See above for MO.  (if we do another loop
 | 
				
			||||||
 | 
					+     iteration we need to see the correct value of g1_start)  */
 | 
				
			||||||
 | 
					   while (!atomic_compare_exchange_weak_acquire (cond->__data.__g_signals + g,
 | 
				
			||||||
 | 
					 						&signals, signals - 2));
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
							
								
								
									
										67
									
								
								SOURCES/glibc-RHEL-8381-3.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								SOURCES/glibc-RHEL-8381-3.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,67 @@
 | 
				
			|||||||
 | 
					commit b42cc6af11062c260c7dfa91f1c89891366fed3e
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 07:55:50 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: Remove unnecessary catch-all-wake in condvar group switch
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This wake is unnecessary. We only switch groups after every sleeper in a group
 | 
				
			||||||
 | 
					    has been woken. Sure, they may take a while to actually wake up and may still
 | 
				
			||||||
 | 
					    hold a reference, but waking them a second time doesn't speed that up. Instead
 | 
				
			||||||
 | 
					    this just makes the code more complicated and may hide problems.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    In particular this safety wake wouldn't even have helped with the bug that was
 | 
				
			||||||
 | 
					    fixed by Barrus' patch: The bug there was that pthread_cond_signal would not
 | 
				
			||||||
 | 
					    switch g1 when it should, so we wouldn't even have entered this code path.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					index 36ec30a103390b3e..f6d8c72b7f30ecff 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					@@ -361,13 +361,7 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					      * New waiters arriving concurrently with the group switching will all go
 | 
				
			||||||
 | 
					        into G2 until we atomically make the switch.  Waiters existing in G2
 | 
				
			||||||
 | 
					        are not affected.
 | 
				
			||||||
 | 
					-     * Waiters in G1 have already received a signal and been woken. If they
 | 
				
			||||||
 | 
					-       haven't woken yet, they will be closed out immediately by the advancing
 | 
				
			||||||
 | 
					-       of __g_signals to the next "lowseq" (low 31 bits of the new g1_start),
 | 
				
			||||||
 | 
					-       which will prevent waiters from blocking using a futex on
 | 
				
			||||||
 | 
					-       __g_signals since it provides enough signals for all possible
 | 
				
			||||||
 | 
					-       remaining waiters.  As a result, they can each consume a signal
 | 
				
			||||||
 | 
					-       and they will eventually remove their group reference.  */
 | 
				
			||||||
 | 
					+     * Waiters in G1 have already received a signal and been woken.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* Update __g1_start, which finishes closing this group.  The value we add
 | 
				
			||||||
 | 
					      will never be negative because old_orig_size can only be zero when we
 | 
				
			||||||
 | 
					@@ -380,29 +374,6 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   unsigned int lowseq = ((old_g1_start + old_orig_size) << 1) & ~1U;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* If any waiters still hold group references (and thus could be blocked),
 | 
				
			||||||
 | 
					-     then wake them all up now and prevent any running ones from blocking.
 | 
				
			||||||
 | 
					-     This is effectively a catch-all for any possible current or future
 | 
				
			||||||
 | 
					-     bugs that can allow the group size to reach 0 before all G1 waiters
 | 
				
			||||||
 | 
					-     have been awakened or at least given signals to consume, or any
 | 
				
			||||||
 | 
					-     other case that can leave blocked (or about to block) older waiters..  */
 | 
				
			||||||
 | 
					-  if ((atomic_fetch_or_release (cond->__data.__g_refs + g1, 0) >> 1) > 0)
 | 
				
			||||||
 | 
					-   {
 | 
				
			||||||
 | 
					-    /* First advance signals to the end of the group (i.e. enough signals
 | 
				
			||||||
 | 
					-       for the entire G1 group) to ensure that waiters which have not
 | 
				
			||||||
 | 
					-       yet blocked in the futex will not block.
 | 
				
			||||||
 | 
					-       Note that in the vast majority of cases, this should never
 | 
				
			||||||
 | 
					-       actually be necessary, since __g_signals will have enough
 | 
				
			||||||
 | 
					-       signals for the remaining g_refs waiters.  As an optimization,
 | 
				
			||||||
 | 
					-       we could check this first before proceeding, although that
 | 
				
			||||||
 | 
					-       could still leave the potential for futex lost wakeup bugs
 | 
				
			||||||
 | 
					-       if the signal count was non-zero but the futex wakeup
 | 
				
			||||||
 | 
					-       was somehow lost.  */
 | 
				
			||||||
 | 
					-    atomic_store_release (cond->__data.__g_signals + g1, lowseq);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-    futex_wake (cond->__data.__g_signals + g1, INT_MAX, private);
 | 
				
			||||||
 | 
					-   }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					   /* At this point, the old G1 is now a valid new G2 (but not in use yet).
 | 
				
			||||||
 | 
					      No old waiter can neither grab a signal nor acquire a reference without
 | 
				
			||||||
 | 
					      noticing that __g1_start is larger.
 | 
				
			||||||
							
								
								
									
										107
									
								
								SOURCES/glibc-RHEL-8381-4.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								SOURCES/glibc-RHEL-8381-4.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,107 @@
 | 
				
			|||||||
 | 
					commit 4f7b051f8ee3feff1b53b27a906f245afaa9cee1
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 07:56:13 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: Remove unnecessary quadruple check in pthread_cond_wait
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    pthread_cond_wait was checking whether it was in a closed group no less than
 | 
				
			||||||
 | 
					    four times. Checking once is enough. Here are the four checks:
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    1. While spin-waiting. This was dead code: maxspin is set to 0 and has been
 | 
				
			||||||
 | 
					       for years.
 | 
				
			||||||
 | 
					    2. Before deciding to go to sleep, and before incrementing grefs: I kept this
 | 
				
			||||||
 | 
					    3. After incrementing grefs. There is no reason to think that the group would
 | 
				
			||||||
 | 
					       close while we do an atomic increment. Obviously it could close at any
 | 
				
			||||||
 | 
					       point, but that doesn't mean we have to recheck after every step. This
 | 
				
			||||||
 | 
					       check was equally good as check 2, except it has to do more work.
 | 
				
			||||||
 | 
					    4. When we find ourselves in a group that has a signal. We only get here after
 | 
				
			||||||
 | 
					       we check that we're not in a closed group. There is no need to check again.
 | 
				
			||||||
 | 
					       The check would only have helped in cases where the compare_exchange in the
 | 
				
			||||||
 | 
					       next line would also have failed. Relying on the compare_exchange is fine.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Removing the duplicate checks clarifies the code.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index 2964c2d1be046b8a..8358784867f6074a 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -367,7 +367,6 @@ static __always_inline int
 | 
				
			||||||
 | 
					 __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					     const struct timespec *abstime)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-  const int maxspin = 0;
 | 
				
			||||||
 | 
					   int err;
 | 
				
			||||||
 | 
					   int result = 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -421,33 +420,6 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	  uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					 	  unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	  /* Spin-wait first.
 | 
				
			||||||
 | 
					-	     Note that spinning first without checking whether a timeout
 | 
				
			||||||
 | 
					-	     passed might lead to what looks like a spurious wake-up even
 | 
				
			||||||
 | 
					-	     though we should return ETIMEDOUT (e.g., if the caller provides
 | 
				
			||||||
 | 
					-	     an absolute timeout that is clearly in the past).  However,
 | 
				
			||||||
 | 
					-	     (1) spurious wake-ups are allowed, (2) it seems unlikely that a
 | 
				
			||||||
 | 
					-	     user will (ab)use pthread_cond_wait as a check for whether a
 | 
				
			||||||
 | 
					-	     point in time is in the past, and (3) spinning first without
 | 
				
			||||||
 | 
					-	     having to compare against the current time seems to be the right
 | 
				
			||||||
 | 
					-	     choice from a performance perspective for most use cases.  */
 | 
				
			||||||
 | 
					-	  unsigned int spin = maxspin;
 | 
				
			||||||
 | 
					-	  while (spin > 0 && ((int)(signals - lowseq) < 2))
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      /* Check that we are not spinning on a group that's already
 | 
				
			||||||
 | 
					-		 closed.  */
 | 
				
			||||||
 | 
					-	      if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					-		break;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	      /* TODO Back off.  */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	      /* Reload signals.  See above for MO.  */
 | 
				
			||||||
 | 
					-	      signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					-	      g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-	      lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					-	      spin--;
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	  if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					 	      /* If the group is closed already,
 | 
				
			||||||
 | 
					@@ -478,24 +450,6 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	     an atomic read-modify-write operation and thus extend the release
 | 
				
			||||||
 | 
					 	     sequence.  */
 | 
				
			||||||
 | 
					 	  atomic_fetch_add_acquire (cond->__data.__g_refs + g, 2);
 | 
				
			||||||
 | 
					-	  signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					-	  g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-	  lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      /* group is closed already, so don't block */
 | 
				
			||||||
 | 
					-	      __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					-	      goto done;
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      /* a signal showed up or G1/G2 switched after we grabbed the
 | 
				
			||||||
 | 
					-	         refcount */
 | 
				
			||||||
 | 
					-	      __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					-	      break;
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  // Now block.
 | 
				
			||||||
 | 
					 	  struct _pthread_cleanup_buffer buffer;
 | 
				
			||||||
 | 
					@@ -571,9 +525,6 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	  /* Reload signals.  See above for MO.  */
 | 
				
			||||||
 | 
					 	  signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-       if (seq < (__condvar_load_g1_start_relaxed (cond) >> 1))
 | 
				
			||||||
 | 
					-	 goto done;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					   /* Try to grab a signal.  See above for MO.  (if we do another loop
 | 
				
			||||||
 | 
					      iteration we need to see the correct value of g1_start)  */
 | 
				
			||||||
							
								
								
									
										172
									
								
								SOURCES/glibc-RHEL-8381-5.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								SOURCES/glibc-RHEL-8381-5.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,172 @@
 | 
				
			|||||||
 | 
					commit c36fc50781995e6758cae2b6927839d0157f213c
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 07:56:38 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: Remove g_refs from condition variables
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This variable used to be needed to wait in group switching until all sleepers
 | 
				
			||||||
 | 
					    have confirmed that they have woken. This is no longer needed. Nothing waits
 | 
				
			||||||
 | 
					    on this variable so there is no need to track how many threads are currently
 | 
				
			||||||
 | 
					    asleep in each group.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Conflicts:
 | 
				
			||||||
 | 
					#	nptl/tst-cond22.c (64-bit atomic counter refactor missing)
 | 
				
			||||||
 | 
					#	sysdeps/nptl/bits/thread-shared-types.h (Likewise)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index 8358784867f6074a..b2bf3bd0a7af43e8 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -144,23 +144,6 @@ __condvar_cancel_waiting (pthread_cond_t *cond, uint64_t seq, unsigned int g,
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-/* Wake up any signalers that might be waiting.  */
 | 
				
			||||||
 | 
					-static void
 | 
				
			||||||
 | 
					-__condvar_dec_grefs (pthread_cond_t *cond, unsigned int g, int private)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-  /* Release MO to synchronize-with the acquire load in
 | 
				
			||||||
 | 
					-     __condvar_quiesce_and_switch_g1.  */
 | 
				
			||||||
 | 
					-  if (atomic_fetch_add_release (cond->__data.__g_refs + g, -2) == 3)
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					-      /* Clear the wake-up request flag before waking up.  We do not need more
 | 
				
			||||||
 | 
					-	 than relaxed MO and it doesn't matter if we apply this for an aliased
 | 
				
			||||||
 | 
					-	 group because we wake all futex waiters right after clearing the
 | 
				
			||||||
 | 
					-	 flag.  */
 | 
				
			||||||
 | 
					-      atomic_fetch_and_relaxed (cond->__data.__g_refs + g, ~(unsigned int) 1);
 | 
				
			||||||
 | 
					-      futex_wake (cond->__data.__g_refs + g, INT_MAX, private);
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 /* Clean-up for cancellation of waiters waiting for normal signals.  We cancel
 | 
				
			||||||
 | 
					    our registration as a waiter, confirm we have woken up, and re-acquire the
 | 
				
			||||||
 | 
					    mutex.  */
 | 
				
			||||||
 | 
					@@ -172,8 +155,6 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					   pthread_cond_t *cond = cbuffer->cond;
 | 
				
			||||||
 | 
					   unsigned g = cbuffer->wseq & 1;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  __condvar_dec_grefs (cond, g, cbuffer->private);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					   __condvar_cancel_waiting (cond, cbuffer->wseq >> 1, g, cbuffer->private);
 | 
				
			||||||
 | 
					   /* FIXME With the current cancellation implementation, it is possible that
 | 
				
			||||||
 | 
					      a thread is cancelled after it has returned from a syscall.  This could
 | 
				
			||||||
 | 
					@@ -328,15 +309,6 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					    sufficient because if a waiter can see a sufficiently large value, it could
 | 
				
			||||||
 | 
					    have also consume a signal in the waiters group.
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-   It is essential that the last field in pthread_cond_t is __g_signals[1]:
 | 
				
			||||||
 | 
					-   The previous condvar used a pointer-sized field in pthread_cond_t, so a
 | 
				
			||||||
 | 
					-   PTHREAD_COND_INITIALIZER from that condvar implementation might only
 | 
				
			||||||
 | 
					-   initialize 4 bytes to zero instead of the 8 bytes we need (i.e., 44 bytes
 | 
				
			||||||
 | 
					-   in total instead of the 48 we need).  __g_signals[1] is not accessed before
 | 
				
			||||||
 | 
					-   the first group switch (G2 starts at index 0), which will set its value to
 | 
				
			||||||
 | 
					-   zero after a harmless fetch-or whose return value is ignored.  This
 | 
				
			||||||
 | 
					-   effectively completes initialization.
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					    Limitations:
 | 
				
			||||||
 | 
					    * This condvar isn't designed to allow for more than
 | 
				
			||||||
 | 
					@@ -436,21 +408,6 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	  if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					 	    break;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	  /* No signals available after spinning, so prepare to block.
 | 
				
			||||||
 | 
					-	     We first acquire a group reference and use acquire MO for that so
 | 
				
			||||||
 | 
					-	     that we synchronize with the dummy read-modify-write in
 | 
				
			||||||
 | 
					-	     __condvar_quiesce_and_switch_g1 if we read from that.  In turn,
 | 
				
			||||||
 | 
					-	     in this case this will make us see the advancement of __g_signals
 | 
				
			||||||
 | 
					-	     to the upcoming new g1_start that occurs with a concurrent
 | 
				
			||||||
 | 
					-	     attempt to reuse the group's slot.
 | 
				
			||||||
 | 
					-	     We use acquire MO for the __g_signals check to make the
 | 
				
			||||||
 | 
					-	     __g1_start check work (see spinning above).
 | 
				
			||||||
 | 
					-	     Note that the group reference acquisition will not mask the
 | 
				
			||||||
 | 
					-	     release MO when decrementing the reference count because we use
 | 
				
			||||||
 | 
					-	     an atomic read-modify-write operation and thus extend the release
 | 
				
			||||||
 | 
					-	     sequence.  */
 | 
				
			||||||
 | 
					-	  atomic_fetch_add_acquire (cond->__data.__g_refs + g, 2);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	  // Now block.
 | 
				
			||||||
 | 
					 	  struct _pthread_cleanup_buffer buffer;
 | 
				
			||||||
 | 
					 	  struct _condvar_cleanup_buffer cbuffer;
 | 
				
			||||||
 | 
					@@ -509,18 +466,11 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  if (__glibc_unlikely (err == ETIMEDOUT))
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					-	      __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					-	      /* If we timed out, we effectively cancel waiting.  Note that
 | 
				
			||||||
 | 
					-		 we have decremented __g_refs before cancellation, so that a
 | 
				
			||||||
 | 
					-		 deadlock between waiting for quiescence of our group in
 | 
				
			||||||
 | 
					-		 __condvar_quiesce_and_switch_g1 and us trying to acquire
 | 
				
			||||||
 | 
					-		 the lock during cancellation is not possible.  */
 | 
				
			||||||
 | 
					+	      /* If we timed out, we effectively cancel waiting.  */
 | 
				
			||||||
 | 
					 	      __condvar_cancel_waiting (cond, seq, g, private);
 | 
				
			||||||
 | 
					 	      result = ETIMEDOUT;
 | 
				
			||||||
 | 
					 	      goto done;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					-	  else
 | 
				
			||||||
 | 
					-	    __condvar_dec_grefs (cond, g, private);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  /* Reload signals.  See above for MO.  */
 | 
				
			||||||
 | 
					 	  signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					diff --git a/nptl/tst-cond22.c b/nptl/tst-cond22.c
 | 
				
			||||||
 | 
					index 64f19ea0a55af057..ebeeeaf666070076 100644
 | 
				
			||||||
 | 
					--- a/nptl/tst-cond22.c
 | 
				
			||||||
 | 
					+++ b/nptl/tst-cond22.c
 | 
				
			||||||
 | 
					@@ -106,10 +106,10 @@ do_test (void)
 | 
				
			||||||
 | 
					       status = 1;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  printf ("cond = { %llu, %llu, %u/%u/%u, %u/%u/%u, %u, %u }\n",
 | 
				
			||||||
 | 
					+  printf ("cond = { %llu, %llu, %u/%u, %u/%u, %u, %u }\n",
 | 
				
			||||||
 | 
					 	  c.__data.__wseq, c.__data.__g1_start,
 | 
				
			||||||
 | 
					-	  c.__data.__g_signals[0], c.__data.__g_refs[0], c.__data.__g_size[0],
 | 
				
			||||||
 | 
					-	  c.__data.__g_signals[1], c.__data.__g_refs[1], c.__data.__g_size[1],
 | 
				
			||||||
 | 
					+	  c.__data.__g_signals[0], c.__data.__g_size[0],
 | 
				
			||||||
 | 
					+	  c.__data.__g_signals[1], c.__data.__g_size[1],
 | 
				
			||||||
 | 
					 	  c.__data.__g1_orig_size, c.__data.__wrefs);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   if (pthread_create (&th, NULL, tf, (void *) 1l) != 0)
 | 
				
			||||||
 | 
					@@ -149,10 +149,10 @@ do_test (void)
 | 
				
			||||||
 | 
					       status = 1;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  printf ("cond = { %llu, %llu, %u/%u/%u, %u/%u/%u, %u, %u }\n",
 | 
				
			||||||
 | 
					+  printf ("cond = { %llu, %llu, %u/%u, %u/%u, %u, %u }\n",
 | 
				
			||||||
 | 
					 	  c.__data.__wseq, c.__data.__g1_start,
 | 
				
			||||||
 | 
					-	  c.__data.__g_signals[0], c.__data.__g_refs[0], c.__data.__g_size[0],
 | 
				
			||||||
 | 
					-	  c.__data.__g_signals[1], c.__data.__g_refs[1], c.__data.__g_size[1],
 | 
				
			||||||
 | 
					+	  c.__data.__g_signals[0], c.__data.__g_size[0],
 | 
				
			||||||
 | 
					+	  c.__data.__g_signals[1], c.__data.__g_size[1],
 | 
				
			||||||
 | 
					 	  c.__data.__g1_orig_size, c.__data.__wrefs);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   return status;
 | 
				
			||||||
 | 
					diff --git a/sysdeps/nptl/bits/thread-shared-types.h b/sysdeps/nptl/bits/thread-shared-types.h
 | 
				
			||||||
 | 
					index 05c94e7a710c0eb9..dcb799b130178f3f 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/nptl/bits/thread-shared-types.h
 | 
				
			||||||
 | 
					+++ b/sysdeps/nptl/bits/thread-shared-types.h
 | 
				
			||||||
 | 
					@@ -188,8 +188,7 @@ struct __pthread_cond_s
 | 
				
			||||||
 | 
					       unsigned int __high;
 | 
				
			||||||
 | 
					     } __g1_start32;
 | 
				
			||||||
 | 
					   };
 | 
				
			||||||
 | 
					-  unsigned int __g_refs[2] __LOCK_ALIGNMENT;
 | 
				
			||||||
 | 
					-  unsigned int __g_size[2];
 | 
				
			||||||
 | 
					+  unsigned int __g_size[2] __LOCK_ALIGNMENT;
 | 
				
			||||||
 | 
					   unsigned int __g1_orig_size;
 | 
				
			||||||
 | 
					   unsigned int __wrefs;
 | 
				
			||||||
 | 
					   unsigned int __g_signals[2];
 | 
				
			||||||
 | 
					diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
 | 
				
			||||||
 | 
					index df049abf74d47522..4f7adccdab1d6e9e 100644
 | 
				
			||||||
 | 
					--- a/sysdeps/nptl/pthread.h
 | 
				
			||||||
 | 
					+++ b/sysdeps/nptl/pthread.h
 | 
				
			||||||
 | 
					@@ -184,7 +184,7 @@ enum
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Conditional variable handling.  */
 | 
				
			||||||
 | 
					-#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }
 | 
				
			||||||
 | 
					+#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, 0, 0, {0, 0} } }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Cleanup buffers */
 | 
				
			||||||
							
								
								
									
										94
									
								
								SOURCES/glibc-RHEL-8381-6.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								SOURCES/glibc-RHEL-8381-6.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,94 @@
 | 
				
			|||||||
 | 
					commit 929a4764ac90382616b6a21f099192b2475da674
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 08:03:44 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: Use a single loop in pthread_cond_wait instaed of a nested loop
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The loop was a little more complicated than necessary. There was only one
 | 
				
			||||||
 | 
					    break statement out of the inner loop, and the outer loop was nearly empty.
 | 
				
			||||||
 | 
					    So just remove the outer loop, moving its code to the one break statement in
 | 
				
			||||||
 | 
					    the inner loop. This allows us to replace all gotos with break statements.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Conflicts:
 | 
				
			||||||
 | 
					#	nptl/pthread_cond_wait.c (Missing EOVERFLOW checks for y2038)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index b2bf3bd0a7af43e8..8f12fc4ee288cf4a 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -378,17 +378,15 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					       return err;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* Now wait until a signal is available in our group or it is closed.
 | 
				
			||||||
 | 
					-     Acquire MO so that if we observe (signals == lowseq) after group
 | 
				
			||||||
 | 
					-     switching in __condvar_quiesce_and_switch_g1, we synchronize with that
 | 
				
			||||||
 | 
					-     store and will see the prior update of __g1_start done while switching
 | 
				
			||||||
 | 
					-     groups too.  */
 | 
				
			||||||
 | 
					-  unsigned int signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  do
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					       while (1)
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					+	  /* Now wait until a signal is available in our group or it is closed.
 | 
				
			||||||
 | 
					+	     Acquire MO so that if we observe (signals == lowseq) after group
 | 
				
			||||||
 | 
					+	     switching in __condvar_quiesce_and_switch_g1, we synchronize with that
 | 
				
			||||||
 | 
					+	     store and will see the prior update of __g1_start done while switching
 | 
				
			||||||
 | 
					+	     groups too.  */
 | 
				
			||||||
 | 
					+	  unsigned int signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					 	  uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					 	  unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -397,7 +395,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	      /* If the group is closed already,
 | 
				
			||||||
 | 
					 	         then this waiter originally had enough extra signals to
 | 
				
			||||||
 | 
					 	         consume, up until the time its group was closed.  */
 | 
				
			||||||
 | 
					-	       goto done;
 | 
				
			||||||
 | 
					+	       break;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  /* If there is an available signal, don't block.
 | 
				
			||||||
 | 
					@@ -406,7 +404,16 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	     G2, but in either case we're allowed to consume the available
 | 
				
			||||||
 | 
					 	     signal and should not block anymore.  */
 | 
				
			||||||
 | 
					 	  if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					-	    break;
 | 
				
			||||||
 | 
					+	    {
 | 
				
			||||||
 | 
					+	      /* Try to grab a signal.  See above for MO.  (if we do another loop
 | 
				
			||||||
 | 
					+		 iteration we need to see the correct value of g1_start)  */
 | 
				
			||||||
 | 
					+		      if (atomic_compare_exchange_weak_acquire (
 | 
				
			||||||
 | 
					+		      		cond->__data.__g_signals + g,
 | 
				
			||||||
 | 
					+			&signals, signals - 2))
 | 
				
			||||||
 | 
					+		      	break;
 | 
				
			||||||
 | 
					+		      else
 | 
				
			||||||
 | 
					+		      	continue;
 | 
				
			||||||
 | 
					+	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  // Now block.
 | 
				
			||||||
 | 
					 	  struct _pthread_cleanup_buffer buffer;
 | 
				
			||||||
 | 
					@@ -469,19 +476,9 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					 	      /* If we timed out, we effectively cancel waiting.  */
 | 
				
			||||||
 | 
					 	      __condvar_cancel_waiting (cond, seq, g, private);
 | 
				
			||||||
 | 
					 	      result = ETIMEDOUT;
 | 
				
			||||||
 | 
					-	      goto done;
 | 
				
			||||||
 | 
					+	      break;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  /* Reload signals.  See above for MO.  */
 | 
				
			||||||
 | 
					-	  signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					-  /* Try to grab a signal.  See above for MO.  (if we do another loop
 | 
				
			||||||
 | 
					-     iteration we need to see the correct value of g1_start)  */
 | 
				
			||||||
 | 
					-  while (!atomic_compare_exchange_weak_acquire (cond->__data.__g_signals + g,
 | 
				
			||||||
 | 
					-						&signals, signals - 2));
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					- done:
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* Confirm that we have been woken.  We do that before acquiring the mutex
 | 
				
			||||||
 | 
					      to allow for execution of pthread_cond_destroy while having acquired the
 | 
				
			||||||
							
								
								
									
										218
									
								
								SOURCES/glibc-RHEL-8381-7.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										218
									
								
								SOURCES/glibc-RHEL-8381-7.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,218 @@
 | 
				
			|||||||
 | 
					commit ee6c14ed59d480720721aaacc5fb03213dc153da
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 08:04:10 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: Fix indentation
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    In my previous change I turned a nested loop into a simple loop. I'm doing
 | 
				
			||||||
 | 
					    the resulting indentation changes in a separate commit to make the diff on
 | 
				
			||||||
 | 
					    the previous commit easier to review.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Conflicts:
 | 
				
			||||||
 | 
					#	nptl/pthread_cond_wait.c (Missing futex_wait_cancelable cleanup)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index 8f12fc4ee288cf4a..964591449dc57758 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -379,107 +379,108 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-      while (1)
 | 
				
			||||||
 | 
					-	{
 | 
				
			||||||
 | 
					-	  /* Now wait until a signal is available in our group or it is closed.
 | 
				
			||||||
 | 
					-	     Acquire MO so that if we observe (signals == lowseq) after group
 | 
				
			||||||
 | 
					-	     switching in __condvar_quiesce_and_switch_g1, we synchronize with that
 | 
				
			||||||
 | 
					-	     store and will see the prior update of __g1_start done while switching
 | 
				
			||||||
 | 
					-	     groups too.  */
 | 
				
			||||||
 | 
					-	  unsigned int signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					-	  uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-	  unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      /* If the group is closed already,
 | 
				
			||||||
 | 
					-	         then this waiter originally had enough extra signals to
 | 
				
			||||||
 | 
					-	         consume, up until the time its group was closed.  */
 | 
				
			||||||
 | 
					-	       break;
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  /* If there is an available signal, don't block.
 | 
				
			||||||
 | 
					-	     If __g1_start has advanced at all, then we must be in G1
 | 
				
			||||||
 | 
					-	     by now, perhaps in the process of switching back to an older
 | 
				
			||||||
 | 
					-	     G2, but in either case we're allowed to consume the available
 | 
				
			||||||
 | 
					-	     signal and should not block anymore.  */
 | 
				
			||||||
 | 
					-	  if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      /* Try to grab a signal.  See above for MO.  (if we do another loop
 | 
				
			||||||
 | 
					-		 iteration we need to see the correct value of g1_start)  */
 | 
				
			||||||
 | 
					-		      if (atomic_compare_exchange_weak_acquire (
 | 
				
			||||||
 | 
					-		      		cond->__data.__g_signals + g,
 | 
				
			||||||
 | 
					+  while (1)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      /* Now wait until a signal is available in our group or it is closed.
 | 
				
			||||||
 | 
					+         Acquire MO so that if we observe (signals == lowseq) after group
 | 
				
			||||||
 | 
					+         switching in __condvar_quiesce_and_switch_g1, we synchronize with that
 | 
				
			||||||
 | 
					+         store and will see the prior update of __g1_start done while switching
 | 
				
			||||||
 | 
					+         groups too.  */
 | 
				
			||||||
 | 
					+      unsigned int signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					+      uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+      unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          /* If the group is closed already,
 | 
				
			||||||
 | 
					+             then this waiter originally had enough extra signals to
 | 
				
			||||||
 | 
					+             consume, up until the time its group was closed.  */
 | 
				
			||||||
 | 
					+           break;
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      /* If there is an available signal, don't block.
 | 
				
			||||||
 | 
					+         If __g1_start has advanced at all, then we must be in G1
 | 
				
			||||||
 | 
					+         by now, perhaps in the process of switching back to an older
 | 
				
			||||||
 | 
					+         G2, but in either case we're allowed to consume the available
 | 
				
			||||||
 | 
					+         signal and should not block anymore.  */
 | 
				
			||||||
 | 
					+      if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+	  /* Try to grab a signal.  See above for MO.  (if we do another loop
 | 
				
			||||||
 | 
					+	     iteration we need to see the correct value of g1_start)  */
 | 
				
			||||||
 | 
					+	    if (atomic_compare_exchange_weak_acquire (
 | 
				
			||||||
 | 
					+			cond->__data.__g_signals + g,
 | 
				
			||||||
 | 
					 			&signals, signals - 2))
 | 
				
			||||||
 | 
					-		      	break;
 | 
				
			||||||
 | 
					-		      else
 | 
				
			||||||
 | 
					-		      	continue;
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					+	      break;
 | 
				
			||||||
 | 
					+	    else
 | 
				
			||||||
 | 
					+	      continue;
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	  // Now block.
 | 
				
			||||||
 | 
					-	  struct _pthread_cleanup_buffer buffer;
 | 
				
			||||||
 | 
					-	  struct _condvar_cleanup_buffer cbuffer;
 | 
				
			||||||
 | 
					-	  cbuffer.wseq = wseq;
 | 
				
			||||||
 | 
					-	  cbuffer.cond = cond;
 | 
				
			||||||
 | 
					-	  cbuffer.mutex = mutex;
 | 
				
			||||||
 | 
					-	  cbuffer.private = private;
 | 
				
			||||||
 | 
					-	  __pthread_cleanup_push (&buffer, __condvar_cleanup_waiting, &cbuffer);
 | 
				
			||||||
 | 
					+      // Now block.
 | 
				
			||||||
 | 
					+      struct _pthread_cleanup_buffer buffer;
 | 
				
			||||||
 | 
					+      struct _condvar_cleanup_buffer cbuffer;
 | 
				
			||||||
 | 
					+      cbuffer.wseq = wseq;
 | 
				
			||||||
 | 
					+      cbuffer.cond = cond;
 | 
				
			||||||
 | 
					+      cbuffer.mutex = mutex;
 | 
				
			||||||
 | 
					+      cbuffer.private = private;
 | 
				
			||||||
 | 
					+      __pthread_cleanup_push (&buffer, __condvar_cleanup_waiting, &cbuffer);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	  if (abstime == NULL)
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      /* Block without a timeout.  */
 | 
				
			||||||
 | 
					-	      err = futex_wait_cancelable (
 | 
				
			||||||
 | 
					-		  cond->__data.__g_signals + g, signals, private);
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					-	  else
 | 
				
			||||||
 | 
					+      if (abstime == NULL)
 | 
				
			||||||
 | 
					+	{
 | 
				
			||||||
 | 
					+	  /* Block without a timeout.  */
 | 
				
			||||||
 | 
					+	  err = futex_wait_cancelable
 | 
				
			||||||
 | 
					+		(cond->__data.__g_signals + g, signals, private);
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					+      else
 | 
				
			||||||
 | 
					+	{
 | 
				
			||||||
 | 
					+	  /* Block, but with a timeout.
 | 
				
			||||||
 | 
					+	     Work around the fact that the kernel rejects negative timeout
 | 
				
			||||||
 | 
					+	     values despite them being valid.  */
 | 
				
			||||||
 | 
					+	  if (__glibc_unlikely (abstime->tv_sec < 0))
 | 
				
			||||||
 | 
					+	    err = ETIMEDOUT;
 | 
				
			||||||
 | 
					+	  else if ((flags & __PTHREAD_COND_CLOCK_MONOTONIC_MASK) != 0)
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					-	      /* Block, but with a timeout.
 | 
				
			||||||
 | 
					-		 Work around the fact that the kernel rejects negative timeout
 | 
				
			||||||
 | 
					-		 values despite them being valid.  */
 | 
				
			||||||
 | 
					-	      if (__glibc_unlikely (abstime->tv_sec < 0))
 | 
				
			||||||
 | 
					-	        err = ETIMEDOUT;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	      else if ((flags & __PTHREAD_COND_CLOCK_MONOTONIC_MASK) != 0)
 | 
				
			||||||
 | 
					+	      /* CLOCK_MONOTONIC is requested.  */
 | 
				
			||||||
 | 
					+	      struct timespec rt;
 | 
				
			||||||
 | 
					+	      if (__clock_gettime (CLOCK_MONOTONIC, &rt) != 0)
 | 
				
			||||||
 | 
					+		__libc_fatal ("clock_gettime does not support "
 | 
				
			||||||
 | 
					+			      "CLOCK_MONOTONIC\n");
 | 
				
			||||||
 | 
					+	      /* Convert the absolute timeout value to a relative
 | 
				
			||||||
 | 
					+		 timeout.  */
 | 
				
			||||||
 | 
					+	      rt.tv_sec = abstime->tv_sec - rt.tv_sec;
 | 
				
			||||||
 | 
					+	      rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
 | 
				
			||||||
 | 
					+	      if (rt.tv_nsec < 0)
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					-		  /* CLOCK_MONOTONIC is requested.  */
 | 
				
			||||||
 | 
					-		  struct timespec rt;
 | 
				
			||||||
 | 
					-		  if (__clock_gettime (CLOCK_MONOTONIC, &rt) != 0)
 | 
				
			||||||
 | 
					-		    __libc_fatal ("clock_gettime does not support "
 | 
				
			||||||
 | 
					-				  "CLOCK_MONOTONIC\n");
 | 
				
			||||||
 | 
					-		  /* Convert the absolute timeout value to a relative
 | 
				
			||||||
 | 
					-		     timeout.  */
 | 
				
			||||||
 | 
					-		  rt.tv_sec = abstime->tv_sec - rt.tv_sec;
 | 
				
			||||||
 | 
					-		  rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
 | 
				
			||||||
 | 
					-		  if (rt.tv_nsec < 0)
 | 
				
			||||||
 | 
					-		    {
 | 
				
			||||||
 | 
					-		      rt.tv_nsec += 1000000000;
 | 
				
			||||||
 | 
					-		      --rt.tv_sec;
 | 
				
			||||||
 | 
					-		    }
 | 
				
			||||||
 | 
					-		  /* Did we already time out?  */
 | 
				
			||||||
 | 
					-		  if (__glibc_unlikely (rt.tv_sec < 0))
 | 
				
			||||||
 | 
					-		    err = ETIMEDOUT;
 | 
				
			||||||
 | 
					-		  else
 | 
				
			||||||
 | 
					-		    err = futex_reltimed_wait_cancelable
 | 
				
			||||||
 | 
					-			(cond->__data.__g_signals + g, signals, &rt, private);
 | 
				
			||||||
 | 
					+		  rt.tv_nsec += 1000000000;
 | 
				
			||||||
 | 
					+		  --rt.tv_sec;
 | 
				
			||||||
 | 
					 		}
 | 
				
			||||||
 | 
					+	      /* Did we already time out?  */
 | 
				
			||||||
 | 
					+	      if (__glibc_unlikely (rt.tv_sec < 0))
 | 
				
			||||||
 | 
					+		err = ETIMEDOUT;
 | 
				
			||||||
 | 
					 	      else
 | 
				
			||||||
 | 
					-		{
 | 
				
			||||||
 | 
					-		  /* Use CLOCK_REALTIME.  */
 | 
				
			||||||
 | 
					-		  err = futex_abstimed_wait_cancelable
 | 
				
			||||||
 | 
					-		      (cond->__data.__g_signals + g, signals, abstime, private);
 | 
				
			||||||
 | 
					-		}
 | 
				
			||||||
 | 
					+		err = futex_reltimed_wait_cancelable
 | 
				
			||||||
 | 
					+			(cond->__data.__g_signals + g, signals,
 | 
				
			||||||
 | 
					+			 &rt, private);
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  __pthread_cleanup_pop (&buffer, 0);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  if (__glibc_unlikely (err == ETIMEDOUT))
 | 
				
			||||||
 | 
					+	  else
 | 
				
			||||||
 | 
					 	    {
 | 
				
			||||||
 | 
					-	      /* If we timed out, we effectively cancel waiting.  */
 | 
				
			||||||
 | 
					-	      __condvar_cancel_waiting (cond, seq, g, private);
 | 
				
			||||||
 | 
					-	      result = ETIMEDOUT;
 | 
				
			||||||
 | 
					-	      break;
 | 
				
			||||||
 | 
					+	      /* Use CLOCK_REALTIME.  */
 | 
				
			||||||
 | 
					+	      err = futex_abstimed_wait_cancelable
 | 
				
			||||||
 | 
					+			(cond->__data.__g_signals + g, signals,
 | 
				
			||||||
 | 
					+			 abstime, private);
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+      __pthread_cleanup_pop (&buffer, 0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      if (__glibc_unlikely (err == ETIMEDOUT))
 | 
				
			||||||
 | 
					+	{
 | 
				
			||||||
 | 
					+	  /* If we timed out, we effectively cancel waiting.  */
 | 
				
			||||||
 | 
					+	  __condvar_cancel_waiting (cond, seq, g, private);
 | 
				
			||||||
 | 
					+	  result = ETIMEDOUT;
 | 
				
			||||||
 | 
					+	  break;
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					   /* Confirm that we have been woken.  We do that before acquiring the mutex
 | 
				
			||||||
 | 
					      to allow for execution of pthread_cond_destroy while having acquired the
 | 
				
			||||||
 | 
					      mutex.  */
 | 
				
			||||||
							
								
								
									
										147
									
								
								SOURCES/glibc-RHEL-8381-8.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								SOURCES/glibc-RHEL-8381-8.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,147 @@
 | 
				
			|||||||
 | 
					commit 4b79e27a5073c02f6bff9aa8f4791230a0ab1867
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 08:04:54 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: rename __condvar_quiesce_and_switch_g1
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This function no longer waits for threads to leave g1, so rename it to
 | 
				
			||||||
 | 
					    __condvar_switch_g1
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c
 | 
				
			||||||
 | 
					index e6bcb9b61b0055a5..1ec746ec3df51c4f 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_broadcast.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_broadcast.c
 | 
				
			||||||
 | 
					@@ -61,7 +61,7 @@ __pthread_cond_broadcast (pthread_cond_t *cond)
 | 
				
			||||||
 | 
					 				cond->__data.__g_size[g1] << 1);
 | 
				
			||||||
 | 
					       cond->__data.__g_size[g1] = 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-      /* We need to wake G1 waiters before we quiesce G1 below.  */
 | 
				
			||||||
 | 
					+      /* We need to wake G1 waiters before we switch G1 below.  */
 | 
				
			||||||
 | 
					       /* TODO Only set it if there are indeed futex waiters.  We could
 | 
				
			||||||
 | 
					 	 also try to move this out of the critical section in cases when
 | 
				
			||||||
 | 
					 	 G2 is empty (and we don't need to quiesce).  */
 | 
				
			||||||
 | 
					@@ -70,7 +70,7 @@ __pthread_cond_broadcast (pthread_cond_t *cond)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* G1 is complete.  Step (2) is next unless there are no waiters in G2, in
 | 
				
			||||||
 | 
					      which case we can stop.  */
 | 
				
			||||||
 | 
					-  if (__condvar_quiesce_and_switch_g1 (cond, wseq, &g1, private))
 | 
				
			||||||
 | 
					+  if (__condvar_switch_g1 (cond, wseq, &g1, private))
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       /* Step (3): Send signals to all waiters in the old G2 / new G1.  */
 | 
				
			||||||
 | 
					       atomic_fetch_add_relaxed (cond->__data.__g_signals + g1,
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					index f6d8c72b7f30ecff..770f8e7c5d347f6b 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					@@ -329,16 +329,15 @@ __condvar_get_private (int flags)
 | 
				
			||||||
 | 
					     return FUTEX_SHARED;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-/* This closes G1 (whose index is in G1INDEX), waits for all futex waiters to
 | 
				
			||||||
 | 
					-   leave G1, converts G1 into a fresh G2, and then switches group roles so that
 | 
				
			||||||
 | 
					-   the former G2 becomes the new G1 ending at the current __wseq value when we
 | 
				
			||||||
 | 
					-   eventually make the switch (WSEQ is just an observation of __wseq by the
 | 
				
			||||||
 | 
					-   signaler).
 | 
				
			||||||
 | 
					+/* This closes G1 (whose index is in G1INDEX), converts G1 into a fresh G2,
 | 
				
			||||||
 | 
					+   and then switches group roles so that the former G2 becomes the new G1
 | 
				
			||||||
 | 
					+   ending at the current __wseq value when we eventually make the switch
 | 
				
			||||||
 | 
					+   (WSEQ is just an observation of __wseq by the signaler).
 | 
				
			||||||
 | 
					    If G2 is empty, it will not switch groups because then it would create an
 | 
				
			||||||
 | 
					    empty G1 which would require switching groups again on the next signal.
 | 
				
			||||||
 | 
					    Returns false iff groups were not switched because G2 was empty.  */
 | 
				
			||||||
 | 
					 static bool __attribute__ ((unused))
 | 
				
			||||||
 | 
					-__condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					+__condvar_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					     unsigned int *g1index, int private)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					   unsigned int g1 = *g1index;
 | 
				
			||||||
 | 
					@@ -354,8 +353,7 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					 	  + cond->__data.__g_size[g1 ^ 1]) == 0)
 | 
				
			||||||
 | 
					 	return false;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* Now try to close and quiesce G1.  We have to consider the following kinds
 | 
				
			||||||
 | 
					-     of waiters:
 | 
				
			||||||
 | 
					+  /* We have to consider the following kinds of waiters:
 | 
				
			||||||
 | 
					      * Waiters from less recent groups than G1 are not affected because
 | 
				
			||||||
 | 
					        nothing will change for them apart from __g1_start getting larger.
 | 
				
			||||||
 | 
					      * New waiters arriving concurrently with the group switching will all go
 | 
				
			||||||
 | 
					@@ -363,12 +361,12 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					        are not affected.
 | 
				
			||||||
 | 
					      * Waiters in G1 have already received a signal and been woken.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* Update __g1_start, which finishes closing this group.  The value we add
 | 
				
			||||||
 | 
					-     will never be negative because old_orig_size can only be zero when we
 | 
				
			||||||
 | 
					-     switch groups the first time after a condvar was initialized, in which
 | 
				
			||||||
 | 
					-     case G1 will be at index 1 and we will add a value of 1.
 | 
				
			||||||
 | 
					-     Relaxed MO is fine because the change comes with no additional
 | 
				
			||||||
 | 
					-     constraints that others would have to observe.  */
 | 
				
			||||||
 | 
					+  /* Update __g1_start, which closes this group.  The value we add will never
 | 
				
			||||||
 | 
					+     be negative because old_orig_size can only be zero when we switch groups
 | 
				
			||||||
 | 
					+     the first time after a condvar was initialized, in which case G1 will be
 | 
				
			||||||
 | 
					+     at index 1 and we will add a value of 1. Relaxed MO is fine because the
 | 
				
			||||||
 | 
					+     change comes with no additional constraints that others would have to
 | 
				
			||||||
 | 
					+     observe.  */
 | 
				
			||||||
 | 
					   __condvar_add_g1_start_relaxed (cond,
 | 
				
			||||||
 | 
					       (old_orig_size << 1) + (g1 == 1 ? 1 : - 1));
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c
 | 
				
			||||||
 | 
					index 3db3d1fbeb165ea4..24c9d813e7c0ada6 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_signal.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_signal.c
 | 
				
			||||||
 | 
					@@ -70,18 +70,17 @@ __pthread_cond_signal (pthread_cond_t *cond)
 | 
				
			||||||
 | 
					   bool do_futex_wake = false;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* If G1 is still receiving signals, we put the signal there.  If not, we
 | 
				
			||||||
 | 
					-     check if G2 has waiters, and if so, quiesce and switch G1 to the former
 | 
				
			||||||
 | 
					-     G2; if this results in a new G1 with waiters (G2 might have cancellations
 | 
				
			||||||
 | 
					-     already, see __condvar_quiesce_and_switch_g1), we put the signal in the
 | 
				
			||||||
 | 
					-     new G1.  */
 | 
				
			||||||
 | 
					+     check if G2 has waiters, and if so, switch G1 to the former G2; if this
 | 
				
			||||||
 | 
					+     results in a new G1 with waiters (G2 might have cancellations already,
 | 
				
			||||||
 | 
					+     see __condvar_switch_g1), we put the signal in the new G1. */
 | 
				
			||||||
 | 
					   if ((cond->__data.__g_size[g1] != 0)
 | 
				
			||||||
 | 
					-      || __condvar_quiesce_and_switch_g1 (cond, wseq, &g1, private))
 | 
				
			||||||
 | 
					+      || __condvar_switch_g1 (cond, wseq, &g1, private))
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       /* Add a signal.  Relaxed MO is fine because signaling does not need to
 | 
				
			||||||
 | 
					-	 establish a happens-before relation (see above).  We do not mask the
 | 
				
			||||||
 | 
					-	 release-MO store when initializing a group in
 | 
				
			||||||
 | 
					-	 __condvar_quiesce_and_switch_g1 because we use an atomic
 | 
				
			||||||
 | 
					-	 read-modify-write and thus extend that store's release sequence.  */
 | 
				
			||||||
 | 
					+         establish a happens-before relation (see above).  We do not mask the
 | 
				
			||||||
 | 
					+         release-MO store when initializing a group in __condvar_switch_g1
 | 
				
			||||||
 | 
					+         because we use an atomic read-modify-write and thus extend that
 | 
				
			||||||
 | 
					+         store's release sequence.  */
 | 
				
			||||||
 | 
					       atomic_fetch_add_relaxed (cond->__data.__g_signals + g1, 2);
 | 
				
			||||||
 | 
					       cond->__data.__g_size[g1]--;
 | 
				
			||||||
 | 
					       /* TODO Only set it if there are indeed futex waiters.  */
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index c97b5d22cb31ca6b..5b82ce639367e0c0 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -350,8 +350,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					      because we do not need to establish any happens-before relation with
 | 
				
			||||||
 | 
					      signalers (see __pthread_cond_signal); modification order alone
 | 
				
			||||||
 | 
					      establishes a total order of waiters/signals.  We do need acquire MO
 | 
				
			||||||
 | 
					-     to synchronize with group reinitialization in
 | 
				
			||||||
 | 
					-     __condvar_quiesce_and_switch_g1.  */
 | 
				
			||||||
 | 
					+     to synchronize with group reinitialization in __condvar_switch_g1.  */
 | 
				
			||||||
 | 
					   uint64_t wseq = __condvar_fetch_add_wseq_acquire (cond, 2);
 | 
				
			||||||
 | 
					   /* Find our group's index.  We always go into what was G2 when we acquired
 | 
				
			||||||
 | 
					      our position.  */
 | 
				
			||||||
 | 
					@@ -383,9 +382,9 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       /* Now wait until a signal is available in our group or it is closed.
 | 
				
			||||||
 | 
					          Acquire MO so that if we observe (signals == lowseq) after group
 | 
				
			||||||
 | 
					-         switching in __condvar_quiesce_and_switch_g1, we synchronize with that
 | 
				
			||||||
 | 
					-         store and will see the prior update of __g1_start done while switching
 | 
				
			||||||
 | 
					-         groups too.  */
 | 
				
			||||||
 | 
					+         switching in __condvar_switch_g1, we synchronize with that store and
 | 
				
			||||||
 | 
					+         will see the prior update of __g1_start done while switching groups
 | 
				
			||||||
 | 
					+         too.  */
 | 
				
			||||||
 | 
					       unsigned int signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					       uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					       unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
							
								
								
									
										179
									
								
								SOURCES/glibc-RHEL-8381-9.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								SOURCES/glibc-RHEL-8381-9.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,179 @@
 | 
				
			|||||||
 | 
					commit 91bb902f58264a2fd50fbce8f39a9a290dd23706
 | 
				
			||||||
 | 
					Author: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					Date:   Wed Dec 4 08:05:40 2024 -0500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nptl: Use all of g1_start and g_signals
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The LSB of g_signals was unused. The LSB of g1_start was used to indicate
 | 
				
			||||||
 | 
					    which group is G2. This was used to always go to sleep in pthread_cond_wait
 | 
				
			||||||
 | 
					    if a waiter is in G2. A comment earlier in the file says that this is not
 | 
				
			||||||
 | 
					    correct to do:
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					     "Waiters cannot determine whether they are currently in G2 or G1 -- but they
 | 
				
			||||||
 | 
					      do not have to because all they are interested in is whether there are
 | 
				
			||||||
 | 
					      available signals"
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    I either would have had to update the comment, or get rid of the check. I
 | 
				
			||||||
 | 
					    chose to get rid of the check. In fact I don't quite know why it was there.
 | 
				
			||||||
 | 
					    There will never be available signals for group G2, so we didn't need the
 | 
				
			||||||
 | 
					    special case. Even if there were, this would just be a spurious wake. This
 | 
				
			||||||
 | 
					    might have caught some cases where the count has wrapped around, but it
 | 
				
			||||||
 | 
					    wouldn't reliably do that, (and even if it did, why would you want to force a
 | 
				
			||||||
 | 
					    sleep in that case?) and we don't support that many concurrent waiters
 | 
				
			||||||
 | 
					    anyway. Getting rid of it allows us to use one more bit, making us more
 | 
				
			||||||
 | 
					    robust to wraparound.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c
 | 
				
			||||||
 | 
					index 1ec746ec3df51c4f..14d3e533ad4b24d7 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_broadcast.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_broadcast.c
 | 
				
			||||||
 | 
					@@ -58,7 +58,7 @@ __pthread_cond_broadcast (pthread_cond_t *cond)
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       /* Add as many signals as the remaining size of the group.  */
 | 
				
			||||||
 | 
					       atomic_fetch_add_relaxed (cond->__data.__g_signals + g1,
 | 
				
			||||||
 | 
					-				cond->__data.__g_size[g1] << 1);
 | 
				
			||||||
 | 
					+				cond->__data.__g_size[g1]);
 | 
				
			||||||
 | 
					       cond->__data.__g_size[g1] = 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       /* We need to wake G1 waiters before we switch G1 below.  */
 | 
				
			||||||
 | 
					@@ -74,7 +74,7 @@ __pthread_cond_broadcast (pthread_cond_t *cond)
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       /* Step (3): Send signals to all waiters in the old G2 / new G1.  */
 | 
				
			||||||
 | 
					       atomic_fetch_add_relaxed (cond->__data.__g_signals + g1,
 | 
				
			||||||
 | 
					-				cond->__data.__g_size[g1] << 1);
 | 
				
			||||||
 | 
					+				cond->__data.__g_size[g1]);
 | 
				
			||||||
 | 
					       cond->__data.__g_size[g1] = 0;
 | 
				
			||||||
 | 
					       /* TODO Only set it if there are indeed futex waiters.  */
 | 
				
			||||||
 | 
					       do_futex_wake = true;
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					index 770f8e7c5d347f6b..1fe0448d8705c326 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_common.c
 | 
				
			||||||
 | 
					@@ -348,9 +348,9 @@ __condvar_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					      behavior.
 | 
				
			||||||
 | 
					      Note that this works correctly for a zero-initialized condvar too.  */
 | 
				
			||||||
 | 
					   unsigned int old_orig_size = __condvar_get_orig_size (cond);
 | 
				
			||||||
 | 
					-  uint64_t old_g1_start = __condvar_load_g1_start_relaxed (cond) >> 1;
 | 
				
			||||||
 | 
					-  if (((unsigned) (wseq - old_g1_start - old_orig_size)
 | 
				
			||||||
 | 
					-	  + cond->__data.__g_size[g1 ^ 1]) == 0)
 | 
				
			||||||
 | 
					+  uint64_t old_g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					+  uint64_t new_g1_start = old_g1_start + old_orig_size;
 | 
				
			||||||
 | 
					+  if (((unsigned) (wseq - new_g1_start) + cond->__data.__g_size[g1 ^ 1]) == 0)
 | 
				
			||||||
 | 
					 	return false;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* We have to consider the following kinds of waiters:
 | 
				
			||||||
 | 
					@@ -361,16 +361,10 @@ __condvar_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					        are not affected.
 | 
				
			||||||
 | 
					      * Waiters in G1 have already received a signal and been woken.  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* Update __g1_start, which closes this group.  The value we add will never
 | 
				
			||||||
 | 
					-     be negative because old_orig_size can only be zero when we switch groups
 | 
				
			||||||
 | 
					-     the first time after a condvar was initialized, in which case G1 will be
 | 
				
			||||||
 | 
					-     at index 1 and we will add a value of 1. Relaxed MO is fine because the
 | 
				
			||||||
 | 
					-     change comes with no additional constraints that others would have to
 | 
				
			||||||
 | 
					-     observe.  */
 | 
				
			||||||
 | 
					-  __condvar_add_g1_start_relaxed (cond,
 | 
				
			||||||
 | 
					-      (old_orig_size << 1) + (g1 == 1 ? 1 : - 1));
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  unsigned int lowseq = ((old_g1_start + old_orig_size) << 1) & ~1U;
 | 
				
			||||||
 | 
					+  /* Update __g1_start, which closes this group.  Relaxed MO is fine because
 | 
				
			||||||
 | 
					+     the change comes with no additional constraints that others would have
 | 
				
			||||||
 | 
					+     to observe.  */
 | 
				
			||||||
 | 
					+  __condvar_add_g1_start_relaxed (cond, old_orig_size);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* At this point, the old G1 is now a valid new G2 (but not in use yet).
 | 
				
			||||||
 | 
					      No old waiter can neither grab a signal nor acquire a reference without
 | 
				
			||||||
 | 
					@@ -382,13 +376,13 @@ __condvar_switch_g1 (pthread_cond_t *cond, uint64_t wseq,
 | 
				
			||||||
 | 
					   g1 ^= 1;
 | 
				
			||||||
 | 
					   *g1index ^= 1;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* Now advance the new G1 g_signals to the new lowseq, giving it
 | 
				
			||||||
 | 
					+  /* Now advance the new G1 g_signals to the new g1_start, giving it
 | 
				
			||||||
 | 
					      an effective signal count of 0 to start.  */
 | 
				
			||||||
 | 
					-  atomic_store_release (cond->__data.__g_signals + g1, lowseq);
 | 
				
			||||||
 | 
					+  atomic_store_release (cond->__data.__g_signals + g1, (unsigned)new_g1_start);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* These values are just observed by signalers, and thus protected by the
 | 
				
			||||||
 | 
					      lock.  */
 | 
				
			||||||
 | 
					-  unsigned int orig_size = wseq - (old_g1_start + old_orig_size);
 | 
				
			||||||
 | 
					+  unsigned int orig_size = wseq - new_g1_start;
 | 
				
			||||||
 | 
					   __condvar_set_orig_size (cond, orig_size);
 | 
				
			||||||
 | 
					   /* Use and addition to not loose track of cancellations in what was
 | 
				
			||||||
 | 
					      previously G2.  */
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c
 | 
				
			||||||
 | 
					index 24c9d813e7c0ada6..9f04833119fd3f59 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_signal.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_signal.c
 | 
				
			||||||
 | 
					@@ -81,7 +81,7 @@ __pthread_cond_signal (pthread_cond_t *cond)
 | 
				
			||||||
 | 
					          release-MO store when initializing a group in __condvar_switch_g1
 | 
				
			||||||
 | 
					          because we use an atomic read-modify-write and thus extend that
 | 
				
			||||||
 | 
					          store's release sequence.  */
 | 
				
			||||||
 | 
					-      atomic_fetch_add_relaxed (cond->__data.__g_signals + g1, 2);
 | 
				
			||||||
 | 
					+      atomic_fetch_add_relaxed (cond->__data.__g_signals + g1, 1);
 | 
				
			||||||
 | 
					       cond->__data.__g_size[g1]--;
 | 
				
			||||||
 | 
					       /* TODO Only set it if there are indeed futex waiters.  */
 | 
				
			||||||
 | 
					       do_futex_wake = true;
 | 
				
			||||||
 | 
					diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					index 5b82ce639367e0c0..031ec717ca64f66f 100644
 | 
				
			||||||
 | 
					--- a/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					+++ b/nptl/pthread_cond_wait.c
 | 
				
			||||||
 | 
					@@ -85,7 +85,7 @@ __condvar_cancel_waiting (pthread_cond_t *cond, uint64_t seq, unsigned int g,
 | 
				
			||||||
 | 
					      not hold a reference on the group.  */
 | 
				
			||||||
 | 
					   __condvar_acquire_lock (cond, private);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  uint64_t g1_start = __condvar_load_g1_start_relaxed (cond) >> 1;
 | 
				
			||||||
 | 
					+  uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					   if (g1_start > seq)
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       /* Our group is closed, so someone provided enough signals for it.
 | 
				
			||||||
 | 
					@@ -260,7 +260,6 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					      * Waiters fetch-add while having acquire the mutex associated with the
 | 
				
			||||||
 | 
					        condvar.  Signalers load it and fetch-xor it concurrently.
 | 
				
			||||||
 | 
					    __g1_start: Starting position of G1 (inclusive)
 | 
				
			||||||
 | 
					-     * LSB is index of current G2.
 | 
				
			||||||
 | 
					      * Modified by signalers while having acquired the condvar-internal lock
 | 
				
			||||||
 | 
					        and observed concurrently by waiters.
 | 
				
			||||||
 | 
					    __g1_orig_size: Initial size of G1
 | 
				
			||||||
 | 
					@@ -281,11 +280,9 @@ __condvar_cleanup_waiting (void *arg)
 | 
				
			||||||
 | 
					      * Reference count used by waiters concurrently with signalers that have
 | 
				
			||||||
 | 
					        acquired the condvar-internal lock.
 | 
				
			||||||
 | 
					    __g_signals: The number of signals that can still be consumed, relative to
 | 
				
			||||||
 | 
					-     the current g1_start.  (i.e. bits 31 to 1 of __g_signals are bits
 | 
				
			||||||
 | 
					-     31 to 1 of g1_start with the signal count added)
 | 
				
			||||||
 | 
					+     the current g1_start.  (i.e. g1_start with the signal count added)
 | 
				
			||||||
 | 
					      * Used as a futex word by waiters.  Used concurrently by waiters and
 | 
				
			||||||
 | 
					        signalers.
 | 
				
			||||||
 | 
					-     * LSB is currently reserved and 0.
 | 
				
			||||||
 | 
					    __g_size: Waiters remaining in this group (i.e., which have not been
 | 
				
			||||||
 | 
					      signaled yet.
 | 
				
			||||||
 | 
					      * Accessed by signalers and waiters that cancel waiting (both do so only
 | 
				
			||||||
 | 
					@@ -387,9 +384,8 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					          too.  */
 | 
				
			||||||
 | 
					       unsigned int signals = atomic_load_acquire (cond->__data.__g_signals + g);
 | 
				
			||||||
 | 
					       uint64_t g1_start = __condvar_load_g1_start_relaxed (cond);
 | 
				
			||||||
 | 
					-      unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-      if (seq < (g1_start >> 1))
 | 
				
			||||||
 | 
					+      if (seq < g1_start)
 | 
				
			||||||
 | 
					         {
 | 
				
			||||||
 | 
					           /* If the group is closed already,
 | 
				
			||||||
 | 
					              then this waiter originally had enough extra signals to
 | 
				
			||||||
 | 
					@@ -402,13 +398,13 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 | 
				
			||||||
 | 
					          by now, perhaps in the process of switching back to an older
 | 
				
			||||||
 | 
					          G2, but in either case we're allowed to consume the available
 | 
				
			||||||
 | 
					          signal and should not block anymore.  */
 | 
				
			||||||
 | 
					-      if ((int)(signals - lowseq) >= 2)
 | 
				
			||||||
 | 
					+      if ((int)(signals - (unsigned int)g1_start) > 0)
 | 
				
			||||||
 | 
					         {
 | 
				
			||||||
 | 
					 	  /* Try to grab a signal.  See above for MO.  (if we do another loop
 | 
				
			||||||
 | 
					 	     iteration we need to see the correct value of g1_start)  */
 | 
				
			||||||
 | 
					 	    if (atomic_compare_exchange_weak_acquire (
 | 
				
			||||||
 | 
					 			cond->__data.__g_signals + g,
 | 
				
			||||||
 | 
					-			&signals, signals - 2))
 | 
				
			||||||
 | 
					+			&signals, signals - 1))
 | 
				
			||||||
 | 
					 	      break;
 | 
				
			||||||
 | 
					 	    else
 | 
				
			||||||
 | 
					 	      continue;
 | 
				
			||||||
							
								
								
									
										194
									
								
								SOURCES/glibc-RHEL-86018-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										194
									
								
								SOURCES/glibc-RHEL-86018-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,194 @@
 | 
				
			|||||||
 | 
					commit 9f0d2c0ee6c728643fcf9a4879e9f20f5e45ce5f
 | 
				
			||||||
 | 
					Author: Arjun Shankar <arjun@redhat.com>
 | 
				
			||||||
 | 
					Date:   Fri Oct 18 16:03:25 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    libio: Fix a deadlock after fork in popen
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    popen modifies its file handler book-keeping under a lock that wasn't
 | 
				
			||||||
 | 
					    being taken during fork.  This meant that a concurrent popen and fork
 | 
				
			||||||
 | 
					    could end up copying the lock in a "locked" state into the fork child,
 | 
				
			||||||
 | 
					    where subsequently calling popen would lead to a deadlock due to the
 | 
				
			||||||
 | 
					    already (spuriously) held lock.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This commit fixes the deadlock by appropriately taking the lock before
 | 
				
			||||||
 | 
					    fork, and releasing/resetting it in the parent/child after the fork.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    A new test for concurrent popen and fork is also added.  It consistently
 | 
				
			||||||
 | 
					    hangs (and therefore fails via timeout) without the fix applied.
 | 
				
			||||||
 | 
					    Reviewed-by: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						libio/Makefile
 | 
				
			||||||
 | 
						  (Usual conflict when adding tests due to missing backports.)
 | 
				
			||||||
 | 
						posix/fork.c
 | 
				
			||||||
 | 
						  (reworked due to file rename upstream and libpthread integration)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/libio/Makefile b/libio/Makefile
 | 
				
			||||||
 | 
					--- a/libio/Makefile	2025-04-23 15:51:08.439579602 -0400
 | 
				
			||||||
 | 
					+++ b/libio/Makefile	2025-04-23 15:11:32.124866600 -0400
 | 
				
			||||||
 | 
					@@ -62,7 +62,7 @@ tests = tst_swprintf tst_wprintf tst_sws
 | 
				
			||||||
 | 
					 	tst-memstream1 tst-memstream2 tst-memstream3 \
 | 
				
			||||||
 | 
					 	tst-wmemstream1 tst-wmemstream2 tst-wmemstream3 \
 | 
				
			||||||
 | 
					 	bug-memstream1 bug-wmemstream1 \
 | 
				
			||||||
 | 
					-	tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \
 | 
				
			||||||
 | 
					+	tst-setvbuf1 tst-popen-fork tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \
 | 
				
			||||||
 | 
					 	tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler \
 | 
				
			||||||
 | 
					 	tst-ftell-append tst-fputws tst-bz22415 tst-fgetc-after-eof \
 | 
				
			||||||
 | 
					 	tst-wfile-sync
 | 
				
			||||||
 | 
					diff -Nrup a/libio/iopopen.c b/libio/iopopen.c
 | 
				
			||||||
 | 
					--- a/libio/iopopen.c	2025-04-23 15:51:09.145583660 -0400
 | 
				
			||||||
 | 
					+++ b/libio/iopopen.c	2025-04-23 15:07:45.167549822 -0400
 | 
				
			||||||
 | 
					@@ -60,6 +60,26 @@ unlock (void *not_used)
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+/* These lock/unlock/resetlock functions are used during fork.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void
 | 
				
			||||||
 | 
					+_IO_proc_file_chain_lock (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  _IO_lock_lock (proc_file_chain_lock);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void
 | 
				
			||||||
 | 
					+_IO_proc_file_chain_unlock (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  _IO_lock_unlock (proc_file_chain_lock);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void
 | 
				
			||||||
 | 
					+_IO_proc_file_chain_resetlock (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  _IO_lock_init (proc_file_chain_lock);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 /* POSIX states popen shall ensure that any streams from previous popen()
 | 
				
			||||||
 | 
					    calls that remain open in the parent process should be closed in the new
 | 
				
			||||||
 | 
					    child process.
 | 
				
			||||||
 | 
					diff -Nrup a/libio/libioP.h b/libio/libioP.h
 | 
				
			||||||
 | 
					--- a/libio/libioP.h	2025-04-23 15:51:08.012577147 -0400
 | 
				
			||||||
 | 
					+++ b/libio/libioP.h	2025-04-23 15:07:45.167549822 -0400
 | 
				
			||||||
 | 
					@@ -423,6 +423,12 @@ libc_hidden_proto (_IO_list_resetlock)
 | 
				
			||||||
 | 
					 extern void _IO_enable_locks (void) __THROW;
 | 
				
			||||||
 | 
					 libc_hidden_proto (_IO_enable_locks)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+/* Functions for operating popen's proc_file_chain_lock during fork.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+extern void _IO_proc_file_chain_lock (void) __THROW attribute_hidden;
 | 
				
			||||||
 | 
					+extern void _IO_proc_file_chain_unlock (void) __THROW attribute_hidden;
 | 
				
			||||||
 | 
					+extern void _IO_proc_file_chain_resetlock (void) __THROW attribute_hidden;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 /* Default jumptable functions. */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 extern int _IO_default_underflow (FILE *) __THROW;
 | 
				
			||||||
 | 
					diff -Nrup a/libio/tst-popen-fork.c b/libio/tst-popen-fork.c
 | 
				
			||||||
 | 
					--- a/libio/tst-popen-fork.c	1969-12-31 19:00:00.000000000 -0500
 | 
				
			||||||
 | 
					+++ b/libio/tst-popen-fork.c	2025-04-23 15:07:45.168549828 -0400
 | 
				
			||||||
 | 
					@@ -0,0 +1,80 @@
 | 
				
			||||||
 | 
					+/* Test concurrent popen and fork.
 | 
				
			||||||
 | 
					+   Copyright (C) 2024 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <stdio.h>
 | 
				
			||||||
 | 
					+#include <stdatomic.h>
 | 
				
			||||||
 | 
					+#include <pthread.h>
 | 
				
			||||||
 | 
					+#include <unistd.h>
 | 
				
			||||||
 | 
					+#include <sys/wait.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/check.h>
 | 
				
			||||||
 | 
					+#include <support/xthread.h>
 | 
				
			||||||
 | 
					+#include <support/xunistd.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+popen_and_pclose (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  FILE *f = popen ("true", "r");
 | 
				
			||||||
 | 
					+  TEST_VERIFY_EXIT (f != NULL);
 | 
				
			||||||
 | 
					+  pclose (f);
 | 
				
			||||||
 | 
					+  return;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static atomic_bool done = ATOMIC_VAR_INIT (0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static void *
 | 
				
			||||||
 | 
					+popen_and_pclose_forever (__attribute__ ((unused))
 | 
				
			||||||
 | 
					+                          void *arg)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  while (!atomic_load_explicit (&done, memory_order_acquire))
 | 
				
			||||||
 | 
					+    popen_and_pclose ();
 | 
				
			||||||
 | 
					+  return NULL;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+do_test (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Repeatedly call popen in a loop during the entire test.  */
 | 
				
			||||||
 | 
					+  pthread_t t = xpthread_create (NULL, popen_and_pclose_forever, NULL);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Repeatedly fork off and reap child processes one-by-one.
 | 
				
			||||||
 | 
					+     Each child calls popen once, then exits, leading to the possibility
 | 
				
			||||||
 | 
					+     that a child forks *during* our own popen call, thus inheriting any
 | 
				
			||||||
 | 
					+     intermediate popen state, possibly including lock state(s).  */
 | 
				
			||||||
 | 
					+  for (int i = 0; i < 100; i++)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      int cpid = xfork ();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      if (cpid == 0)
 | 
				
			||||||
 | 
					+        {
 | 
				
			||||||
 | 
					+          popen_and_pclose ();
 | 
				
			||||||
 | 
					+          _exit (0);
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+      else
 | 
				
			||||||
 | 
					+        xwaitpid (cpid, NULL, 0);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Stop calling popen.  */
 | 
				
			||||||
 | 
					+  atomic_store_explicit (&done, 1, memory_order_release);
 | 
				
			||||||
 | 
					+  xpthread_join (t);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
 | 
					--- a/sysdeps/nptl/fork.c	2025-04-23 16:33:49.283403134 -0400
 | 
				
			||||||
 | 
					+++ b/sysdeps/nptl/fork.c	2025-04-23 16:33:12.240190356 -0400
 | 
				
			||||||
 | 
					@@ -65,6 +65,7 @@ __libc_fork (void)
 | 
				
			||||||
 | 
					      not matter if fork was called from a signal handler.  */
 | 
				
			||||||
 | 
					   if (multiple_threads)
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					+      _IO_proc_file_chain_lock ();
 | 
				
			||||||
 | 
					       _IO_list_lock ();
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       /* Acquire malloc locks.  This needs to come last because fork
 | 
				
			||||||
 | 
					@@ -121,6 +122,7 @@ __libc_fork (void)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  /* Reset locks in the I/O code.  */
 | 
				
			||||||
 | 
					 	  _IO_list_resetlock ();
 | 
				
			||||||
 | 
					+	  _IO_proc_file_chain_resetlock ();
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       /* Reset the lock the dynamic loader uses to protect its data.  */
 | 
				
			||||||
 | 
					@@ -142,6 +144,7 @@ __libc_fork (void)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	  /* We execute this even if the 'fork' call failed.  */
 | 
				
			||||||
 | 
					 	  _IO_list_unlock ();
 | 
				
			||||||
 | 
					+	  _IO_proc_file_chain_unlock ();
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       /* Run the handlers registered for the parent.  */
 | 
				
			||||||
							
								
								
									
										29
									
								
								SOURCES/glibc-RHEL-86018-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								SOURCES/glibc-RHEL-86018-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					commit 6a290b2895b77be839fcb7c44a6a9879560097ad
 | 
				
			||||||
 | 
					Author: Arjun Shankar <arjun@redhat.com>
 | 
				
			||||||
 | 
					Date:   Fri Oct 25 09:33:45 2024 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    libio: Correctly link tst-popen-fork against libpthread
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    tst-popen-fork failed to build for Hurd due to not being linked with
 | 
				
			||||||
 | 
					    libpthread.  This commit fixes that.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Tested with build-many-glibcs.py for i686-gnu.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						libio/Makefile
 | 
				
			||||||
 | 
						  (Usual conflict when adding tests due to missing backports.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/libio/Makefile b/libio/Makefile
 | 
				
			||||||
 | 
					--- a/libio/Makefile	2025-04-23 16:41:58.028210552 -0400
 | 
				
			||||||
 | 
					+++ b/libio/Makefile	2025-04-23 16:41:30.195050679 -0400
 | 
				
			||||||
 | 
					@@ -67,6 +67,8 @@ tests = tst_swprintf tst_wprintf tst_sws
 | 
				
			||||||
 | 
					 	tst-ftell-append tst-fputws tst-bz22415 tst-fgetc-after-eof \
 | 
				
			||||||
 | 
					 	tst-wfile-sync
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+$(objpfx)tst-popen-fork: $(shared-thread-library)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 tests-internal = tst-vtables tst-vtables-interposed
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 ifeq (yes,$(build-shared))
 | 
				
			||||||
							
								
								
									
										31
									
								
								SOURCES/glibc-RHEL-88813.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								SOURCES/glibc-RHEL-88813.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					commit 268bb71e475d7e40fad83313be0eeb173e599c92
 | 
				
			||||||
 | 
					Author: Stefan Liebler <stli@linux.ibm.com>
 | 
				
			||||||
 | 
					Date:   Fri Dec 14 09:50:53 2018 +0100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Add missing libnss_testX.so requirement for tst-nss-test3.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Sometimes tst-nss-test3 fails with:
 | 
				
			||||||
 | 
					    error: test-container.c:386: unable to open .../nss/libnss_test1.so for reading
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The test tst-nss-test3 which runs in a container needs
 | 
				
			||||||
 | 
					    libnss_test[12].so. (see e.g. tst-nss-test3.script).
 | 
				
			||||||
 | 
					    Before this test was moved from tests to tests-container variable,
 | 
				
			||||||
 | 
					    the requirement was met.  Thus this patch adds this requirement
 | 
				
			||||||
 | 
					    also for tests in tests-container.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						ChangeLog
 | 
				
			||||||
 | 
						(removed)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff -Nrup a/nss/Makefile b/nss/Makefile
 | 
				
			||||||
 | 
					--- a/nss/Makefile	2025-05-01 21:21:05.471995292 -0400
 | 
				
			||||||
 | 
					+++ b/nss/Makefile	2025-05-01 21:19:15.440411065 -0400
 | 
				
			||||||
 | 
					@@ -197,7 +197,7 @@ $(objpfx)/libnss_test_errno.so$(libnss_f
 | 
				
			||||||
 | 
					 $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \
 | 
				
			||||||
 | 
					   $(objpfx)/libnss_test_gai_hv2_canonname.so
 | 
				
			||||||
 | 
					 	$(make-link)
 | 
				
			||||||
 | 
					-$(patsubst %,$(objpfx)%.out,$(tests)) : \
 | 
				
			||||||
 | 
					+$(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
 | 
				
			||||||
 | 
					 	$(objpfx)/libnss_test1.so$(libnss_test1.so-version) \
 | 
				
			||||||
 | 
					 	$(objpfx)/libnss_test2.so$(libnss_test2.so-version) \
 | 
				
			||||||
 | 
					 	$(objpfx)/libnss_test_errno.so$(libnss_files.so-version) \
 | 
				
			||||||
							
								
								
									
										23
									
								
								SOURCES/glibc-RHEL-92685-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								SOURCES/glibc-RHEL-92685-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					commit 45caed9d67a00af917d8b5b88d4b5eb1225b7aef
 | 
				
			||||||
 | 
					Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					Date:   Tue Aug 3 21:10:53 2021 +0530
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    copy_and_spawn_sgid: Avoid double calls to close()
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    If close() on infd and outfd succeeded, reset the fd numbers so that
 | 
				
			||||||
 | 
					    we don't attempt to close them again.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Arjun Shankar <arjun@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					index eec5371d5602aa29..9da5ba0c10bf6eee 100644
 | 
				
			||||||
 | 
					--- a/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					+++ b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					@@ -169,6 +169,7 @@ copy_and_spawn_sgid (char *child_id, gid_t gid)
 | 
				
			||||||
 | 
					      support_subprogram because we only want the program exit status, not the
 | 
				
			||||||
 | 
					      contents.  */
 | 
				
			||||||
 | 
					   ret = 0;
 | 
				
			||||||
 | 
					+  infd = outfd = -1;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   char * const args[] = {execname, child_id, NULL};
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
							
								
								
									
										52
									
								
								SOURCES/glibc-RHEL-92685-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								SOURCES/glibc-RHEL-92685-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					commit 6286cca2cb8389dcffec39238a8bf15ffea96396
 | 
				
			||||||
 | 
					Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					Date:   Thu Jun 1 07:23:15 2023 -0400
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    support: Don't fail on fchown when spawning sgid processes
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    In some cases (e.g. when podman creates user containers), the only other
 | 
				
			||||||
 | 
					    group assigned to the executing user is nobody and fchown fails with it
 | 
				
			||||||
 | 
					    because the group is not mapped.  Do not fail the test in this case,
 | 
				
			||||||
 | 
					    instead exit as unsupported.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reported-by: Frédéric Bérat <fberat@redhat.com>
 | 
				
			||||||
 | 
					    Tested-by: Frédéric Bérat <fberat@redhat.com>
 | 
				
			||||||
 | 
					    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					index 9da5ba0c10bf6eee..af03ea4dc6ec0b95 100644
 | 
				
			||||||
 | 
					--- a/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					+++ b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					@@ -152,9 +152,18 @@ copy_and_spawn_sgid (char *child_id, gid_t gid)
 | 
				
			||||||
 | 
					 	  p += wrcount;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					-  TEST_VERIFY (fchown (outfd, getuid (), gid) == 0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  bool chowned = false;
 | 
				
			||||||
 | 
					+  TEST_VERIFY ((chowned = fchown (outfd, getuid (), gid) == 0)
 | 
				
			||||||
 | 
					+	       || errno == EPERM);
 | 
				
			||||||
 | 
					   if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					     goto err;
 | 
				
			||||||
 | 
					+  else if (!chowned)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      ret = 77;
 | 
				
			||||||
 | 
					+      goto err;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					   TEST_VERIFY (fchmod (outfd, 02750) == 0);
 | 
				
			||||||
 | 
					   if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					     goto err;
 | 
				
			||||||
 | 
					@@ -191,8 +200,10 @@ err:
 | 
				
			||||||
 | 
					       free (dirname);
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+  if (ret == 77)
 | 
				
			||||||
 | 
					+    FAIL_UNSUPPORTED ("Failed to make sgid executable for test\n");
 | 
				
			||||||
 | 
					   if (ret != 0)
 | 
				
			||||||
 | 
					-    FAIL_EXIT1("Failed to make sgid executable for test\n");
 | 
				
			||||||
 | 
					+    FAIL_EXIT1 ("Failed to make sgid executable for test\n");
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   return status;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
							
								
								
									
										86
									
								
								SOURCES/glibc-RHEL-92685-3.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								SOURCES/glibc-RHEL-92685-3.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,86 @@
 | 
				
			|||||||
 | 
					commit 5451fa962cd0a90a0e2ec1d8910a559ace02bba0
 | 
				
			||||||
 | 
					Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
 | 
				
			||||||
 | 
					Date:   Mon Nov 6 17:25:49 2023 -0300
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elf: Ignore LD_LIBRARY_PATH and debug env var for setuid for static
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    It mimics the ld.so behavior.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Checked on x86_64-linux-gnu.
 | 
				
			||||||
 | 
					    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						elf/dl-support.c
 | 
				
			||||||
 | 
						  (downstream still uses HAVE_TUNABLES, does not yet
 | 
				
			||||||
 | 
						  call setup_vdso_pointers, still supports
 | 
				
			||||||
 | 
						  EXTRA_UNSECURE_ENVVARS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/elf/dl-support.c b/elf/dl-support.c
 | 
				
			||||||
 | 
					index e9943e889ef447ad..008fd90cb43c8803 100644
 | 
				
			||||||
 | 
					--- a/elf/dl-support.c
 | 
				
			||||||
 | 
					+++ b/elf/dl-support.c
 | 
				
			||||||
 | 
					@@ -314,33 +314,10 @@ _dl_non_dynamic_init (void)
 | 
				
			||||||
 | 
					   _dl_main_map.l_phdr = GL(dl_phdr);
 | 
				
			||||||
 | 
					   _dl_main_map.l_phnum = GL(dl_phnum);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					   /* Set up the data structures for the system-supplied DSO early,
 | 
				
			||||||
 | 
					      so they can influence _dl_init_paths.  */
 | 
				
			||||||
 | 
					   setup_vdso (NULL, NULL);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  /* Initialize the data structures for the search paths for shared
 | 
				
			||||||
 | 
					-     objects.  */
 | 
				
			||||||
 | 
					-  _dl_init_paths (getenv ("LD_LIBRARY_PATH"), "LD_LIBRARY_PATH",
 | 
				
			||||||
 | 
					-		  /* No glibc-hwcaps selection support in statically
 | 
				
			||||||
 | 
					-		     linked binaries.  */
 | 
				
			||||||
 | 
					-		  NULL, NULL);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  /* Remember the last search directory added at startup.  */
 | 
				
			||||||
 | 
					-  _dl_init_all_dirs = GL(dl_all_dirs);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  _dl_lazy = *(getenv ("LD_BIND_NOW") ?: "") == '\0';
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  _dl_bind_not = *(getenv ("LD_BIND_NOT") ?: "") != '\0';
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0';
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  _dl_profile_output = getenv ("LD_PROFILE_OUTPUT");
 | 
				
			||||||
 | 
					-  if (_dl_profile_output == NULL || _dl_profile_output[0] == '\0')
 | 
				
			||||||
 | 
					-    _dl_profile_output
 | 
				
			||||||
 | 
					-      = &"/var/tmp\0/var/profile"[__libc_enable_secure ? 9 : 0];
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					   if (__libc_enable_secure)
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       static const char unsecure_envvars[] =
 | 
				
			||||||
 | 
					@@ -363,6 +340,30 @@ _dl_non_dynamic_init (void)
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+  _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Initialize the data structures for the search paths for shared
 | 
				
			||||||
 | 
					+     objects.  */
 | 
				
			||||||
 | 
					+  _dl_init_paths (getenv ("LD_LIBRARY_PATH"), "LD_LIBRARY_PATH",
 | 
				
			||||||
 | 
					+		  /* No glibc-hwcaps selection support in statically
 | 
				
			||||||
 | 
					+		     linked binaries.  */
 | 
				
			||||||
 | 
					+		  NULL, NULL);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Remember the last search directory added at startup.  */
 | 
				
			||||||
 | 
					+  _dl_init_all_dirs = GL(dl_all_dirs);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  _dl_lazy = *(getenv ("LD_BIND_NOW") ?: "") == '\0';
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  _dl_bind_not = *(getenv ("LD_BIND_NOT") ?: "") != '\0';
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0';
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  _dl_profile_output = getenv ("LD_PROFILE_OUTPUT");
 | 
				
			||||||
 | 
					+  if (_dl_profile_output == NULL || _dl_profile_output[0] == '\0')
 | 
				
			||||||
 | 
					+    _dl_profile_output
 | 
				
			||||||
 | 
					+      = &"/var/tmp\0/var/profile"[__libc_enable_secure ? 9 : 0];
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 #ifdef DL_PLATFORM_INIT
 | 
				
			||||||
 | 
					   DL_PLATFORM_INIT;
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
							
								
								
									
										41
									
								
								SOURCES/glibc-RHEL-92685-4.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								SOURCES/glibc-RHEL-92685-4.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					commit d0b8aa6de4529231fadfe604ac2c434e559c2d9e
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Mon Dec 23 13:57:55 2024 +0100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    support: Add support_record_failure_barrier
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This can be used to stop execution after a TEST_COMPARE_BLOB
 | 
				
			||||||
 | 
					    failure, for example.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/support/check.h b/support/check.h
 | 
				
			||||||
 | 
					index 7ea9a86a9c7ed055..d435479963945bb9 100644
 | 
				
			||||||
 | 
					--- a/support/check.h
 | 
				
			||||||
 | 
					+++ b/support/check.h
 | 
				
			||||||
 | 
					@@ -187,6 +187,9 @@ void support_record_failure_reset (void);
 | 
				
			||||||
 | 
					    failures or not.  */
 | 
				
			||||||
 | 
					 int support_record_failure_is_failed (void);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+/* Terminate the process if any failures have been encountered so far.  */
 | 
				
			||||||
 | 
					+void support_record_failure_barrier (void);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 __END_DECLS
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #endif /* SUPPORT_CHECK_H */
 | 
				
			||||||
 | 
					diff --git a/support/support_record_failure.c b/support/support_record_failure.c
 | 
				
			||||||
 | 
					index 17ab1d80ef2bbdea..8d0f3852dcf60a70 100644
 | 
				
			||||||
 | 
					--- a/support/support_record_failure.c
 | 
				
			||||||
 | 
					+++ b/support/support_record_failure.c
 | 
				
			||||||
 | 
					@@ -112,3 +112,13 @@ support_record_failure_is_failed (void)
 | 
				
			||||||
 | 
					      synchronization for reliable test error reporting anyway.  */
 | 
				
			||||||
 | 
					   return __atomic_load_n (&state->failed, __ATOMIC_RELAXED);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void
 | 
				
			||||||
 | 
					+support_record_failure_barrier (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (__atomic_load_n (&state->failed, __ATOMIC_RELAXED))
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      puts ("error: exiting due to previous errors");
 | 
				
			||||||
 | 
					+      exit (1);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
							
								
								
									
										56
									
								
								SOURCES/glibc-RHEL-92685-5.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								SOURCES/glibc-RHEL-92685-5.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,56 @@
 | 
				
			|||||||
 | 
					commit f0c09fe61678df6f7f18fe1ebff074e62fa5ca7a
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Tue May 20 19:36:02 2025 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    support: Use const char * argument in support_capture_subprogram_self_sgid
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The function does not modify the passed-in string, so make this clear
 | 
				
			||||||
 | 
					    via the prototype.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/support/capture_subprocess.h b/support/capture_subprocess.h
 | 
				
			||||||
 | 
					index 72fb30504684a84e..67c0cd82597805bd 100644
 | 
				
			||||||
 | 
					--- a/support/capture_subprocess.h
 | 
				
			||||||
 | 
					+++ b/support/capture_subprocess.h
 | 
				
			||||||
 | 
					@@ -44,8 +44,7 @@ struct support_capture_subprocess support_capture_subprogram
 | 
				
			||||||
 | 
					 /* Copy the running program into a setgid binary and run it with CHILD_ID
 | 
				
			||||||
 | 
					    argument.  If execution is successful, return the exit status of the child
 | 
				
			||||||
 | 
					    program, otherwise return a non-zero failure exit code.  */
 | 
				
			||||||
 | 
					-int support_capture_subprogram_self_sgid
 | 
				
			||||||
 | 
					-  (char *child_id);
 | 
				
			||||||
 | 
					+int support_capture_subprogram_self_sgid (const char *child_id);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Deallocate the subprocess data captured by
 | 
				
			||||||
 | 
					    support_capture_subprocess.  */
 | 
				
			||||||
 | 
					diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					index af03ea4dc6ec0b95..48c2ab839dca33ea 100644
 | 
				
			||||||
 | 
					--- a/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					+++ b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					@@ -108,7 +108,7 @@ support_capture_subprogram (const char *file, char *const argv[])
 | 
				
			||||||
 | 
					    safely make it SGID with the TARGET group ID.  Then runs the
 | 
				
			||||||
 | 
					    executable.  */
 | 
				
			||||||
 | 
					 static int
 | 
				
			||||||
 | 
					-copy_and_spawn_sgid (char *child_id, gid_t gid)
 | 
				
			||||||
 | 
					+copy_and_spawn_sgid (const char *child_id, gid_t gid)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					   char *dirname = xasprintf ("%s/tst-tunables-setuid.%jd",
 | 
				
			||||||
 | 
					 			     test_dir, (intmax_t) getpid ());
 | 
				
			||||||
 | 
					@@ -180,7 +180,7 @@ copy_and_spawn_sgid (char *child_id, gid_t gid)
 | 
				
			||||||
 | 
					   ret = 0;
 | 
				
			||||||
 | 
					   infd = outfd = -1;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  char * const args[] = {execname, child_id, NULL};
 | 
				
			||||||
 | 
					+  char * const args[] = {execname, (char *) child_id, NULL};
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   status = support_subprogram_wait (args[0], args);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -209,7 +209,7 @@ err:
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 int
 | 
				
			||||||
 | 
					-support_capture_subprogram_self_sgid (char *child_id)
 | 
				
			||||||
 | 
					+support_capture_subprogram_self_sgid (const char *child_id)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					   gid_t target = 0;
 | 
				
			||||||
 | 
					   const int count = 64;
 | 
				
			||||||
							
								
								
									
										159
									
								
								SOURCES/glibc-RHEL-92685-6.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										159
									
								
								SOURCES/glibc-RHEL-92685-6.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,159 @@
 | 
				
			|||||||
 | 
					commit d8f7a79335b0d861c12c42aec94c04cd5bb181e2
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Tue May 20 19:36:02 2025 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elf: Test case for bug 32976 (CVE-2025-4802)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Check that LD_LIBRARY_PATH is ignored for AT_SECURE statically
 | 
				
			||||||
 | 
					    linked binaries, using support_capture_subprogram_self_sgid.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						elf/Makefile
 | 
				
			||||||
 | 
						  ((test list differences, link against libdl))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/elf/Makefile b/elf/Makefile
 | 
				
			||||||
 | 
					index 8ca9f1c13f78216d..38976f195a398abf 100644
 | 
				
			||||||
 | 
					--- a/elf/Makefile
 | 
				
			||||||
 | 
					+++ b/elf/Makefile
 | 
				
			||||||
 | 
					@@ -235,6 +235,7 @@ tests-static-normal := \
 | 
				
			||||||
 | 
					   tst-array1-static \
 | 
				
			||||||
 | 
					   tst-array5-static \
 | 
				
			||||||
 | 
					   tst-dl-iter-static \
 | 
				
			||||||
 | 
					+  tst-dlopen-sgid \
 | 
				
			||||||
 | 
					   tst-dst-static \
 | 
				
			||||||
 | 
					   tst-env-setuid \
 | 
				
			||||||
 | 
					   tst-env-setuid-tunables \
 | 
				
			||||||
 | 
					@@ -726,6 +727,7 @@ modules-names = \
 | 
				
			||||||
 | 
					   tst-dlmopen-gethostbyname-mod \
 | 
				
			||||||
 | 
					   tst-dlmopen-twice-mod1 \
 | 
				
			||||||
 | 
					   tst-dlmopen-twice-mod2 \
 | 
				
			||||||
 | 
					+  tst-dlopen-sgid-mod \
 | 
				
			||||||
 | 
					   tst-dlopen-tlsreinitmod1 \
 | 
				
			||||||
 | 
					   tst-dlopen-tlsreinitmod2 \
 | 
				
			||||||
 | 
					   tst-dlopen-tlsreinitmod3 \
 | 
				
			||||||
 | 
					@@ -2816,3 +2818,6 @@ $(objpfx)tst-dlopen-tlsreinit3.out: $(objpfx)tst-auditmod1.so
 | 
				
			||||||
 | 
					 tst-dlopen-tlsreinit3-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
 | 
				
			||||||
 | 
					 $(objpfx)tst-dlopen-tlsreinit4.out: $(objpfx)tst-auditmod1.so
 | 
				
			||||||
 | 
					 tst-dlopen-tlsreinit4-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+$(objpfx)tst-dlopen-sgid: $(common-objpfx)dlfcn/libdl.a
 | 
				
			||||||
 | 
					+$(objpfx)tst-dlopen-sgid.out: $(objpfx)tst-dlopen-sgid-mod.so
 | 
				
			||||||
 | 
					diff --git a/elf/tst-dlopen-sgid-mod.c b/elf/tst-dlopen-sgid-mod.c
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 0000000000000000..5eb79eef485da4c9
 | 
				
			||||||
 | 
					--- /dev/null
 | 
				
			||||||
 | 
					+++ b/elf/tst-dlopen-sgid-mod.c
 | 
				
			||||||
 | 
					@@ -0,0 +1 @@
 | 
				
			||||||
 | 
					+/* Opening this object should not succeed.  */
 | 
				
			||||||
 | 
					diff --git a/elf/tst-dlopen-sgid.c b/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 0000000000000000..47829a405e90b6b9
 | 
				
			||||||
 | 
					--- /dev/null
 | 
				
			||||||
 | 
					+++ b/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					@@ -0,0 +1,104 @@
 | 
				
			||||||
 | 
					+/* Test case for ignored LD_LIBRARY_PATH in static startug (bug 32976).
 | 
				
			||||||
 | 
					+   Copyright (C) 2025 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					+   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					+   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					+   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					+   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					+   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					+   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#include <dlfcn.h>
 | 
				
			||||||
 | 
					+#include <gnu/lib-names.h>
 | 
				
			||||||
 | 
					+#include <stddef.h>
 | 
				
			||||||
 | 
					+#include <stdint.h>
 | 
				
			||||||
 | 
					+#include <stdlib.h>
 | 
				
			||||||
 | 
					+#include <string.h>
 | 
				
			||||||
 | 
					+#include <support/capture_subprocess.h>
 | 
				
			||||||
 | 
					+#include <support/check.h>
 | 
				
			||||||
 | 
					+#include <support/support.h>
 | 
				
			||||||
 | 
					+#include <support/temp_file.h>
 | 
				
			||||||
 | 
					+#include <unistd.h>
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* This is the name of our test object.  Use a custom module for
 | 
				
			||||||
 | 
					+   testing, so that this object does not get picked up from the system
 | 
				
			||||||
 | 
					+   path.  */
 | 
				
			||||||
 | 
					+static const char dso_name[] = "tst-dlopen-sgid-mod.so";
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* Used to mark the recursive invocation.  */
 | 
				
			||||||
 | 
					+static const char magic_argument[] = "run-actual-test";
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static int
 | 
				
			||||||
 | 
					+do_test (void)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+/* Pathname of the directory that receives the shared objects this
 | 
				
			||||||
 | 
					+   test attempts to load.  */
 | 
				
			||||||
 | 
					+  char *libdir = support_create_temp_directory ("tst-dlopen-sgid-");
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* This is supposed to be ignored and stripped.  */
 | 
				
			||||||
 | 
					+  TEST_COMPARE (setenv ("LD_LIBRARY_PATH", libdir, 1), 0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Copy of libc.so.6.  */
 | 
				
			||||||
 | 
					+  {
 | 
				
			||||||
 | 
					+    char *from = xasprintf ("%s/%s", support_objdir_root, LIBC_SO);
 | 
				
			||||||
 | 
					+    char *to = xasprintf ("%s/%s", libdir, LIBC_SO);
 | 
				
			||||||
 | 
					+    add_temp_file (to);
 | 
				
			||||||
 | 
					+    support_copy_file (from, to);
 | 
				
			||||||
 | 
					+    free (to);
 | 
				
			||||||
 | 
					+    free (from);
 | 
				
			||||||
 | 
					+  }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  /* Copy of the test object.   */
 | 
				
			||||||
 | 
					+  {
 | 
				
			||||||
 | 
					+    char *from = xasprintf ("%s/elf/%s", support_objdir_root, dso_name);
 | 
				
			||||||
 | 
					+    char *to = xasprintf ("%s/%s", libdir, dso_name);
 | 
				
			||||||
 | 
					+    add_temp_file (to);
 | 
				
			||||||
 | 
					+    support_copy_file (from, to);
 | 
				
			||||||
 | 
					+    free (to);
 | 
				
			||||||
 | 
					+    free (from);
 | 
				
			||||||
 | 
					+  }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  TEST_COMPARE (support_capture_subprogram_self_sgid (magic_argument), 0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  free (libdir);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  return 0;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					+alternative_main (int argc, char **argv)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  if (argc == 2 && strcmp (argv[1], magic_argument) == 0)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      if (getgid () == getegid ())
 | 
				
			||||||
 | 
					+        /* This can happen if the file system is mounted nosuid.  */
 | 
				
			||||||
 | 
					+        FAIL_UNSUPPORTED ("SGID failed: GID and EGID match (%jd)\n",
 | 
				
			||||||
 | 
					+                          (intmax_t) getgid ());
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      /* Should be removed due to SGID.  */
 | 
				
			||||||
 | 
					+      TEST_COMPARE_STRING (getenv ("LD_LIBRARY_PATH"), NULL);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      TEST_VERIFY (dlopen (dso_name, RTLD_NOW) == NULL);
 | 
				
			||||||
 | 
					+      {
 | 
				
			||||||
 | 
					+        const char *message = dlerror ();
 | 
				
			||||||
 | 
					+        TEST_COMPARE_STRING (message,
 | 
				
			||||||
 | 
					+                             "tst-dlopen-sgid-mod.so:"
 | 
				
			||||||
 | 
					+                             " cannot open shared object file:"
 | 
				
			||||||
 | 
					+                             " No such file or directory");
 | 
				
			||||||
 | 
					+      }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+      support_record_failure_barrier ();
 | 
				
			||||||
 | 
					+      exit (EXIT_SUCCESS);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+#define PREPARE alternative_main
 | 
				
			||||||
 | 
					+#include <support/test-driver.c>
 | 
				
			||||||
							
								
								
									
										42
									
								
								SOURCES/glibc-RHEL-92685-7.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								SOURCES/glibc-RHEL-92685-7.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					commit 35fc356fa3b4f485bd3ba3114c9f774e5df7d3c2
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Wed May 21 08:43:32 2025 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This should really move into support_capture_subprogram_self_sgid.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Sam James <sam@gentoo.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/elf/tst-dlopen-sgid.c b/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					index 47829a405e90b6b9..5688b79f2e870b1d 100644
 | 
				
			||||||
 | 
					--- a/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					+++ b/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					@@ -26,6 +26,8 @@
 | 
				
			||||||
 | 
					 #include <support/check.h>
 | 
				
			||||||
 | 
					 #include <support/support.h>
 | 
				
			||||||
 | 
					 #include <support/temp_file.h>
 | 
				
			||||||
 | 
					+#include <support/test-driver.h>
 | 
				
			||||||
 | 
					+#include <sys/wait.h>
 | 
				
			||||||
 | 
					 #include <unistd.h>
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* This is the name of our test object.  Use a custom module for
 | 
				
			||||||
 | 
					@@ -66,10 +68,16 @@ do_test (void)
 | 
				
			||||||
 | 
					     free (from);
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  TEST_COMPARE (support_capture_subprogram_self_sgid (magic_argument), 0);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					   free (libdir);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+  int status = support_capture_subprogram_self_sgid (magic_argument);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
 | 
				
			||||||
 | 
					+    return EXIT_UNSUPPORTED;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  if (!WIFEXITED (status))
 | 
				
			||||||
 | 
					+    FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					   return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
							
								
								
									
										105
									
								
								SOURCES/glibc-RHEL-92685-8.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								SOURCES/glibc-RHEL-92685-8.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,105 @@
 | 
				
			|||||||
 | 
					commit 2f769cec448d84a62b7dd0d4ff56978fe22c0cd6
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Wed May 21 16:47:34 2025 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    support: Pick group in support_capture_subprogram_self_sgid if UID == 0
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    When running as root, it is likely that we can run under any group.
 | 
				
			||||||
 | 
					    Pick a harmless group from /etc/group in this case.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					index 48c2ab839dca33ea..774deacd5fe2b6cc 100644
 | 
				
			||||||
 | 
					--- a/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					+++ b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					@@ -21,7 +21,11 @@
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #include <errno.h>
 | 
				
			||||||
 | 
					 #include <fcntl.h>
 | 
				
			||||||
 | 
					+#include <grp.h>
 | 
				
			||||||
 | 
					+#include <scratch_buffer.h>
 | 
				
			||||||
 | 
					+#include <stdio_ext.h>
 | 
				
			||||||
 | 
					 #include <stdlib.h>
 | 
				
			||||||
 | 
					+#include <string.h>
 | 
				
			||||||
 | 
					 #include <support/check.h>
 | 
				
			||||||
 | 
					 #include <support/xunistd.h>
 | 
				
			||||||
 | 
					 #include <support/xsocket.h>
 | 
				
			||||||
 | 
					@@ -208,10 +212,48 @@ err:
 | 
				
			||||||
 | 
					   return status;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+/* Returns true if a group with NAME has been found, and writes its
 | 
				
			||||||
 | 
					+   GID to *TARGET.  */
 | 
				
			||||||
 | 
					+static bool
 | 
				
			||||||
 | 
					+find_sgid_group (gid_t *target, const char *name)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+  /* Do not use getgrname_r because it does not work in statically
 | 
				
			||||||
 | 
					+     linked binaries if the system libc is different.  */
 | 
				
			||||||
 | 
					+  FILE *fp = fopen ("/etc/group", "rce");
 | 
				
			||||||
 | 
					+  if (fp == NULL)
 | 
				
			||||||
 | 
					+    return false;
 | 
				
			||||||
 | 
					+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+  bool ok = false;
 | 
				
			||||||
 | 
					+  struct scratch_buffer buf;
 | 
				
			||||||
 | 
					+  scratch_buffer_init (&buf);
 | 
				
			||||||
 | 
					+  while (true)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      struct group grp;
 | 
				
			||||||
 | 
					+      struct group *result = NULL;
 | 
				
			||||||
 | 
					+      int status = fgetgrent_r (fp, &grp, buf.data, buf.length, &result);
 | 
				
			||||||
 | 
					+      if (status == 0 && result != NULL)
 | 
				
			||||||
 | 
					+	{
 | 
				
			||||||
 | 
					+	  if (strcmp (result->gr_name, name) == 0)
 | 
				
			||||||
 | 
					+	    {
 | 
				
			||||||
 | 
					+	      *target = result->gr_gid;
 | 
				
			||||||
 | 
					+	      ok = true;
 | 
				
			||||||
 | 
					+	      break;
 | 
				
			||||||
 | 
					+	    }
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					+      else if (errno != ERANGE)
 | 
				
			||||||
 | 
					+	break;
 | 
				
			||||||
 | 
					+      else if (!scratch_buffer_grow (&buf))
 | 
				
			||||||
 | 
					+	break;
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					+  scratch_buffer_free (&buf);
 | 
				
			||||||
 | 
					+  fclose (fp);
 | 
				
			||||||
 | 
					+  return ok;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 int
 | 
				
			||||||
 | 
					 support_capture_subprogram_self_sgid (const char *child_id)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-  gid_t target = 0;
 | 
				
			||||||
 | 
					   const int count = 64;
 | 
				
			||||||
 | 
					   gid_t groups[count];
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -223,6 +265,7 @@ support_capture_subprogram_self_sgid (const char *child_id)
 | 
				
			||||||
 | 
					 		     (intmax_t) getuid ());
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   gid_t current = getgid ();
 | 
				
			||||||
 | 
					+  gid_t target = current;
 | 
				
			||||||
 | 
					   for (int i = 0; i < ret; ++i)
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       if (groups[i] != current)
 | 
				
			||||||
 | 
					@@ -232,9 +275,16 @@ support_capture_subprogram_self_sgid (const char *child_id)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  if (target == 0)
 | 
				
			||||||
 | 
					-    FAIL_UNSUPPORTED("Could not find a suitable GID for user %jd\n",
 | 
				
			||||||
 | 
					-		     (intmax_t) getuid ());
 | 
				
			||||||
 | 
					+  if (target == current)
 | 
				
			||||||
 | 
					+    {
 | 
				
			||||||
 | 
					+      /* If running as root, try to find a harmless group for SGID.  */
 | 
				
			||||||
 | 
					+      if (getuid () != 0
 | 
				
			||||||
 | 
					+	  || (!find_sgid_group (&target, "nogroup")
 | 
				
			||||||
 | 
					+	      && !find_sgid_group (&target, "bin")
 | 
				
			||||||
 | 
					+	      && !find_sgid_group (&target, "daemon")))
 | 
				
			||||||
 | 
					+	FAIL_UNSUPPORTED("Could not find a suitable GID for user %jd\n",
 | 
				
			||||||
 | 
					+			 (intmax_t) getuid ());
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   return copy_and_spawn_sgid (child_id, target);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
							
								
								
									
										315
									
								
								SOURCES/glibc-RHEL-92685-9.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										315
									
								
								SOURCES/glibc-RHEL-92685-9.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,315 @@
 | 
				
			|||||||
 | 
					commit 3a3fb2ed83f79100c116c824454095ecfb335ad7
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Thu May 22 14:36:37 2025 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Fix error reporting (false negatives) in SGID tests
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    And simplify the interface of support_capture_subprogram_self_sgid.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Use the existing framework for temporary directories (now with
 | 
				
			||||||
 | 
					    mode 0700) and directory/file deletion.  Handle all execution
 | 
				
			||||||
 | 
					    errors within support_capture_subprogram_self_sgid.  In particular,
 | 
				
			||||||
 | 
					    this includes test failures because the invoked program did not
 | 
				
			||||||
 | 
					    exit with exit status zero.  Existing tests that expect exit
 | 
				
			||||||
 | 
					    status 42 are adjusted to use zero instead.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    In addition, fix callers not to call exit (0) with test failures
 | 
				
			||||||
 | 
					    pending (which may mask them, especially when running with --direct).
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Fixes commit 35fc356fa3b4f485bd3ba3114c9f774e5df7d3c2
 | 
				
			||||||
 | 
					    ("elf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)").
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						elf/tst-env-setuid.c
 | 
				
			||||||
 | 
						  (missing commit 11f7e3dd8fed66e0b8740af440cd3151e55a466f
 | 
				
			||||||
 | 
						   ("elf: Add all malloc tunable to unsecvars") downstream)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/elf/tst-dlopen-sgid.c b/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					index 5688b79f2e870b1d..8aec52e19fc56aba 100644
 | 
				
			||||||
 | 
					--- a/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					+++ b/elf/tst-dlopen-sgid.c
 | 
				
			||||||
 | 
					@@ -70,13 +70,7 @@ do_test (void)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   free (libdir);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  int status = support_capture_subprogram_self_sgid (magic_argument);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
 | 
				
			||||||
 | 
					-    return EXIT_UNSUPPORTED;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  if (!WIFEXITED (status))
 | 
				
			||||||
 | 
					-    FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status);
 | 
				
			||||||
 | 
					+  support_capture_subprogram_self_sgid (magic_argument);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					diff --git a/elf/tst-env-setuid-tunables.c b/elf/tst-env-setuid-tunables.c
 | 
				
			||||||
 | 
					index 8b0861c4ad853040..dfbea3118fa9daf8 100644
 | 
				
			||||||
 | 
					--- a/elf/tst-env-setuid-tunables.c
 | 
				
			||||||
 | 
					+++ b/elf/tst-env-setuid-tunables.c
 | 
				
			||||||
 | 
					@@ -127,10 +127,7 @@ do_test (int argc, char **argv)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       if (ret != 0)
 | 
				
			||||||
 | 
					 	exit (1);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      /* Special return code to make sure that the child executed all the way
 | 
				
			||||||
 | 
					-	 through.  */
 | 
				
			||||||
 | 
					-      exit (42);
 | 
				
			||||||
 | 
					+      return 0;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					   else
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					@@ -149,18 +146,7 @@ do_test (int argc, char **argv)
 | 
				
			||||||
 | 
					 	      continue;
 | 
				
			||||||
 | 
					 	    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	  int status = support_capture_subprogram_self_sgid (buf);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  /* Bail out early if unsupported.  */
 | 
				
			||||||
 | 
					-	  if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
 | 
				
			||||||
 | 
					-	    return EXIT_UNSUPPORTED;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	  if (WEXITSTATUS (status) != 42)
 | 
				
			||||||
 | 
					-	    {
 | 
				
			||||||
 | 
					-	      printf ("    [%d] child failed with status %d\n", i,
 | 
				
			||||||
 | 
					-		      WEXITSTATUS (status));
 | 
				
			||||||
 | 
					-	      support_record_failure ();
 | 
				
			||||||
 | 
					-	    }
 | 
				
			||||||
 | 
					+	  support_capture_subprogram_self_sgid (buf);
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					       return 0;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					diff --git a/elf/tst-env-setuid.c b/elf/tst-env-setuid.c
 | 
				
			||||||
 | 
					index eda87f9dda293e79..04f6b0025fc86cfa 100644
 | 
				
			||||||
 | 
					--- a/elf/tst-env-setuid.c
 | 
				
			||||||
 | 
					+++ b/elf/tst-env-setuid.c
 | 
				
			||||||
 | 
					@@ -103,21 +103,14 @@ do_test (int argc, char **argv)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       if (ret != 0)
 | 
				
			||||||
 | 
					 	exit (1);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      exit (EXIT_SUCCESS);
 | 
				
			||||||
 | 
					+      return 0;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					   else
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       if (test_parent () != 0)
 | 
				
			||||||
 | 
					 	exit (1);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-      int status = support_capture_subprogram_self_sgid (SETGID_CHILD);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
 | 
				
			||||||
 | 
					-	return EXIT_UNSUPPORTED;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-      if (!WIFEXITED (status))
 | 
				
			||||||
 | 
					-	FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status);
 | 
				
			||||||
 | 
					+      support_capture_subprogram_self_sgid (SETGID_CHILD);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					       return 0;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					diff --git a/stdlib/tst-secure-getenv.c b/stdlib/tst-secure-getenv.c
 | 
				
			||||||
 | 
					index 156c92fea216729f..bda73a203498a90f 100644
 | 
				
			||||||
 | 
					--- a/stdlib/tst-secure-getenv.c
 | 
				
			||||||
 | 
					+++ b/stdlib/tst-secure-getenv.c
 | 
				
			||||||
 | 
					@@ -57,13 +57,7 @@ do_test (void)
 | 
				
			||||||
 | 
					       exit (1);
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  int status = support_capture_subprogram_self_sgid (MAGIC_ARGUMENT);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
 | 
				
			||||||
 | 
					-    return EXIT_UNSUPPORTED;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  if (!WIFEXITED (status))
 | 
				
			||||||
 | 
					-    FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status);
 | 
				
			||||||
 | 
					+  support_capture_subprogram_self_sgid (MAGIC_ARGUMENT);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					@@ -82,6 +76,7 @@ alternative_main (int argc, char **argv)
 | 
				
			||||||
 | 
					       if (secure_getenv ("PATH") != NULL)
 | 
				
			||||||
 | 
					 	FAIL_EXIT (4, "PATH variable not filtered out\n");
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+      support_record_failure_barrier ();
 | 
				
			||||||
 | 
					       exit (EXIT_SUCCESS);
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					diff --git a/support/capture_subprocess.h b/support/capture_subprocess.h
 | 
				
			||||||
 | 
					index 67c0cd82597805bd..a7eef351ce1b276c 100644
 | 
				
			||||||
 | 
					--- a/support/capture_subprocess.h
 | 
				
			||||||
 | 
					+++ b/support/capture_subprocess.h
 | 
				
			||||||
 | 
					@@ -41,10 +41,12 @@ struct support_capture_subprocess support_capture_subprocess
 | 
				
			||||||
 | 
					 struct support_capture_subprocess support_capture_subprogram
 | 
				
			||||||
 | 
					   (const char *file, char *const argv[]);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-/* Copy the running program into a setgid binary and run it with CHILD_ID
 | 
				
			||||||
 | 
					-   argument.  If execution is successful, return the exit status of the child
 | 
				
			||||||
 | 
					-   program, otherwise return a non-zero failure exit code.  */
 | 
				
			||||||
 | 
					-int support_capture_subprogram_self_sgid (const char *child_id);
 | 
				
			||||||
 | 
					+/* Copy the running program into a setgid binary and run it with
 | 
				
			||||||
 | 
					+   CHILD_ID argument.  If the program exits with a non-zero status,
 | 
				
			||||||
 | 
					+   exit with that exit status (or status 1 if the program did not exit
 | 
				
			||||||
 | 
					+   normally).  If the test cannot be performed, exit with
 | 
				
			||||||
 | 
					+   EXIT_UNSUPPORTED.  */
 | 
				
			||||||
 | 
					+void support_capture_subprogram_self_sgid (const char *child_id);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Deallocate the subprocess data captured by
 | 
				
			||||||
 | 
					    support_capture_subprocess.  */
 | 
				
			||||||
 | 
					diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					index 774deacd5fe2b6cc..25f79b760a9e414d 100644
 | 
				
			||||||
 | 
					--- a/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					+++ b/support/support_capture_subprocess.c
 | 
				
			||||||
 | 
					@@ -31,6 +31,7 @@
 | 
				
			||||||
 | 
					 #include <support/xsocket.h>
 | 
				
			||||||
 | 
					 #include <support/xspawn.h>
 | 
				
			||||||
 | 
					 #include <support/support.h>
 | 
				
			||||||
 | 
					+#include <support/temp_file.h>
 | 
				
			||||||
 | 
					 #include <support/test-driver.h>
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static void
 | 
				
			||||||
 | 
					@@ -111,105 +112,44 @@ support_capture_subprogram (const char *file, char *const argv[])
 | 
				
			||||||
 | 
					 /* Copies the executable into a restricted directory, so that we can
 | 
				
			||||||
 | 
					    safely make it SGID with the TARGET group ID.  Then runs the
 | 
				
			||||||
 | 
					    executable.  */
 | 
				
			||||||
 | 
					-static int
 | 
				
			||||||
 | 
					+static void
 | 
				
			||||||
 | 
					 copy_and_spawn_sgid (const char *child_id, gid_t gid)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-  char *dirname = xasprintf ("%s/tst-tunables-setuid.%jd",
 | 
				
			||||||
 | 
					-			     test_dir, (intmax_t) getpid ());
 | 
				
			||||||
 | 
					+  char *dirname = support_create_temp_directory ("tst-glibc-sgid-");
 | 
				
			||||||
 | 
					   char *execname = xasprintf ("%s/bin", dirname);
 | 
				
			||||||
 | 
					-  int infd = -1;
 | 
				
			||||||
 | 
					-  int outfd = -1;
 | 
				
			||||||
 | 
					-  int ret = 1, status = 1;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  TEST_VERIFY (mkdir (dirname, 0700) == 0);
 | 
				
			||||||
 | 
					-  if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-    goto err;
 | 
				
			||||||
 | 
					+  add_temp_file (execname);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  infd = open ("/proc/self/exe", O_RDONLY);
 | 
				
			||||||
 | 
					-  if (infd < 0)
 | 
				
			||||||
 | 
					+  if (access ("/proc/self/exe", R_OK) != 0)
 | 
				
			||||||
 | 
					     FAIL_UNSUPPORTED ("unsupported: Cannot read binary from procfs\n");
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  outfd = open (execname, O_WRONLY | O_CREAT | O_EXCL, 0700);
 | 
				
			||||||
 | 
					-  TEST_VERIFY (outfd >= 0);
 | 
				
			||||||
 | 
					-  if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-    goto err;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  char buf[4096];
 | 
				
			||||||
 | 
					-  for (;;)
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					-      ssize_t rdcount = read (infd, buf, sizeof (buf));
 | 
				
			||||||
 | 
					-      TEST_VERIFY (rdcount >= 0);
 | 
				
			||||||
 | 
					-      if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-	goto err;
 | 
				
			||||||
 | 
					-      if (rdcount == 0)
 | 
				
			||||||
 | 
					-	break;
 | 
				
			||||||
 | 
					-      char *p = buf;
 | 
				
			||||||
 | 
					-      char *end = buf + rdcount;
 | 
				
			||||||
 | 
					-      while (p != end)
 | 
				
			||||||
 | 
					-	{
 | 
				
			||||||
 | 
					-	  ssize_t wrcount = write (outfd, buf, end - p);
 | 
				
			||||||
 | 
					-	  if (wrcount == 0)
 | 
				
			||||||
 | 
					-	    errno = ENOSPC;
 | 
				
			||||||
 | 
					-	  TEST_VERIFY (wrcount > 0);
 | 
				
			||||||
 | 
					-	  if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-	    goto err;
 | 
				
			||||||
 | 
					-	  p += wrcount;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					+  support_copy_file ("/proc/self/exe", execname);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  bool chowned = false;
 | 
				
			||||||
 | 
					-  TEST_VERIFY ((chowned = fchown (outfd, getuid (), gid) == 0)
 | 
				
			||||||
 | 
					-	       || errno == EPERM);
 | 
				
			||||||
 | 
					-  if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-    goto err;
 | 
				
			||||||
 | 
					-  else if (!chowned)
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					-      ret = 77;
 | 
				
			||||||
 | 
					-      goto err;
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					+  if (chown (execname, getuid (), gid) != 0)
 | 
				
			||||||
 | 
					+    FAIL_UNSUPPORTED ("cannot change group of \"%s\" to %jd: %m",
 | 
				
			||||||
 | 
					+		      execname, (intmax_t) gid);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  TEST_VERIFY (fchmod (outfd, 02750) == 0);
 | 
				
			||||||
 | 
					-  if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-    goto err;
 | 
				
			||||||
 | 
					-  TEST_VERIFY (close (outfd) == 0);
 | 
				
			||||||
 | 
					-  if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-    goto err;
 | 
				
			||||||
 | 
					-  TEST_VERIFY (close (infd) == 0);
 | 
				
			||||||
 | 
					-  if (support_record_failure_is_failed ())
 | 
				
			||||||
 | 
					-    goto err;
 | 
				
			||||||
 | 
					+  if (chmod (execname, 02750) != 0)
 | 
				
			||||||
 | 
					+    FAIL_UNSUPPORTED ("cannot make \"%s\" SGID: %m ", execname);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   /* We have the binary, now spawn the subprocess.  Avoid using
 | 
				
			||||||
 | 
					      support_subprogram because we only want the program exit status, not the
 | 
				
			||||||
 | 
					      contents.  */
 | 
				
			||||||
 | 
					-  ret = 0;
 | 
				
			||||||
 | 
					-  infd = outfd = -1;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					   char * const args[] = {execname, (char *) child_id, NULL};
 | 
				
			||||||
 | 
					+  int status = support_subprogram_wait (args[0], args);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  status = support_subprogram_wait (args[0], args);
 | 
				
			||||||
 | 
					+  free (execname);
 | 
				
			||||||
 | 
					+  free (dirname);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-err:
 | 
				
			||||||
 | 
					-  if (outfd >= 0)
 | 
				
			||||||
 | 
					-    close (outfd);
 | 
				
			||||||
 | 
					-  if (infd >= 0)
 | 
				
			||||||
 | 
					-    close (infd);
 | 
				
			||||||
 | 
					-  if (execname != NULL)
 | 
				
			||||||
 | 
					-    {
 | 
				
			||||||
 | 
					-      unlink (execname);
 | 
				
			||||||
 | 
					-      free (execname);
 | 
				
			||||||
 | 
					-    }
 | 
				
			||||||
 | 
					-  if (dirname != NULL)
 | 
				
			||||||
 | 
					+  if (WIFEXITED (status))
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					-      rmdir (dirname);
 | 
				
			||||||
 | 
					-      free (dirname);
 | 
				
			||||||
 | 
					+      if (WEXITSTATUS (status) == 0)
 | 
				
			||||||
 | 
					+	return;
 | 
				
			||||||
 | 
					+      else
 | 
				
			||||||
 | 
					+	exit (WEXITSTATUS (status));
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  if (ret == 77)
 | 
				
			||||||
 | 
					-    FAIL_UNSUPPORTED ("Failed to make sgid executable for test\n");
 | 
				
			||||||
 | 
					-  if (ret != 0)
 | 
				
			||||||
 | 
					-    FAIL_EXIT1 ("Failed to make sgid executable for test\n");
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-  return status;
 | 
				
			||||||
 | 
					+  else
 | 
				
			||||||
 | 
					+    FAIL_EXIT1 ("subprogram failed with status %d", status);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* Returns true if a group with NAME has been found, and writes its
 | 
				
			||||||
 | 
					@@ -251,7 +191,7 @@ find_sgid_group (gid_t *target, const char *name)
 | 
				
			||||||
 | 
					   return ok;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-int
 | 
				
			||||||
 | 
					+void
 | 
				
			||||||
 | 
					 support_capture_subprogram_self_sgid (const char *child_id)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					   const int count = 64;
 | 
				
			||||||
 | 
					@@ -286,7 +226,7 @@ support_capture_subprogram_self_sgid (const char *child_id)
 | 
				
			||||||
 | 
					 			 (intmax_t) getuid ());
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-  return copy_and_spawn_sgid (child_id, target);
 | 
				
			||||||
 | 
					+  copy_and_spawn_sgid (child_id, target);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 void
 | 
				
			||||||
							
								
								
									
										25
									
								
								SOURCES/glibc-RHEL-93937-1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								SOURCES/glibc-RHEL-93937-1.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					commit 81a1fa6cbfef5ca33e7eeb11f8f9a528f4dc0117
 | 
				
			||||||
 | 
					Author: Arjun Shankar <arjun@redhat.com>
 | 
				
			||||||
 | 
					Date:   Tue Nov 5 16:41:25 2019 +0100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Fix run-one-test so that it runs elf tests
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    The `test' make target passes a trailing slash in the subdir argument.  This
 | 
				
			||||||
 | 
					    does not play well with elf/rtld-Rules which looks for `elf' without any
 | 
				
			||||||
 | 
					    trailing slash, and therefore doesn't find a match when running an elf test
 | 
				
			||||||
 | 
					    individually.  This commit removes the trailing slash from the invocation.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Reviewed-by: DJ Delorie <dj@redhat.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Makefile b/Makefile
 | 
				
			||||||
 | 
					index 6518f62ee0676b0d..40066189f3f49441 100644
 | 
				
			||||||
 | 
					--- a/Makefile
 | 
				
			||||||
 | 
					+++ b/Makefile
 | 
				
			||||||
 | 
					@@ -518,6 +518,6 @@ iconvdata/% localedata/% po/%: FORCE
 | 
				
			||||||
 | 
					 .PHONY: test
 | 
				
			||||||
 | 
					 test :
 | 
				
			||||||
 | 
					 	@-rm -f $(objpfx)$t.out
 | 
				
			||||||
 | 
					-	$(MAKE) subdir=$(dir $t) -C $(dir $t) ..=../ $(objpfx)$t.out
 | 
				
			||||||
 | 
					+	$(MAKE) subdir=$(patsubst %/,%,$(dir $t)) -C $(dir $t) ..=../ $(objpfx)$t.out
 | 
				
			||||||
 | 
					 	@cat $(objpfx)$t.test-result
 | 
				
			||||||
 | 
					 	@cat $(objpfx)$t.out
 | 
				
			||||||
							
								
								
									
										100
									
								
								SOURCES/glibc-RHEL-93937-2.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								SOURCES/glibc-RHEL-93937-2.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,100 @@
 | 
				
			|||||||
 | 
					commit 2fca4b624bd3ceb8c756b4145c7e96aa032b2b98
 | 
				
			||||||
 | 
					Author: Florian Weimer <fweimer@redhat.com>
 | 
				
			||||||
 | 
					Date:   Wed Jun 4 17:44:19 2025 +0200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Makefile: Avoid $(objpfx)/ in makefiles
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    If paths with both $(objpfx)/ and $(objpfx) (which already includes
 | 
				
			||||||
 | 
					    a trailing slash) appear during the build, this can trigger unexpected
 | 
				
			||||||
 | 
					    rebuilds, or incorrect concurrent rebuilds.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Conflicts:
 | 
				
			||||||
 | 
						elf/Makefile: Test differences.
 | 
				
			||||||
 | 
						nss/Makefile: Test differences.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/elf/Makefile b/elf/Makefile
 | 
				
			||||||
 | 
					index 38976f195a398abf..d09f5482c089f18c 100644
 | 
				
			||||||
 | 
					--- a/elf/Makefile
 | 
				
			||||||
 | 
					+++ b/elf/Makefile
 | 
				
			||||||
 | 
					@@ -1055,8 +1055,8 @@ $(objpfx)$(1).generated-makefile: $(1)
 | 
				
			||||||
 | 
					 endef
 | 
				
			||||||
 | 
					 endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
 | 
				
			||||||
 | 
					-		       $(objpfx)/dso-sort-tests-2.generated-makefile
 | 
				
			||||||
 | 
					+postclean-generated += $(objpfx)dso-sort-tests-2.generated-makefile \
 | 
				
			||||||
 | 
					+		       $(objpfx)dso-sort-tests-2.generated-makefile
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 # Generate from each testcase description file
 | 
				
			||||||
 | 
					 ifeq (yes,$(have-tunables))
 | 
				
			||||||
 | 
					@@ -2674,7 +2674,7 @@ $(objpfx)tst-tls21: $(libdl) $(shared-thread-library)
 | 
				
			||||||
 | 
					 $(objpfx)tst-tls21.out: $(objpfx)tst-tls21mod.so
 | 
				
			||||||
 | 
					 $(objpfx)tst-tls21mod.so: $(tst-tls-many-dynamic-modules:%=$(objpfx)%.so)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-$(objpfx)tst-rtld-run-static.out: $(objpfx)/ldconfig
 | 
				
			||||||
 | 
					+$(objpfx)tst-rtld-run-static.out: $(objpfx)ldconfig
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 $(objpfx)tst-dlmopen-gethostbyname: $(libdl)
 | 
				
			||||||
 | 
					 $(objpfx)tst-dlmopen-gethostbyname.out: $(objpfx)tst-dlmopen-gethostbyname-mod.so
 | 
				
			||||||
 | 
					diff --git a/nss/Makefile b/nss/Makefile
 | 
				
			||||||
 | 
					index 4ee8b1eefd792062..05fcadf60fd0d771 100644
 | 
				
			||||||
 | 
					--- a/nss/Makefile
 | 
				
			||||||
 | 
					+++ b/nss/Makefile
 | 
				
			||||||
 | 
					@@ -172,36 +172,36 @@ libof-nss_test1 = extramodules
 | 
				
			||||||
 | 
					 libof-nss_test2 = extramodules
 | 
				
			||||||
 | 
					 libof-nss_test_errno = extramodules
 | 
				
			||||||
 | 
					 libof-nss_test_gai_hv2_canonname = extramodules
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
 | 
				
			||||||
 | 
					 	$(build-module)
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
 | 
				
			||||||
 | 
					 	$(build-module)
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps)
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps)
 | 
				
			||||||
 | 
					 	$(build-module)
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test_gai_hv2_canonname.so: \
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test_gai_hv2_canonname.so: \
 | 
				
			||||||
 | 
					   $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps) \
 | 
				
			||||||
 | 
					-  $(objpfx)/libnss_files.so
 | 
				
			||||||
 | 
					+  $(objpfx)libnss_files.so
 | 
				
			||||||
 | 
					 	$(build-module)
 | 
				
			||||||
 | 
					 $(objpfx)nss_test2.os : nss_test1.c
 | 
				
			||||||
 | 
					 ifdef libnss_test1.so-version
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test1.so$(libnss_test1.so-version): $(objpfx)libnss_test1.so
 | 
				
			||||||
 | 
					 	$(make-link)
 | 
				
			||||||
 | 
					 endif
 | 
				
			||||||
 | 
					 ifdef libnss_test2.so-version
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test2.so$(libnss_test2.so-version): $(objpfx)libnss_test2.so
 | 
				
			||||||
 | 
					 	$(make-link)
 | 
				
			||||||
 | 
					 endif
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \
 | 
				
			||||||
 | 
					-  $(objpfx)/libnss_test_errno.so
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test_errno.so$(libnss_files.so-version): \
 | 
				
			||||||
 | 
					+  $(objpfx)libnss_test_errno.so
 | 
				
			||||||
 | 
					 	$(make-link)
 | 
				
			||||||
 | 
					-$(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \
 | 
				
			||||||
 | 
					-  $(objpfx)/libnss_test_gai_hv2_canonname.so
 | 
				
			||||||
 | 
					+$(objpfx)libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \
 | 
				
			||||||
 | 
					+  $(objpfx)libnss_test_gai_hv2_canonname.so
 | 
				
			||||||
 | 
					 	$(make-link)
 | 
				
			||||||
 | 
					 $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
 | 
				
			||||||
 | 
					-	$(objpfx)/libnss_test1.so$(libnss_test1.so-version) \
 | 
				
			||||||
 | 
					-	$(objpfx)/libnss_test2.so$(libnss_test2.so-version) \
 | 
				
			||||||
 | 
					-	$(objpfx)/libnss_test_errno.so$(libnss_files.so-version) \
 | 
				
			||||||
 | 
					-	$(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version)
 | 
				
			||||||
 | 
					+	$(objpfx)libnss_test1.so$(libnss_test1.so-version) \
 | 
				
			||||||
 | 
					+	$(objpfx)libnss_test2.so$(libnss_test2.so-version) \
 | 
				
			||||||
 | 
					+	$(objpfx)libnss_test_errno.so$(libnss_files.so-version) \
 | 
				
			||||||
 | 
					+	$(objpfx)libnss_test_gai_hv2_canonname.so$(libnss_files.so-version)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 ifeq (yes,$(have-thread-library))
 | 
				
			||||||
 | 
					 $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
 | 
				
			||||||
 | 
					@@ -211,4 +211,4 @@ $(objpfx)tst-nss-files-hosts-erange: $(libdl)
 | 
				
			||||||
 | 
					 $(objpfx)tst-nss-files-hosts-multi: $(libdl)
 | 
				
			||||||
 | 
					 $(objpfx)tst-nss-files-hosts-getent: $(libdl)
 | 
				
			||||||
 | 
					 $(objpfx)tst-nss-files-alias-leak: $(libdl)
 | 
				
			||||||
 | 
					-$(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so
 | 
				
			||||||
 | 
					+$(objpfx)tst-nss-files-alias-leak.out: $(objpfx)libnss_files.so
 | 
				
			||||||
							
								
								
									
										872
									
								
								SPECS/glibc.spec
									
									
									
									
									
								
							
							
						
						
									
										872
									
								
								SPECS/glibc.spec
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user