Accepting request 1157905 from Base:System

- stdbit-builtins.patch: Use gcc __builtin_stdc_* builtins in stdbit.h if
  possible

- sigisemptyset.patch: linux/sigsetops: fix type confusion (BZ #31468)

- duplocale-global-locale.patch: duplocale: protect use of global locale
  (bsc#1220441, BZ #23970) (forwarded request 1157904 from Andreas_Schwab)

OBS-URL: https://build.opensuse.org/request/show/1157905
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/glibc?expand=0&rev=288
This commit is contained in:
Ana Guerrero 2024-03-18 15:43:09 +00:00 committed by Git OBS Bridge
commit 69b88c814f
5 changed files with 1271 additions and 2 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,20 @@
-------------------------------------------------------------------
Wed Mar 13 08:31:20 UTC 2024 - Andreas Schwab <schwab@suse.de>
- stdbit-builtins.patch: Use gcc __builtin_stdc_* builtins in stdbit.h if
possible
-------------------------------------------------------------------
Tue Mar 12 09:13:02 UTC 2024 - Andreas Schwab <schwab@suse.de>
- sigisemptyset.patch: linux/sigsetops: fix type confusion (BZ #31468)
-------------------------------------------------------------------
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)
-------------------------------------------------------------------
Tue Feb 27 08:14:31 UTC 2024 - Ludwig Nussel <lnussel@suse.com>

View File

@ -1,5 +1,5 @@
#
# spec file for package glibc
# spec file
#
# Copyright (c) 2024 SUSE LLC
#
@ -306,6 +306,12 @@ Patch306: glibc-fix-double-loopback.diff
Patch1000: arm-dl-start-user.patch
# PATCH-FIX-UPSTREAM S390: Do not clobber r7 in clone (BZ #31402)
Patch1001: s390-clone-error-clobber-r7.patch
# PATCH-FIX-UPSTREAM duplocale: protect use of global locale (BZ #23970)
Patch1002: duplocale-global-locale.patch
# PATCH-FIX-UPSTREAM linux/sigsetops: fix type confusion (BZ #31468)
Patch1003: sigisemptyset.patch
# PATCH-FIX-UPSTREAM Use gcc __builtin_stdc_* builtins in stdbit.h if possible
Patch1004: stdbit-builtins.patch
%endif
###
@ -351,7 +357,7 @@ Summary: Info Files for the GNU C Library
License: GFDL-1.1-only
Group: Documentation/Other
Requires(post): %{install_info_prereq}
Requires(preun): %{install_info_prereq}
Requires(preun):%{install_info_prereq}
BuildArch: noarch
%description info

128
sigisemptyset.patch Normal file
View File

@ -0,0 +1,128 @@
From 2173173d57971d042c0ad4b281431ae127e9b5b8 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Mon, 11 Mar 2024 15:13:09 +0100
Subject: [PATCH] linux/sigsetops: fix type confusion (bug 31468)
Each mask in the sigset array is an unsigned long, so fix __sigisemptyset
to use that instead of int. The __sigword function returns a simple array
index, so it can return int instead of unsigned long.
---
signal/tst-sigisemptyset.c | 11 +++++++++++
sysdeps/unix/sysv/linux/internal-sigset.h | 8 ++++----
sysdeps/unix/sysv/linux/sigsetops.h | 10 +++++-----
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/signal/tst-sigisemptyset.c b/signal/tst-sigisemptyset.c
index f5e35e8c22..11e7f39d09 100644
--- a/signal/tst-sigisemptyset.c
+++ b/signal/tst-sigisemptyset.c
@@ -89,6 +89,17 @@ do_test (void)
TEST_COMPARE (sigisemptyset (&set), 1);
}
+ {
+ sigset_t set;
+ for (int sig = 1; sig <= NSIG; sig++)
+ {
+ sigemptyset (&set);
+ if (sigaddset (&set, sig) < 0)
+ continue;
+ TEST_COMPARE (sigisemptyset (&set), 0);
+ }
+ }
+
return 0;
}
diff --git a/sysdeps/unix/sysv/linux/internal-sigset.h b/sysdeps/unix/sysv/linux/internal-sigset.h
index 3c21c3b6d5..5d7020b42d 100644
--- a/sysdeps/unix/sysv/linux/internal-sigset.h
+++ b/sysdeps/unix/sysv/linux/internal-sigset.h
@@ -54,7 +54,7 @@ static inline int
internal_sigisemptyset (const internal_sigset_t *set)
{
int cnt = __NSIG_WORDS;
- int ret = set->__val[--cnt];
+ unsigned long int ret = set->__val[--cnt];
while (ret == 0 && --cnt >= 0)
ret = set->__val[cnt];
return ret == 0;
@@ -82,7 +82,7 @@ static inline int
internal_sigismember (const internal_sigset_t *set, int sig)
{
unsigned long int mask = __sigmask (sig);
- unsigned long int word = __sigword (sig);
+ int word = __sigword (sig);
return set->__val[word] & mask ? 1 : 0;
}
@@ -90,7 +90,7 @@ static inline void
internal_sigaddset (internal_sigset_t *set, int sig)
{
unsigned long int mask = __sigmask (sig);
- unsigned long int word = __sigword (sig);
+ int word = __sigword (sig);
set->__val[word] |= mask;
}
@@ -98,7 +98,7 @@ static inline void
internal_sigdelset (internal_sigset_t *set, int sig)
{
unsigned long int mask = __sigmask (sig);
- unsigned long int word = __sigword (sig);
+ int word = __sigword (sig);
set->__val[word] &= ~mask;
}
diff --git a/sysdeps/unix/sysv/linux/sigsetops.h b/sysdeps/unix/sysv/linux/sigsetops.h
index abd5576172..33db4f77b8 100644
--- a/sysdeps/unix/sysv/linux/sigsetops.h
+++ b/sysdeps/unix/sysv/linux/sigsetops.h
@@ -28,7 +28,7 @@
(1UL << (((sig) - 1) % ULONG_WIDTH))
/* Return the word index for SIG. */
-static inline unsigned long int
+static inline int
__sigword (int sig)
{
return (sig - 1) / ULONG_WIDTH;
@@ -66,7 +66,7 @@ static inline int
__sigisemptyset (const sigset_t *set)
{
int cnt = __NSIG_WORDS;
- int ret = set->__val[--cnt];
+ unsigned long int ret = set->__val[--cnt];
while (ret == 0 && --cnt >= 0)
ret = set->__val[cnt];
return ret == 0;
@@ -92,7 +92,7 @@ static inline int
__sigismember (const sigset_t *set, int sig)
{
unsigned long int mask = __sigmask (sig);
- unsigned long int word = __sigword (sig);
+ int word = __sigword (sig);
return set->__val[word] & mask ? 1 : 0;
}
@@ -100,7 +100,7 @@ static inline void
__sigaddset (sigset_t *set, int sig)
{
unsigned long int mask = __sigmask (sig);
- unsigned long int word = __sigword (sig);
+ int word = __sigword (sig);
set->__val[word] |= mask;
}
@@ -108,7 +108,7 @@ static inline void
__sigdelset (sigset_t *set, int sig)
{
unsigned long int mask = __sigmask (sig);
- unsigned long int word = __sigword (sig);
+ int word = __sigword (sig);
set->__val[word] &= ~mask;
}
--
2.44.0

1061
stdbit-builtins.patch Normal file

File diff suppressed because it is too large Load Diff