!308 backport some bugfix patches from mainline

Merge pull request !308 from liqingqing_1229/2203
This commit is contained in:
openeuler-ci-bot 2022-01-11 20:09:18 +00:00 committed by Gitee
commit ec23701fa2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 918 additions and 1 deletions

View File

@ -0,0 +1,55 @@
From e5fa62b8db546f8792ec9e5c61e6419f4f8e3f4d Mon Sep 17 00:00:00 2001
From: Wilco Dijkstra <wdijkstr@arm.com>
Date: Thu, 6 Jan 2022 14:36:28 +0000
Subject: [PATCH] AArch64: Check for SVE in ifuncs [BZ #28744]
Add a check for SVE in the A64FX ifuncs for memcpy, memset and memmove.
This fixes BZ #28744.
---
sysdeps/aarch64/multiarch/memcpy.c | 2 +-
sysdeps/aarch64/multiarch/memmove.c | 2 +-
sysdeps/aarch64/multiarch/memset.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sysdeps/aarch64/multiarch/memcpy.c b/sysdeps/aarch64/multiarch/memcpy.c
index 7dac7b7..a476dd5 100644
--- a/sysdeps/aarch64/multiarch/memcpy.c
+++ b/sysdeps/aarch64/multiarch/memcpy.c
@@ -48,7 +48,7 @@ libc_ifunc (__libc_memcpy,
|| IS_NEOVERSE_V1 (midr)
? __memcpy_simd
# if HAVE_AARCH64_SVE_ASM
- : (IS_A64FX (midr)
+ : (IS_A64FX (midr) && sve
? __memcpy_a64fx
: __memcpy_generic))))));
# else
diff --git a/sysdeps/aarch64/multiarch/memmove.c b/sysdeps/aarch64/multiarch/memmove.c
index 48f8e46..4f7d7ee 100644
--- a/sysdeps/aarch64/multiarch/memmove.c
+++ b/sysdeps/aarch64/multiarch/memmove.c
@@ -48,7 +48,7 @@ libc_ifunc (__libc_memmove,
|| IS_NEOVERSE_V1 (midr)
? __memmove_simd
# if HAVE_AARCH64_SVE_ASM
- : (IS_A64FX (midr)
+ : (IS_A64FX (midr) && sve
? __memmove_a64fx
: __memmove_generic))))));
# else
diff --git a/sysdeps/aarch64/multiarch/memset.c b/sysdeps/aarch64/multiarch/memset.c
index 3692b07..c4008f3 100644
--- a/sysdeps/aarch64/multiarch/memset.c
+++ b/sysdeps/aarch64/multiarch/memset.c
@@ -44,7 +44,7 @@ libc_ifunc (__libc_memset,
: (IS_EMAG (midr) && zva_size == 64
? __memset_emag
# if HAVE_AARCH64_SVE_ASM
- : (IS_A64FX (midr)
+ : (IS_A64FX (midr) && sve
? __memset_a64fx
: __memset_generic))));
# else
--
1.8.3.1

View File

@ -0,0 +1,31 @@
From 645277434a42efc547d2cac8bfede4da10b4049f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 13 Sep 2021 22:49:45 -0700
Subject: [PATCH] Fix subscript error with odd TZif file [BZ #28338]
* time/tzfile.c (__tzfile_compute): Fix unlikely off-by-one bug
that accessed before start of an array when an oddball-but-valid
TZif file was queried with an unusual time_t value.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
time/tzfile.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/time/tzfile.c b/time/tzfile.c
index 4377018..190a777 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -765,8 +765,7 @@ __tzfile_compute (__time64_t timer, int use_localtime,
*leap_correct = leaps[i].change;
if (timer == leaps[i].transition /* Exactly at the transition time. */
- && ((i == 0 && leaps[i].change > 0)
- || leaps[i].change > leaps[i - 1].change))
+ && (leaps[i].change > (i == 0 ? 0 : leaps[i - 1].change)))
{
*leap_hit = 1;
while (i > 0
--
1.8.3.1

View File

@ -0,0 +1,158 @@
From 01bffc013cdad1e0c45db7aa57efb2bee61f3338 Mon Sep 17 00:00:00 2001
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Fri, 29 Oct 2021 14:53:55 +0530
Subject: [PATCH] Handle NULL input to malloc_usable_size [BZ #28506]
Hoist the NULL check for malloc_usable_size into its entry points in
malloc-debug and malloc and assume non-NULL in all callees. This fixes
BZ #28506
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit 88e316b06414ee7c944cd6f8b30b07a972b78499)
---
malloc/malloc-debug.c | 13 +++++++------
malloc/malloc.c | 25 +++++++++----------------
malloc/tst-malloc-usable.c | 22 +++++++++-------------
3 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c
index 9922ef5..3d7e6d4 100644
--- a/malloc/malloc-debug.c
+++ b/malloc/malloc-debug.c
@@ -1,5 +1,6 @@
/* Malloc debug DSO.
Copyright (C) 2021 Free Software Foundation, Inc.
+ 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
@@ -399,17 +400,17 @@ strong_alias (__debug_calloc, calloc)
size_t
malloc_usable_size (void *mem)
{
+ if (mem == NULL)
+ return 0;
+
if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
return mcheck_usable_size (mem);
if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
return malloc_check_get_size (mem);
- if (mem != NULL)
- {
- mchunkptr p = mem2chunk (mem);
- if (DUMPED_MAIN_ARENA_CHUNK (p))
- return chunksize (p) - SIZE_SZ;
- }
+ mchunkptr p = mem2chunk (mem);
+ if (DUMPED_MAIN_ARENA_CHUNK (p))
+ return chunksize (p) - SIZE_SZ;
return musable (mem);
}
diff --git a/malloc/malloc.c b/malloc/malloc.c
index e065785..7882c70 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1,5 +1,6 @@
/* Malloc implementation for multiple threads without lock contention.
Copyright (C) 1996-2021 Free Software Foundation, Inc.
+ Copyright The GNU Toolchain Authors.
This file is part of the GNU C Library.
Contributed by Wolfram Gloger <wg@malloc.de>
and Doug Lea <dl@cs.oswego.edu>, 2001.
@@ -5009,20 +5010,13 @@ __malloc_trim (size_t s)
static size_t
musable (void *mem)
{
- mchunkptr p;
- if (mem != 0)
- {
- size_t result = 0;
-
- p = mem2chunk (mem);
+ mchunkptr p = mem2chunk (mem);
- if (chunk_is_mmapped (p))
- result = chunksize (p) - CHUNK_HDR_SZ;
- else if (inuse (p))
- result = memsize (p);
+ if (chunk_is_mmapped (p))
+ return chunksize (p) - CHUNK_HDR_SZ;
+ else if (inuse (p))
+ return memsize (p);
- return result;
- }
return 0;
}
@@ -5030,10 +5024,9 @@ musable (void *mem)
size_t
__malloc_usable_size (void *m)
{
- size_t result;
-
- result = musable (m);
- return result;
+ if (m == NULL)
+ return 0;
+ return musable (m);
}
#endif
diff --git a/malloc/tst-malloc-usable.c b/malloc/tst-malloc-usable.c
index a1074b7..b0d702b 100644
--- a/malloc/tst-malloc-usable.c
+++ b/malloc/tst-malloc-usable.c
@@ -2,6 +2,7 @@
MALLOC_CHECK_ exported to a positive value.
Copyright (C) 2012-2021 Free Software Foundation, Inc.
+ 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
@@ -21,29 +22,24 @@
#include <malloc.h>
#include <string.h>
#include <stdio.h>
+#include <support/support.h>
+#include <support/check.h>
static int
do_test (void)
{
size_t usable_size;
void *p = malloc (7);
- if (!p)
- {
- printf ("memory allocation failed\n");
- return 1;
- }
+ TEST_VERIFY_EXIT (p != NULL);
usable_size = malloc_usable_size (p);
- if (usable_size != 7)
- {
- printf ("malloc_usable_size: expected 7 but got %zu\n", usable_size);
- return 1;
- }
-
+ TEST_COMPARE (usable_size, 7);
memset (p, 0, usable_size);
free (p);
+
+ TEST_COMPARE (malloc_usable_size (NULL), 0);
+
return 0;
}
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include "support/test-driver.c"
--
1.8.3.1

View File

@ -0,0 +1,73 @@
From ea32ec354c65ddad11b82ca9d057010df13a9cea Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 5 Nov 2021 17:01:24 +0100
Subject: [PATCH] elf: Earlier missing dynamic segment check in
_dl_map_object_from_fd
Separated debuginfo files have PT_DYNAMIC with p_filesz == 0. We
need to check for that before the _dl_map_segments call because
that could attempt to write to mappings that extend beyond the end
of the file, resulting in SIGBUS.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
---
elf/dl-load.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/elf/dl-load.c b/elf/dl-load.c
index a1f1682..9f4fa96 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1135,6 +1135,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
struct loadcmd loadcmds[l->l_phnum];
size_t nloadcmds = 0;
bool has_holes = false;
+ bool empty_dynamic = false;
/* The struct is initialized to zero so this is not necessary:
l->l_ld = 0;
@@ -1147,7 +1148,9 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
segments are mapped in. We record the addresses it says
verbatim, and later correct for the run-time load address. */
case PT_DYNAMIC:
- if (ph->p_filesz)
+ if (ph->p_filesz == 0)
+ empty_dynamic = true; /* Usually separate debuginfo. */
+ else
{
/* Debuginfo only files from "objcopy --only-keep-debug"
contain a PT_DYNAMIC segment with p_filesz == 0. Skip
@@ -1270,6 +1273,13 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
goto lose;
}
+ /* This check recognizes most separate debuginfo files. */
+ if (__glibc_unlikely ((l->l_ld == 0 && type == ET_DYN) || empty_dynamic))
+ {
+ errstring = N_("object file has no dynamic section");
+ goto lose;
+ }
+
/* Length of the sections to be loaded. */
maplength = loadcmds[nloadcmds - 1].allocend - loadcmds[0].mapstart;
@@ -1287,15 +1297,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
}
}
- if (l->l_ld == 0)
- {
- if (__glibc_unlikely (type == ET_DYN))
- {
- errstring = N_("object file has no dynamic section");
- goto lose;
- }
- }
- else
+ if (l->l_ld != 0)
l->l_ld = (ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
elf_get_dynamic_info (l);
--
1.8.3.1

View File

@ -65,7 +65,7 @@
##############################################################################
Name: glibc
Version: 2.34
Release: 40
Release: 41
Summary: The GNU libc libraries
License: %{all_license}
URL: http://www.gnu.org/software/glibc/
@ -147,6 +147,17 @@ Patch60: Do-not-define-tgmath.h-fmaxmag-fminmag-macros-for-C2.patch
Patch61: ld.so-Don-t-fill-the-DT_DEBUG-entry-in-ld.so-BZ-2812.patch
Patch62: elf-Replace-nsid-with-args.nsid-BZ-27609.patch
Patch63: support-Also-return-fd-when-it-is-0.patch
Patch64: elf-Earlier-missing-dynamic-segment-check-in-_dl_map.patch
Patch65: Handle-NULL-input-to-malloc_usable_size-BZ-28506.patch
Patch66: intl-plural.y-Avoid-conflicting-declarations-of-yyer.patch
Patch67: linux-Use-proc-stat-fallback-for-__get_nprocs_conf-B.patch
Patch68: nptl-Do-not-set-signal-mask-on-second-setjmp-return-.patch
Patch69: nss-Use-files-dns-as-the-default-for-the-hosts-datab.patch
Patch70: timex-Use-64-bit-fields-on-32-bit-TIMESIZE-64-system.patch
Patch71: AArch64-Check-for-SVE-in-ifuncs-BZ-28744.patch
Patch72: Fix-subscript-error-with-odd-TZif-file-BZ-28338.patch
Patch73: timezone-handle-truncated-timezones-from-tzcode-2021.patch
Patch74: timezone-test-case-for-BZ-28707.patch
Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
@ -1349,6 +1360,19 @@ fi
%endif
%changelog
* Mon Jan 10 2022 Qingqing Li <liqingqing3@huawei.com> - 2.34-41
- timex: Use 64-bit fields on 32-bit TIMESIZE=64 systems. BZ #28469
- malloc: Handle NULL input to malloc usable size. BZ #28506
- elf: Earlier missing dynamic segment check in _dl_map_object_from_fd
- nptl: Do not set signal mask on second setjmp return. BZ #28607
- linux: use /proc/stat fallback for __get_nprocs_conf. BZ #28624
- nss: Use "file dns" as the default for the hosts database. BZ #28700
- int/plural.y: Avoid conflicting declarations of yyerror and yylex
- aarch64: Check for SVE in ifuncs BZ #28744
- Fix subscript error with odd TZif file BZ #28338
- timezone: handle truncated timezones from tzcode 2021
- timezone: test case for BZ #28707
* Mon Jan 10 2022 Yang Yanchao <yangyanchao6@huawei.com> - 2.34-40
- rpm-build move find-debuginfo.sh into debugedit.
and change the path from "/usr/lib/rpm" to "/usr/bin"

View File

@ -0,0 +1,42 @@
From c6d7d6312c21bbcfb236d48bb7c11cedb234389f Mon Sep 17 00:00:00 2001
From: Andrea Monaco <andrea.monaco@autistici.org>
Date: Sun, 12 Dec 2021 10:24:28 +0100
Subject: [PATCH] intl/plural.y: Avoid conflicting declarations of yyerror and
yylex
bison-3.8 includes these lines in the generated intl/plural.c:
#if !defined __gettexterror && !defined YYERROR_IS_DECLARED
void __gettexterror (struct parse_args *arg, const char *msg);
#endif
#if !defined __gettextlex && !defined YYLEX_IS_DECLARED
int __gettextlex (YYSTYPE *yylvalp, struct parse_args *arg);
#endif
Those default prototypes provided by bison conflict with the
declarations later on in plural.y. This patch solves the issue.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
---
intl/plural.y | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/intl/plural.y b/intl/plural.y
index e02e745..2ee128b 100644
--- a/intl/plural.y
+++ b/intl/plural.y
@@ -40,6 +40,11 @@
# define __gettextparse PLURAL_PARSE
#endif
+/* Later we provide those prototypes. Without these macros, bison may
+ generate its own prototypes with possible conflicts. */
+#define YYLEX_IS_DECLARED
+#define YYERROR_IS_DECLARED
+
%}
%parse-param {struct parse_args *arg}
%lex-param {struct parse_args *arg}
--
1.8.3.1

View File

@ -0,0 +1,102 @@
From 137ed5ac440a4d3cf4178ce97f349b349a9c2c66 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu, 25 Nov 2021 09:12:00 -0300
Subject: [PATCH] linux: Use /proc/stat fallback for __get_nprocs_conf (BZ
#28624)
The /proc/statm fallback was removed by f13fb81ad3159 if sysfs is
not available, reinstate it.
Checked on x86_64-linux-gnu.
---
sysdeps/unix/sysv/linux/getsysstats.c | 60 ++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 15ad91c..d376f05 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -107,6 +107,37 @@ next_line (int fd, char *const buffer, char **cp, char **re,
return res == *re ? NULL : res;
}
+static int
+get_nproc_stat (char *buffer, size_t buffer_size)
+{
+ char *buffer_end = buffer + buffer_size;
+ char *cp = buffer_end;
+ char *re = buffer_end;
+
+ /* Default to an SMP system in case we cannot obtain an accurate
+ number. */
+ int result = 2;
+
+ const int flags = O_RDONLY | O_CLOEXEC;
+ int fd = __open_nocancel ("/proc/stat", flags);
+ if (fd != -1)
+ {
+ result = 0;
+
+ char *l;
+ while ((l = next_line (fd, buffer, &cp, &re, buffer_end)) != NULL)
+ /* The current format of /proc/stat has all the cpu* entries
+ at the front. We assume here that stays this way. */
+ if (strncmp (l, "cpu", 3) != 0)
+ break;
+ else if (isdigit (l[3]))
+ ++result;
+
+ __close_nocancel_nostatus (fd);
+ }
+
+ return result;
+}
int
__get_nprocs (void)
@@ -162,30 +193,7 @@ __get_nprocs (void)
return result;
}
- cp = buffer_end;
- re = buffer_end;
-
- /* Default to an SMP system in case we cannot obtain an accurate
- number. */
- result = 2;
-
- fd = __open_nocancel ("/proc/stat", flags);
- if (fd != -1)
- {
- result = 0;
-
- while ((l = next_line (fd, buffer, &cp, &re, buffer_end)) != NULL)
- /* The current format of /proc/stat has all the cpu* entries
- at the front. We assume here that stays this way. */
- if (strncmp (l, "cpu", 3) != 0)
- break;
- else if (isdigit (l[3]))
- ++result;
-
- __close_nocancel_nostatus (fd);
- }
-
- return result;
+ return get_nproc_stat (buffer, buffer_size);
}
libc_hidden_def (__get_nprocs)
weak_alias (__get_nprocs, get_nprocs)
@@ -219,7 +227,9 @@ __get_nprocs_conf (void)
return count;
}
- return 1;
+ enum { buffer_size = 1024 };
+ char buffer[buffer_size];
+ return get_nproc_stat (buffer, buffer_size);
}
libc_hidden_def (__get_nprocs_conf)
weak_alias (__get_nprocs_conf, get_nprocs_conf)
--
1.8.3.1

View File

@ -0,0 +1,111 @@
From bfe68fe3c475fe34bed4e017d6e63196c305c934 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Wed, 24 Nov 2021 08:59:54 +0100
Subject: [PATCH] nptl: Do not set signal mask on second setjmp return [BZ
#28607]
__libc_signal_restore_set was in the wrong place: It also ran
when setjmp returned the second time (after pthread_exit or
pthread_cancel). This is observable with blocked pending
signals during thread exit.
Fixes commit b3cae39dcbfa2432b3f3aa28854d8ac57f0de1b8
("nptl: Start new threads with all signals blocked [BZ #25098]").
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit e186fc5a31e46f2cbf5ea1a75223b4412907f3d8)
---
nptl/pthread_create.c | 4 +--
sysdeps/pthread/Makefile | 1 +
sysdeps/pthread/tst-pthread-exit-signal.c | 45 +++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 2 deletions(-)
create mode 100644 sysdeps/pthread/tst-pthread-exit-signal.c
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index bc213f0..3db0c9f 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -407,8 +407,6 @@ start_thread (void *arg)
unwind_buf.priv.data.prev = NULL;
unwind_buf.priv.data.cleanup = NULL;
- __libc_signal_restore_set (&pd->sigmask);
-
/* Allow setxid from now onwards. */
if (__glibc_unlikely (atomic_exchange_acq (&pd->setxid_futex, 0) == -2))
futex_wake (&pd->setxid_futex, 1, FUTEX_PRIVATE);
@@ -418,6 +416,8 @@ start_thread (void *arg)
/* Store the new cleanup handler info. */
THREAD_SETMEM (pd, cleanup_jmp_buf, &unwind_buf);
+ __libc_signal_restore_set (&pd->sigmask);
+
LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
/* Run the code the user provided. */
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index df8943f..c657101 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -118,6 +118,7 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
tst-unload \
tst-unwind-thread \
tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
+ tst-pthread-exit-signal \
tst-pthread-setuid-loop \
tst-pthread_cancel-exited \
tst-pthread_cancel-select-loop \
diff --git a/sysdeps/pthread/tst-pthread-exit-signal.c b/sysdeps/pthread/tst-pthread-exit-signal.c
new file mode 100644
index 0000000..b4526fe
--- /dev/null
+++ b/sysdeps/pthread/tst-pthread-exit-signal.c
@@ -0,0 +1,45 @@
+/* Test that pending signals are not delivered on thread exit (bug 28607).
+ Copyright (C) 2021 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/>. */
+
+/* Due to bug 28607, pthread_kill (or pthread_cancel) restored the
+ signal mask during during thread exit, triggering the delivery of a
+ blocked pending signal (SIGUSR1 in this test). */
+
+#include <support/xthread.h>
+#include <support/xsignal.h>
+
+static void *
+threadfunc (void *closure)
+{
+ sigset_t sigmask;
+ sigfillset (&sigmask);
+ xpthread_sigmask (SIG_SETMASK, &sigmask, NULL);
+ xpthread_kill (pthread_self (), SIGUSR1);
+ pthread_exit (NULL);
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ pthread_t thr = xpthread_create (NULL, threadfunc, NULL);
+ xpthread_join (thr);
+ return 0;
+}
+
+#include <support/test-driver.c>
--
1.8.3.1

View File

@ -0,0 +1,81 @@
From b99b0f93ee8762fe53ff65802deb6f00700b9924 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 17 Dec 2021 12:01:20 +0100
Subject: [PATCH] nss: Use "files dns" as the default for the hosts database
(bug 28700)
This matches what is currently in nss/nsswitch.conf. The new ordering
matches what most distributions use in their installed configuration
files.
It is common to add localhost to /etc/hosts because the name does not
exist in the DNS, but is commonly used as a host name.
With the built-in "dns [!UNAVAIL=return] files" default, dns is
searched first and provides an answer for "localhost" (NXDOMAIN).
We never look at the files database as a result, so the contents of
/etc/hosts is ignored. This means that "getent hosts localhost"
fail without a /etc/nsswitch.conf file, even though the host name
is listed in /etc/hosts.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
---
manual/nss.texi | 5 ++---
nss/XXX-lookup.c | 2 +-
nss/nss_database.c | 4 ++--
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/manual/nss.texi b/manual/nss.texi
index 3aaa778..524d22a 100644
--- a/manual/nss.texi
+++ b/manual/nss.texi
@@ -324,9 +324,8 @@ missing.
@cindex default value, and NSS
For the @code{hosts} and @code{networks} databases the default value is
-@code{dns [!UNAVAIL=return] files}. I.e., the system is prepared for
-the DNS service not to be available but if it is available the answer it
-returns is definitive.
+@code{files dns}. I.e., local configuration will override the contents
+of the domain name system (DNS).
The @code{passwd}, @code{group}, and @code{shadow} databases was
traditionally handled in a special way. The appropriate files in the
diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c
index 302c636..e129f69 100644
--- a/nss/XXX-lookup.c
+++ b/nss/XXX-lookup.c
@@ -28,7 +28,7 @@
|* ALTERNATE_NAME - name of another service which is examined in *|
|* case DATABASE_NAME is not found *|
|* *|
-|* DEFAULT_CONFIG - string for default conf (e.g. "dns files") *|
+|* DEFAULT_CONFIG - string for default conf (e.g. "files dns") *|
|* *|
\*******************************************************************/
diff --git a/nss/nss_database.c b/nss/nss_database.c
index ab121cb..54561f0 100644
--- a/nss/nss_database.c
+++ b/nss/nss_database.c
@@ -80,7 +80,7 @@ enum nss_database_default
{
nss_database_default_defconfig = 0, /* "nis [NOTFOUND=return] files". */
nss_database_default_compat, /* "compat [NOTFOUND=return] files". */
- nss_database_default_dns, /* "dns [!UNAVAIL=return] files". */
+ nss_database_default_dns, /* "files dns". */
nss_database_default_files, /* "files". */
nss_database_default_nis, /* "nis". */
nss_database_default_nis_nisplus, /* "nis nisplus". */
@@ -133,7 +133,7 @@ nss_database_select_default (struct nss_database_default_cache *cache,
#endif
case nss_database_default_dns:
- line = "dns [!UNAVAIL=return] files";
+ line = "files dns";
break;
case nss_database_default_files:
--
1.8.3.1

View File

@ -0,0 +1,45 @@
From 1d550265a75b412cea4889a50b101395f6a8e025 Mon Sep 17 00:00:00 2001
From: Stafford Horne <shorne@gmail.com>
Date: Fri, 15 Oct 2021 06:17:41 +0900
Subject: [PATCH] timex: Use 64-bit fields on 32-bit TIMESIZE=64 systems (BZ
#28469)
This was found when testing the OpenRISC port I am working on. These
two tests fail with SIGSEGV:
FAIL: misc/tst-ntp_gettime
FAIL: misc/tst-ntp_gettimex
This was found to be due to the kernel overwriting the stack space
allocated by the timex structure. The reason for the overwrite being
that the kernel timex has 64-bit fields and user space code only
allocates enough stack space for timex with 32-bit fields.
On 32-bit systems with TIMESIZE=64 __USE_TIME_BITS64 is not defined.
This causes the timex structure to use 32-bit fields with type
__syscall_slong_t.
This patch adjusts the ifdef condition to allow 32-bit systems with
TIMESIZE=64 to use the 64-bit long long timex definition.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
sysdeps/unix/sysv/linux/bits/timex.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/bits/timex.h b/sysdeps/unix/sysv/linux/bits/timex.h
index ee37694..4a5db6d 100644
--- a/sysdeps/unix/sysv/linux/bits/timex.h
+++ b/sysdeps/unix/sysv/linux/bits/timex.h
@@ -25,7 +25,7 @@
struct timex
{
-# ifdef __USE_TIME_BITS64
+# if defined __USE_TIME_BITS64 || (__TIMESIZE == 64 && __WORDSIZE == 32)
unsigned int modes; /* mode selector */
int :32; /* pad */
long long offset; /* time offset (usec) */
--
1.8.3.1

View File

@ -0,0 +1,57 @@
From c36f64aa6dff13b12a1e03a185e75a50fa9f6a4c Mon Sep 17 00:00:00 2001
From: Hans-Peter Nilsson <hp@axis.com>
Date: Fri, 17 Dec 2021 21:38:00 +0100
Subject: [PATCH] timezone: handle truncated timezones from tzcode-2021d and
later (BZ #28707)
When using a timezone file with a truncated starting time,
generated by the zic in IANA tzcode-2021d a.k.a. tzlib-2021d
(also in tzlib-2021e; current as of this writing), glibc
asserts in __tzfile_read (on e.g. tzset() for this file) and
you may find lines matching "tzfile.c:435: __tzfile_read:
Assertion `num_types == 1' failed" in your syslog.
One example of such a file is the tzfile for Asuncion
generated by tzlib-2021e as follows, using the tzlib-2021e zic:
"zic -d DEST -r @1546300800 -L /dev/null -b slim
SOURCE/southamerica". Note that in its type 2 header, it has
two entries in its "time-types" array (types), but only one
entry in its "transition types" array (type_idxs).
This is valid and expected already in the published RFC8536, and
not even frowned upon: "Local time for timestamps before the
first transition is specified by the first time type (time type
0)" ... "every nonzero local time type index SHOULD appear at
least once in the transition type array". Note the "nonzero ...
index". Until the 2021d zic, index 0 has been shared by the
first valid transition but with 2021d it's separate, set apart
as a placeholder and only "implicitly" indexed. (A draft update
of the RFC mandates that the entry at index 0 is a placeholder
in this case, hence can no longer be shared.)
* time/tzfile.c (__tzfile_read): Don't assert when no transitions
are found.
Co-authored-by: Christopher Wong <Christopher.Wong@axis.com>
---
time/tzfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/time/tzfile.c b/time/tzfile.c
index 190a777..8668392 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -431,8 +431,8 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
if (__tzname[0] == NULL)
{
/* This should only happen if there are no transition rules.
- In this case there should be only one single type. */
- assert (num_types == 1);
+ In this case there's usually only one single type, unless
+ e.g. the data file has a truncated time-range. */
__tzname[0] = __tzstring (zone_names);
}
if (__tzname[1] == NULL)
--
1.8.3.1

View File

@ -0,0 +1,138 @@
From ebe899af0dc3215159a9c896ac6f35b72a18cb6e Mon Sep 17 00:00:00 2001
From: Hans-Peter Nilsson <hp@axis.com>
Date: Fri, 17 Dec 2021 21:45:54 +0100
Subject: [PATCH] timezone: test-case for BZ #28707
This test-case is the tzfile for Asuncion generated by
tzlib-2021e as follows, using the tzlib-2021e zic: "zic -d
DEST -r @1546300800 -L /dev/null -b slim
SOURCE/southamerica". Note that in its type 2 header, it
has two entries in its "time-types" array (types), but only
one entry in its "transition types" array (type_idxs).
* timezone/Makefile, timezone/tst-pr28707.c,
timezone/testdata/gen-XT5.sh: New test.
Co-authored-by: Christopher Wong <Christopher.Wong@axis.com>
---
timezone/Makefile | 8 +++++++-
timezone/testdata/gen-XT5.sh | 16 +++++++++++++++
timezone/tst-bz28707.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletion(-)
create mode 100755 timezone/testdata/gen-XT5.sh
create mode 100644 timezone/tst-bz28707.c
diff --git a/timezone/Makefile b/timezone/Makefile
index c624a18..f091663 100644
--- a/timezone/Makefile
+++ b/timezone/Makefile
@@ -23,7 +23,7 @@ subdir := timezone
include ../Makeconfig
others := zdump zic
-tests := test-tz tst-timezone tst-tzset
+tests := test-tz tst-timezone tst-tzset tst-bz28707
generated-dirs += testdata
@@ -85,10 +85,12 @@ $(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
America/Sao_Paulo Asia/Tokyo \
Europe/London)
$(objpfx)tst-tzset.out: $(addprefix $(testdata)/XT, 1 2 3 4)
+$(objpfx)tst-bz28707.out: $(testdata)/XT5
test-tz-ENV = TZDIR=$(testdata)
tst-timezone-ENV = TZDIR=$(testdata)
tst-tzset-ENV = TZDIR=$(testdata)
+tst-bz28707-ENV = TZDIR=$(testdata)
# Note this must come second in the deps list for $(built-program-cmd) to work.
zic-deps = $(objpfx)zic $(leapseconds) yearistype
@@ -122,6 +124,10 @@ $(testdata)/XT%: testdata/XT%
$(make-target-directory)
cp $< $@
+$(testdata)/XT%: testdata/gen-XT%.sh
+ $(SHELL) $< > $@.tmp
+ mv $@.tmp $@
+
$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
sed -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
-e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
diff --git a/timezone/testdata/gen-XT5.sh b/timezone/testdata/gen-XT5.sh
new file mode 100755
index 0000000..3cea056
--- /dev/null
+++ b/timezone/testdata/gen-XT5.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+# This test-case is the tzfile for America/Asuncion
+# generated by tzlib-2021e as follows, using the tzlib-2021e
+# zic: "zic -d DEST -r @1546300800 -L /dev/null -b slim
+# SOURCE/southamerica". Note that in its type 2 header, it
+# has two entries in its "time-types" array (types), but
+# only one entry in its "transition types" array
+# (type_idxs).
+
+printf \
+'TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'\
+'\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0TZif2\0\0\0\0\0\0\0\0'\
+'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\2\0\0\0\b\0'\
+'\0\0\0\*\255\200\1\0\0\0\0\0\0\377\377\325\320\1\4-00\0-03\0\n'\
+'<-04>4<-03>,M10.1.0/0,M3.4.0/0\n'
diff --git a/timezone/tst-bz28707.c b/timezone/tst-bz28707.c
new file mode 100644
index 0000000..0a9df1e
--- /dev/null
+++ b/timezone/tst-bz28707.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2021 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 <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Test that we can use a truncated timezone-file, where the time-type
+ at index 0 is not indexed by the transition-types array (and the
+ transition-types array does not contain at least both one DST and one
+ normal time members). */
+
+static int
+do_test (void)
+{
+ if (setenv ("TZ", "XT5", 1))
+ {
+ puts ("setenv failed.");
+ return 1;
+ }
+
+ tzset ();
+
+ return
+ /* Sanity-check that we got the right timezone-name for DST. For
+ normal time, we're likely to get "-00" (the "unspecified" marker),
+ even though the POSIX timezone string says "-04". Let's not test
+ that. */
+ !(strcmp (tzname[1], "-03") == 0);
+}
+#include <support/test-driver.c>
--
1.8.3.1