Sync from SUSE:ALP:Source:Standard:1.0 glibc revision 058493c2c68e50f1893f9c004487a7d3

This commit is contained in:
Adrian Schröter 2024-03-15 15:55:46 +01:00
parent 35d5193285
commit e22ea755a4
3 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,57 @@
From 513331b788a3fa633f1d0417d43915e16a0c88f0 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Wed, 6 Mar 2024 12:59:47 +0100
Subject: [PATCH] duplocale: protect use of global locale (bug 23970)
Protect the global locale from being modified while we compute the size of
the locale category names. That allows the use of the global locale in a
single thread, while all other threads use the thread safe locale
functions.
---
locale/duplocale.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/locale/duplocale.c b/locale/duplocale.c
index a755ac5c36..bad476700f 100644
--- a/locale/duplocale.c
+++ b/locale/duplocale.c
@@ -43,6 +43,11 @@ __duplocale (locale_t dataset)
int cnt;
size_t names_len = 0;
+ /* If dataset points to _nl_global_locale, we need to prevent other
+ threads from modifying it. We also modify global data below (the
+ usage counts). */
+ __libc_rwlock_wrlock (__libc_setlocale_lock);
+
/* Calculate the total space we need to store all the names. */
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL && dataset->__names[cnt] != _nl_C_name)
@@ -55,9 +60,6 @@ __duplocale (locale_t dataset)
{
char *namep = (char *) (result + 1);
- /* We modify global data (the usage counts). */
- __libc_rwlock_wrlock (__libc_setlocale_lock);
-
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL)
{
@@ -78,11 +80,11 @@ __duplocale (locale_t dataset)
result->__ctype_b = dataset->__ctype_b;
result->__ctype_tolower = dataset->__ctype_tolower;
result->__ctype_toupper = dataset->__ctype_toupper;
-
- /* It's done. */
- __libc_rwlock_unlock (__libc_setlocale_lock);
}
+ /* It's done. */
+ __libc_rwlock_unlock (__libc_setlocale_lock);
+
return result;
}
weak_alias (__duplocale, duplocale)
--
2.44.0

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Mar 11 10:06:42 UTC 2024 - Andreas Schwab <schwab@suse.de>
- duplocale-global-locale.patch: duplocale: protect use of global locale
(bsc#1220441, BZ #23970)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Feb 26 12:48:48 UTC 2024 - Andreas Schwab <schwab@suse.de> Mon Feb 26 12:48:48 UTC 2024 - Andreas Schwab <schwab@suse.de>

View File

@ -341,6 +341,8 @@ Patch1021: syslog-buffer-overflow.patch
Patch1022: qsort-invalid-cmp.patch Patch1022: qsort-invalid-cmp.patch
# PATCH-FIX-UPSTREAM S390: Do not clobber r7 in clone (BZ #31402) # PATCH-FIX-UPSTREAM S390: Do not clobber r7 in clone (BZ #31402)
Patch1023: s390-clone-error-clobber-r7.patch Patch1023: s390-clone-error-clobber-r7.patch
# PATCH-FIX-UPSTREAM duplocale: protect use of global locale (BZ #23970)
Patch1024: duplocale-global-locale.patch
### ###
# Patches awaiting upstream approval # Patches awaiting upstream approval