diff -Nru glibc-2.36/debian/changelog glibc-2.36/debian/changelog --- glibc-2.36/debian/changelog 2022-09-20 01:53:55.000000000 +0200 +++ glibc-2.36/debian/changelog 2022-10-05 22:15:30.000000000 +0200 @@ -1,3 +1,25 @@ +glibc (2.36-0ubuntu4) UNRELEASED; urgency=medium + + * Enable building for the 'arc' architecture. (LP: #1991652) + * Cherry-pick patches from upstream maintenance branch: + - 0020-01-scripts-dso-ordering-test.py-Generate-program-run-ti.patch + - 0020-02-elf-Rename-_dl_sort_maps-parameter-from-skip-to-forc.patch + - 0021-elf-Implement-force_first-handling-in-_dl_sort_maps_.patch + - 0022-gconv-Use-64-bit-interfaces-in-gconv_parseconfdir-bu.patch + - 0023-01-x86-include-BMI1-and-BMI2-in-x86-64-v3-level.patch + - 0023-02-x86-64-Require-BMI2-for-AVX2-str-n-casecmp-implement.patch + - 0023-03-x86-64-Require-BMI2-for-AVX2-strcmp-implementation.patch + - 0023-04-x86-64-Require-BMI2-for-AVX2-strncmp-implementation.patch + - 0023-05-x86-64-Require-BMI2-for-AVX2-wcs-n-cmp-implementatio.patch + - 0023-06-x86-64-Require-BMI2-for-AVX2-raw-w-memchr-implementa.patch + - 0023-07-x86-64-Require-BMI2-and-LZCNT-for-AVX2-memrchr-imple.patch + - 0023-08-x86-64-Require-BMI1-BMI2-for-AVX2-strrchr-and-wcsrch.patch + - 0024-nscd-Drop-local-address-tuple-variable-BZ-29607.patch + - 0025-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch + - 0026-stdlib-Fix-__getrandom_nocancel-type-and-arc4random-.patch + + -- Michael Hudson-Doyle Thu, 06 Oct 2022 09:15:30 +1300 + glibc (2.36-0ubuntu3) kinetic; urgency=medium * Remove patches that are now in upstream release branch: diff -Nru glibc-2.36/debian/control glibc-2.36/debian/control --- glibc-2.36/debian/control 2022-09-18 23:56:05.000000000 +0200 +++ glibc-2.36/debian/control 2022-10-05 22:15:30.000000000 +0200 @@ -157,7 +157,7 @@ slow services like LDAP, NIS or NIS+. Package: libc6 -Architecture: amd64 arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 +Architecture: amd64 arc arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 Section: libs Priority: optional Multi-Arch: same @@ -191,7 +191,7 @@ and the standard math library, as well as many others. Package: libc6-dev -Architecture: amd64 arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 +Architecture: amd64 arc arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 Section: libdevel Priority: optional Multi-Arch: same @@ -206,7 +206,7 @@ and link programs which use the standard C library. Package: libc6-dbg -Architecture: amd64 arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 +Architecture: amd64 arc arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 Section: debug Priority: optional Multi-Arch: same @@ -219,7 +219,7 @@ Package: libc6-udeb Package-Type: udeb -Architecture: amd64 arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 +Architecture: amd64 arc arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 sparc sparc64 s390x sh3 sh4 x32 Section: debian-installer Priority: optional Depends: libcrypt1-udeb diff -Nru glibc-2.36/debian/maint/state.txt glibc-2.36/debian/maint/state.txt --- glibc-2.36/debian/maint/state.txt 2022-09-19 00:46:43.000000000 +0200 +++ glibc-2.36/debian/maint/state.txt 2022-10-05 22:15:30.000000000 +0200 @@ -94,6 +94,47 @@ FirstPatch: 0019-elf-Fix-hwcaps-string-size-overestimation.patch 4b95b6e8bbb5a2b6856f707bf3bc3308ebef595a elf: Fix hwcaps string size overestimation +YES +# Dependencies for the next patch ( https://sourceware.org/bugzilla/show_bug.cgi?id=28937 ) +FirstPatch: 0020-01-scripts-dso-ordering-test.py-Generate-program-run-ti.patch +7a3f8c8a7aeb41d4bbfeec07d0be1e92c3019919 scripts/dso-ordering-test.py: Generate program run-time dependencies +d1241cf00139733de069c84933cd576dc1a1f45e elf: Rename _dl_sort_maps parameter from skip to force_first + +YES +FirstPatch: 0021-elf-Implement-force_first-handling-in-_dl_sort_maps_.patch +da5f134f6d59701a3a6119309ae91c93c3fa5b51 elf: Implement force_first handling in _dl_sort_maps_dfs (bug 28937) + +YES +# We want this one for armhf I guess? +FirstPatch: 0022-gconv-Use-64-bit-interfaces-in-gconv_parseconfdir-bu.patch +52c037f3574eb9062b111d78a4cbeb79681d07d3 gconv: Use 64-bit interfaces in gconv_parseconfdir (bug 29583) + +YES +FirstPatch: 0023-01-x86-include-BMI1-and-BMI2-in-x86-64-v3-level.patch +18bec23cbb4d530a2a8ce95353770661fabcd55f x86: include BMI1 and BMI2 in x86-64-v3 level +46479e5d10ed87825aa277da158d6a687974518b x86-64: Require BMI2 for AVX2 str(n)casecmp implementations +7afbd1e56acb721031bffd876f275dcb1af7e530 x86-64: Require BMI2 for AVX2 strcmp implementation +29c577e0f54fe6e70ceacb3659179781c5569903 x86-64: Require BMI2 for AVX2 strncmp implementation +d8bf4388df679fa5a3ae7889a649e573e3124530 x86-64: Require BMI2 for AVX2 wcs(n)cmp implementations +d9196d4f3fa9997388655813ddd236426a16dd92 x86-64: Require BMI2 for AVX2 (raw|w)memchr implementations +923c3f3c373f499e62160e00831dda576443317b x86-64: Require BMI2 and LZCNT for AVX2 memrchr implementation +2d8ef784bd6a784496a6fd460de6b6f57c70a501 x86-64: Require BMI1/BMI2 for AVX2 strrchr and wcsrchr implementations + +YES +# needed because we included the faulty rewrite in our patchset +FirstPatch: 0024-nscd-Drop-local-address-tuple-variable-BZ-29607.patch +2bd815d8347851212b9a91dbdca8053f4dbdac87 nscd: Drop local address tuple variable [BZ #29607] + +YES +# This one worries me because of the comments in https://sourceware.org/bugzilla/show_bug.cgi?id=29605 saying that it breaks stuff with the resolver rewrite, which we included. +FirstPatch: 0025-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch +227c9035872fc9e9e2cf56ec8f89219747ee19bc get_nscd_addresses: Fix subscript typos [BZ #29605] + +YES +# Do we care about Trusty ? get_random() syscall is available on newer releases +FirstPatch: 0026-stdlib-Fix-__getrandom_nocancel-type-and-arc4random-.patch +76e05613ee28f4ac4a0ab97effc32e0e78e37a56 stdlib: Fix __getrandom_nocancel type and arc4random usage (BZ #29638) + NO # We don't seem to hit this particular issue? 33f1b4c1452b33991e670f636ebe98b90a405e10 wcsmbs: Add missing test-c8rtomb/test-mbrtoc8 dependency @@ -101,3 +142,12 @@ NO 302bc33bc53c787da6e74162a7092e9c0fb964a8 elf: Replace `strcpy` call with `memcpy` [BZ #29454] +NO +2628500f5dff1dd99c49a09b418b3b1ea3a6b5d3 m68k: Enforce 4-byte alignment on internal locks (BZ #29537) + +NO +d1d8379bff34f02f86f82db2cef5bf66746d3560 hppa: Fix initialization of dp register [BZ 29635] + +NO +cdc496eb55e30f8f2461bedb0a7381c0a7a3d3ae hppa: undef __ASSUME_SET_ROBUST_LIST + diff -Nru glibc-2.36/debian/patches/series glibc-2.36/debian/patches/series --- glibc-2.36/debian/patches/series 2022-09-19 00:46:24.000000000 +0200 +++ glibc-2.36/debian/patches/series 2022-10-05 22:15:30.000000000 +0200 @@ -35,6 +35,21 @@ upstream-updates/0017-NEWS-Note-bug-12154-and-bug-29305-as-fixed.patch upstream-updates/0018-elf-Run-tst-audit-tlsdesc-tst-audit-tlsdesc-dlopen-e.patch upstream-updates/0019-elf-Fix-hwcaps-string-size-overestimation.patch +upstream-updates/0020-01-scripts-dso-ordering-test.py-Generate-program-run-ti.patch +upstream-updates/0020-02-elf-Rename-_dl_sort_maps-parameter-from-skip-to-forc.patch +upstream-updates/0021-elf-Implement-force_first-handling-in-_dl_sort_maps_.patch +upstream-updates/0022-gconv-Use-64-bit-interfaces-in-gconv_parseconfdir-bu.patch +upstream-updates/0023-01-x86-include-BMI1-and-BMI2-in-x86-64-v3-level.patch +upstream-updates/0023-02-x86-64-Require-BMI2-for-AVX2-str-n-casecmp-implement.patch +upstream-updates/0023-03-x86-64-Require-BMI2-for-AVX2-strcmp-implementation.patch +upstream-updates/0023-04-x86-64-Require-BMI2-for-AVX2-strncmp-implementation.patch +upstream-updates/0023-05-x86-64-Require-BMI2-for-AVX2-wcs-n-cmp-implementatio.patch +upstream-updates/0023-06-x86-64-Require-BMI2-for-AVX2-raw-w-memchr-implementa.patch +upstream-updates/0023-07-x86-64-Require-BMI2-and-LZCNT-for-AVX2-memrchr-imple.patch +upstream-updates/0023-08-x86-64-Require-BMI1-BMI2-for-AVX2-strrchr-and-wcsrch.patch +upstream-updates/0024-nscd-Drop-local-address-tuple-variable-BZ-29607.patch +upstream-updates/0025-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch +upstream-updates/0026-stdlib-Fix-__getrandom_nocancel-type-and-arc4random-.patch locale/check-unknown-symbols.diff locale/locale-print-LANGUAGE.diff diff -Nru glibc-2.36/debian/patches/upstream-updates/0020-01-scripts-dso-ordering-test.py-Generate-program-run-ti.patch glibc-2.36/debian/patches/upstream-updates/0020-01-scripts-dso-ordering-test.py-Generate-program-run-ti.patch --- glibc-2.36/debian/patches/upstream-updates/0020-01-scripts-dso-ordering-test.py-Generate-program-run-ti.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0020-01-scripts-dso-ordering-test.py-Generate-program-run-ti.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,44 @@ +From 7a3f8c8a7aeb41d4bbfeec07d0be1e92c3019919 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Tue, 6 Sep 2022 07:38:10 +0200 +Subject: [PATCH] scripts/dso-ordering-test.py: Generate program run-time + dependencies + +The main program needs to depend on all shared objects, even objects +that have link-time dependencies among shared objects. Filtering +out shared objects that already have an link-time dependencies is not +necessary here; make will do this automatically. + +Reviewed-by: Adhemerval Zanella +(cherry picked from commit 183d99737298bb3200f0610fdcd1c7549c8ed560) +--- + scripts/dso-ordering-test.py | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +diff --git a/scripts/dso-ordering-test.py b/scripts/dso-ordering-test.py +index 2dd6bfda18..b87cf2f809 100644 +--- a/scripts/dso-ordering-test.py ++++ b/scripts/dso-ordering-test.py +@@ -707,13 +707,12 @@ def process_testcase(t): + "\t$(compile.c) $(OUTPUT_OPTION)\n") + makefile.write (rule) + +- not_depended_objs = find_objs_not_depended_on(test_descr) +- if not_depended_objs: +- depstr = "" +- for dep in not_depended_objs: +- depstr += (" $(objpfx)" + test_subdir + "/" +- + test_name + "-" + dep + ".so") +- makefile.write("$(objpfx)%s.out:%s\n" % (base_test_name, depstr)) ++ # Ensure that all shared objects are built before running the ++ # test, whether there link-time dependencies or not. ++ depobjs = ["$(objpfx){}/{}-{}.so".format(test_subdir, test_name, dep) ++ for dep in test_descr.objs] ++ makefile.write("$(objpfx){}.out: {}\n".format( ++ base_test_name, " ".join(depobjs))) + + # Add main executable to test-srcs + makefile.write("test-srcs += %s/%s\n" % (test_subdir, test_name)) +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0020-02-elf-Rename-_dl_sort_maps-parameter-from-skip-to-forc.patch glibc-2.36/debian/patches/upstream-updates/0020-02-elf-Rename-_dl_sort_maps-parameter-from-skip-to-forc.patch --- glibc-2.36/debian/patches/upstream-updates/0020-02-elf-Rename-_dl_sort_maps-parameter-from-skip-to-forc.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0020-02-elf-Rename-_dl_sort_maps-parameter-from-skip-to-forc.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,86 @@ +From d1241cf00139733de069c84933cd576dc1a1f45e Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Tue, 6 Sep 2022 07:38:10 +0200 +Subject: [PATCH] elf: Rename _dl_sort_maps parameter from skip to force_first + +The new implementation will not be able to skip an arbitrary number +of objects. + +Reviewed-by: Adhemerval Zanella +(cherry picked from commit dbb75513f5cf9285c77c9e55777c5c35b653f890) +--- + elf/dl-sort-maps.c | 14 +++++++------- + sysdeps/generic/ldsodefs.h | 6 ++++-- + 2 files changed, 11 insertions(+), 9 deletions(-) + +diff --git a/elf/dl-sort-maps.c b/elf/dl-sort-maps.c +index 96638d7ed1..5b550b1e94 100644 +--- a/elf/dl-sort-maps.c ++++ b/elf/dl-sort-maps.c +@@ -27,12 +27,12 @@ + If FOR_FINI is true, this is called for finishing an object. */ + static void + _dl_sort_maps_original (struct link_map **maps, unsigned int nmaps, +- unsigned int skip, bool for_fini) ++ bool force_first, bool for_fini) + { + /* Allows caller to do the common optimization of skipping the first map, + usually the main binary. */ +- maps += skip; +- nmaps -= skip; ++ maps += force_first; ++ nmaps -= force_first; + + /* A list of one element need not be sorted. */ + if (nmaps <= 1) +@@ -182,7 +182,7 @@ dfs_traversal (struct link_map ***rpo, struct link_map *map, + + static void + _dl_sort_maps_dfs (struct link_map **maps, unsigned int nmaps, +- unsigned int skip __attribute__ ((unused)), bool for_fini) ++ bool force_first __attribute__ ((unused)), bool for_fini) + { + for (int i = nmaps - 1; i >= 0; i--) + maps[i]->l_visited = 0; +@@ -286,7 +286,7 @@ _dl_sort_maps_init (void) + + void + _dl_sort_maps (struct link_map **maps, unsigned int nmaps, +- unsigned int skip, bool for_fini) ++ bool force_first, bool for_fini) + { + /* It can be tempting to use a static function pointer to store and call + the current selected sorting algorithm routine, but experimentation +@@ -296,9 +296,9 @@ _dl_sort_maps (struct link_map **maps, unsigned int nmaps, + input cases. A simple if-case with direct function calls appears to + be the fastest. */ + if (__glibc_likely (GLRO(dl_dso_sort_algo) == dso_sort_algorithm_original)) +- _dl_sort_maps_original (maps, nmaps, skip, for_fini); ++ _dl_sort_maps_original (maps, nmaps, force_first, for_fini); + else +- _dl_sort_maps_dfs (maps, nmaps, skip, for_fini); ++ _dl_sort_maps_dfs (maps, nmaps, force_first, for_fini); + } + + #endif /* HAVE_TUNABLES. */ +diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h +index 050a3032de..6b256b8388 100644 +--- a/sysdeps/generic/ldsodefs.h ++++ b/sysdeps/generic/ldsodefs.h +@@ -1048,9 +1048,11 @@ extern void _dl_init (struct link_map *main_map, int argc, char **argv, + initializer functions have completed. */ + extern void _dl_fini (void) attribute_hidden; + +-/* Sort array MAPS according to dependencies of the contained objects. */ ++/* Sort array MAPS according to dependencies of the contained objects. ++ If FORCE_FIRST, MAPS[0] keeps its place even if the dependencies ++ say otherwise. */ + extern void _dl_sort_maps (struct link_map **maps, unsigned int nmaps, +- unsigned int skip, bool for_fini) attribute_hidden; ++ bool force_first, bool for_fini) attribute_hidden; + + /* The dynamic linker calls this function before and having changing + any shared object mappings. The `r_state' member of `struct r_debug' +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0021-elf-Implement-force_first-handling-in-_dl_sort_maps_.patch glibc-2.36/debian/patches/upstream-updates/0021-elf-Implement-force_first-handling-in-_dl_sort_maps_.patch --- glibc-2.36/debian/patches/upstream-updates/0021-elf-Implement-force_first-handling-in-_dl_sort_maps_.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0021-elf-Implement-force_first-handling-in-_dl_sort_maps_.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,114 @@ +From da5f134f6d59701a3a6119309ae91c93c3fa5b51 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Tue, 20 Sep 2022 11:00:42 +0200 +Subject: [PATCH] elf: Implement force_first handling in _dl_sort_maps_dfs (bug + 28937) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The implementation in _dl_close_worker requires that the first +element of l_initfini is always this very map (“We are always the +zeroth entry, and since we don't include ourselves in the +dependency analysis start at 1.”). Rather than fixing that +assumption, this commit adds an implementation of the force_first +argument to the new dependency sorting algorithm. This also means +that the directly dlopen'ed shared object is always initialized last, +which is the least surprising behavior in the presence of cycles. + +Reviewed-by: Adhemerval Zanella +(cherry picked from commit 1df71d32fe5f5905ffd5d100e5e9ca8ad6210891) +--- + NEWS | 1 + + elf/dl-sort-maps.c | 32 +++++++++++++++++++++++--------- + elf/dso-sort-tests-1.def | 7 +++++++ + 3 files changed, 31 insertions(+), 9 deletions(-) + +diff --git a/NEWS b/NEWS +index 03281e3ab4..5b4753416f 100644 +--- a/NEWS ++++ b/NEWS +@@ -20,6 +20,7 @@ The following bugs are resolved with this release: + [28846] CMSG_NXTHDR may trigger -Wstrict-overflow warning + [29305] Conserve NSS buffer space during DNS packet parsing + [29415] nscd: Fix netlink cache invalidation if epoll is used ++ [28937] New DSO dependency sorter does not put new map first if in a cycle + [29446] _dlopen now ignores dl_caller argument in static mode + [29485] Linux: Terminate subprocess on late failure in tst-pidfd + [29490] alpha: New __brk_call implementation is broken +diff --git a/elf/dl-sort-maps.c b/elf/dl-sort-maps.c +index 5b550b1e94..3e2a6a584e 100644 +--- a/elf/dl-sort-maps.c ++++ b/elf/dl-sort-maps.c +@@ -182,8 +182,9 @@ dfs_traversal (struct link_map ***rpo, struct link_map *map, + + static void + _dl_sort_maps_dfs (struct link_map **maps, unsigned int nmaps, +- bool force_first __attribute__ ((unused)), bool for_fini) ++ bool force_first, bool for_fini) + { ++ struct link_map *first_map = maps[0]; + for (int i = nmaps - 1; i >= 0; i--) + maps[i]->l_visited = 0; + +@@ -208,14 +209,6 @@ _dl_sort_maps_dfs (struct link_map **maps, unsigned int nmaps, + Adjusting the order so that maps[0] is last traversed naturally avoids + this problem. + +- Further, the old "optimization" of skipping the main object at maps[0] +- from the call-site (i.e. _dl_sort_maps(maps+1,nmaps-1)) is in general +- no longer valid, since traversing along object dependency-links +- may "find" the main object even when it is not included in the initial +- order (e.g. a dlopen()'ed shared object can have circular dependencies +- linked back to itself). In such a case, traversing N-1 objects will +- create a N-object result, and raise problems. +- + To summarize, just passing in the full list, and iterating from back + to front makes things much more straightforward. */ + +@@ -274,6 +267,27 @@ _dl_sort_maps_dfs (struct link_map **maps, unsigned int nmaps, + } + + memcpy (maps, rpo, sizeof (struct link_map *) * nmaps); ++ ++ /* Skipping the first object at maps[0] is not valid in general, ++ since traversing along object dependency-links may "find" that ++ first object even when it is not included in the initial order ++ (e.g., a dlopen'ed shared object can have circular dependencies ++ linked back to itself). In such a case, traversing N-1 objects ++ will create a N-object result, and raise problems. Instead, ++ force the object back into first place after sorting. This naive ++ approach may introduce further dependency ordering violations ++ compared to rotating the cycle until the first map is again in ++ the first position, but as there is a cycle, at least one ++ violation is already present. */ ++ if (force_first && maps[0] != first_map) ++ { ++ int i; ++ for (i = 0; maps[i] != first_map; ++i) ++ ; ++ assert (i < nmaps); ++ memmove (&maps[1], maps, i * sizeof (maps[0])); ++ maps[0] = first_map; ++ } + } + + void +diff --git a/elf/dso-sort-tests-1.def b/elf/dso-sort-tests-1.def +index 5f7f18ef27..4bf9052db1 100644 +--- a/elf/dso-sort-tests-1.def ++++ b/elf/dso-sort-tests-1.def +@@ -64,3 +64,10 @@ output: b>a>{}b->c->d;d=>[ba];c=>a;b=>e=>a;c=>f=>b;d=>g=>c + output(glibc.rtld.dynamic_sort=1): {+a[d>c>b>a>];+e[e>];+f[f>];+g[g>];+d[];%d(b(e(a()))a()g(c(a()f(b(e(a()))))));-d[];-g[];-f[];-e[];-a[c>b>a>];+e[e>];+f[f>];+g[g>];+d[];%d(b(e(a()))a()g(c(a()f(b(e(a()))))));-d[];-g[];-f[];-e[];-a[a1;a->a2;a2->a;b->b1;c->a1;c=>a1 ++output(glibc.rtld.dynamic_sort=1): {+a[a2>a1>a>];+b[b1>b>];-b[];%c(a1());}a1>a>];+b[b1>b>];-b[];%c(a1());} +Date: Tue, 20 Sep 2022 12:12:43 +0200 +Subject: [PATCH] gconv: Use 64-bit interfaces in gconv_parseconfdir (bug + 29583) + +It's possible that inode numbers are outside the 32-bit range. +The existing code only handles the in-libc case correctly, and +still uses the legacy interfaces when building iconv. + +Suggested-by: Helge Deller +(cherry picked from commit f97905f24631097af325d6a231093071c3077a5f) +--- + NEWS | 1 + + iconv/gconv_parseconfdir.h | 16 ++++++++-------- + 2 files changed, 9 insertions(+), 8 deletions(-) + +diff --git a/NEWS b/NEWS +index 5b4753416f..eab882987b 100644 +--- a/NEWS ++++ b/NEWS +@@ -26,6 +26,7 @@ The following bugs are resolved with this release: + [29490] alpha: New __brk_call implementation is broken + [29528] elf: Call __libc_early_init for reused namespaces + [29539] libc: LD_TRACE_LOADED_OBJECTS changed how vDSO library are ++ [29583] Use 64-bit interfaces in gconv_parseconfdir + + Version 2.36 + +diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h +index debb96b322..b72933b526 100644 +--- a/iconv/gconv_parseconfdir.h ++++ b/iconv/gconv_parseconfdir.h +@@ -29,14 +29,14 @@ + # define isspace(__c) __isspace_l ((__c), _nl_C_locobj_ptr) + # define asprintf __asprintf + # define opendir __opendir +-# define readdir __readdir ++# define readdir64 __readdir64 + # define closedir __closedir + # define mempcpy __mempcpy +-# define struct_stat struct __stat64_t64 +-# define lstat __lstat64_time64 ++# define struct_stat64 struct __stat64_t64 ++# define lstat64 __lstat64_time64 + # define feof_unlocked __feof_unlocked + #else +-# define struct_stat struct stat ++# define struct_stat64 struct stat64 + #endif + + /* Name of the file containing the module information in the directories +@@ -148,8 +148,8 @@ gconv_parseconfdir (const char *prefix, const char *dir, size_t dir_len) + DIR *confdir = opendir (buf); + if (confdir != NULL) + { +- struct dirent *ent; +- while ((ent = readdir (confdir)) != NULL) ++ struct dirent64 *ent; ++ while ((ent = readdir64 (confdir)) != NULL) + { + if (ent->d_type != DT_REG && ent->d_type != DT_UNKNOWN) + continue; +@@ -161,12 +161,12 @@ gconv_parseconfdir (const char *prefix, const char *dir, size_t dir_len) + && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0) + { + char *conf; +- struct_stat st; ++ struct_stat64 st; + if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) + continue; + + if (ent->d_type != DT_UNKNOWN +- || (lstat (conf, &st) != -1 && S_ISREG (st.st_mode))) ++ || (lstat64 (conf, &st) != -1 && S_ISREG (st.st_mode))) + found |= read_conf_file (conf, dir, dir_len); + + free (conf); +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-01-x86-include-BMI1-and-BMI2-in-x86-64-v3-level.patch glibc-2.36/debian/patches/upstream-updates/0023-01-x86-include-BMI1-and-BMI2-in-x86-64-v3-level.patch --- glibc-2.36/debian/patches/upstream-updates/0023-01-x86-include-BMI1-and-BMI2-in-x86-64-v3-level.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-01-x86-include-BMI1-and-BMI2-in-x86-64-v3-level.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,31 @@ +From 18bec23cbb4d530a2a8ce95353770661fabcd55f Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86: include BMI1 and BMI2 in x86-64-v3 level + +The "System V Application Binary Interface AMD64 Architecture Processor +Supplement" mandates the BMI1 and BMI2 CPU features for the x86-64-v3 +level. + +Reviewed-by: Noah Goldstein +(cherry picked from commit b80f16adbd979831bf25ea491e1261e81885c2b6) +--- + sysdeps/x86/get-isa-level.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/sysdeps/x86/get-isa-level.h b/sysdeps/x86/get-isa-level.h +index 1ade78ab73..5b4dd5f062 100644 +--- a/sysdeps/x86/get-isa-level.h ++++ b/sysdeps/x86/get-isa-level.h +@@ -47,6 +47,8 @@ get_isa_level (const struct cpu_features *cpu_features) + isa_level |= GNU_PROPERTY_X86_ISA_1_V2; + if (CPU_FEATURE_USABLE_P (cpu_features, AVX) + && CPU_FEATURE_USABLE_P (cpu_features, AVX2) ++ && CPU_FEATURE_USABLE_P (cpu_features, BMI1) ++ && CPU_FEATURE_USABLE_P (cpu_features, BMI2) + && CPU_FEATURE_USABLE_P (cpu_features, F16C) + && CPU_FEATURE_USABLE_P (cpu_features, FMA) + && CPU_FEATURE_USABLE_P (cpu_features, LZCNT) +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-02-x86-64-Require-BMI2-for-AVX2-str-n-casecmp-implement.patch glibc-2.36/debian/patches/upstream-updates/0023-02-x86-64-Require-BMI2-for-AVX2-str-n-casecmp-implement.patch --- glibc-2.36/debian/patches/upstream-updates/0023-02-x86-64-Require-BMI2-for-AVX2-str-n-casecmp-implement.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-02-x86-64-Require-BMI2-for-AVX2-str-n-casecmp-implement.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,117 @@ +From 46479e5d10ed87825aa277da158d6a687974518b Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86-64: Require BMI2 for AVX2 str(n)casecmp implementations + +The AVX2 str(n)casecmp implementations use the 'bzhi' instruction, which +belongs to the BMI2 CPU feature. + +NB: It also uses the 'tzcnt' BMI1 instruction, but it is executed as BSF +as BSF if the CPU doesn't support TZCNT, and produces the same result +for non-zero input. + +Partially fixes: b77b06e0e296 ("x86: Optimize strcmp-avx2.S") +Partially resolves: BZ #29611 + +Reviewed-by: Noah Goldstein +(cherry picked from commit 10f79d3670b036925da63dc532b122d27ce65ff8) +--- + sysdeps/x86_64/multiarch/ifunc-impl-list.c | 28 +++++++++++++++------ + sysdeps/x86_64/multiarch/ifunc-strcasecmp.h | 1 + + 2 files changed, 21 insertions(+), 8 deletions(-) + +diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +index a71444eccb..d208fae4bf 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c ++++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +@@ -448,13 +448,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + IFUNC_IMPL (i, name, strcasecmp, + X86_IFUNC_IMPL_ADD_V4 (array, i, strcasecmp, + (CPU_FEATURE_USABLE (AVX512VL) +- && CPU_FEATURE_USABLE (AVX512BW)), ++ && CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI2)), + __strcasecmp_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, strcasecmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __strcasecmp_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, strcasecmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __strcasecmp_avx2_rtm) + X86_IFUNC_IMPL_ADD_V2 (array, i, strcasecmp, +@@ -470,13 +473,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + IFUNC_IMPL (i, name, strcasecmp_l, + X86_IFUNC_IMPL_ADD_V4 (array, i, strcasecmp, + (CPU_FEATURE_USABLE (AVX512VL) +- && CPU_FEATURE_USABLE (AVX512BW)), ++ && CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI2)), + __strcasecmp_l_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, strcasecmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __strcasecmp_l_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, strcasecmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __strcasecmp_l_avx2_rtm) + X86_IFUNC_IMPL_ADD_V2 (array, i, strcasecmp_l, +@@ -638,13 +644,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + IFUNC_IMPL (i, name, strncasecmp, + X86_IFUNC_IMPL_ADD_V4 (array, i, strncasecmp, + (CPU_FEATURE_USABLE (AVX512VL) +- && CPU_FEATURE_USABLE (AVX512BW)), ++ && CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI2)), + __strncasecmp_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, strncasecmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __strncasecmp_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, strncasecmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __strncasecmp_avx2_rtm) + X86_IFUNC_IMPL_ADD_V2 (array, i, strncasecmp, +@@ -660,13 +669,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + IFUNC_IMPL (i, name, strncasecmp_l, + X86_IFUNC_IMPL_ADD_V4 (array, i, strncasecmp, + (CPU_FEATURE_USABLE (AVX512VL) +- && CPU_FEATURE_USABLE (AVX512BW)), ++ & CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI2)), + __strncasecmp_l_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, strncasecmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __strncasecmp_l_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, strncasecmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __strncasecmp_l_avx2_rtm) + X86_IFUNC_IMPL_ADD_V2 (array, i, strncasecmp_l, +diff --git a/sysdeps/x86_64/multiarch/ifunc-strcasecmp.h b/sysdeps/x86_64/multiarch/ifunc-strcasecmp.h +index 68646ef199..7622af259c 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-strcasecmp.h ++++ b/sysdeps/x86_64/multiarch/ifunc-strcasecmp.h +@@ -34,6 +34,7 @@ IFUNC_SELECTOR (void) + const struct cpu_features *cpu_features = __get_cpu_features (); + + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2) ++ && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2) + && X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, + AVX_Fast_Unaligned_Load, )) + { +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-03-x86-64-Require-BMI2-for-AVX2-strcmp-implementation.patch glibc-2.36/debian/patches/upstream-updates/0023-03-x86-64-Require-BMI2-for-AVX2-strcmp-implementation.patch --- glibc-2.36/debian/patches/upstream-updates/0023-03-x86-64-Require-BMI2-for-AVX2-strcmp-implementation.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-03-x86-64-Require-BMI2-for-AVX2-strcmp-implementation.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,62 @@ +From 7afbd1e56acb721031bffd876f275dcb1af7e530 Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86-64: Require BMI2 for AVX2 strcmp implementation + +The AVX2 strcmp implementation uses the 'bzhi' instruction, which +belongs to the BMI2 CPU feature. + +NB: It also uses the 'tzcnt' BMI1 instruction, but it is executed as BSF +as BSF if the CPU doesn't support TZCNT, and produces the same result +for non-zero input. + +Partially fixes: b77b06e0e296 ("x86: Optimize strcmp-avx2.S") +Partially resolves: BZ #29611 + +Reviewed-by: Noah Goldstein +(cherry picked from commit 4d64c6445735e9b34e2ac8e369312cbfc2f88e17) +--- + sysdeps/x86_64/multiarch/ifunc-impl-list.c | 4 +++- + sysdeps/x86_64/multiarch/strcmp.c | 4 ++-- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +index d208fae4bf..a42b0a4620 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c ++++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +@@ -591,10 +591,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + && CPU_FEATURE_USABLE (BMI2)), + __strcmp_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, strcmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __strcmp_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, strcmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __strcmp_avx2_rtm) + X86_IFUNC_IMPL_ADD_V2 (array, i, strcmp, +diff --git a/sysdeps/x86_64/multiarch/strcmp.c b/sysdeps/x86_64/multiarch/strcmp.c +index fdd5afe3af..9d6c9f66ba 100644 +--- a/sysdeps/x86_64/multiarch/strcmp.c ++++ b/sysdeps/x86_64/multiarch/strcmp.c +@@ -45,12 +45,12 @@ IFUNC_SELECTOR (void) + const struct cpu_features *cpu_features = __get_cpu_features (); + + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2) ++ && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2) + && X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, + AVX_Fast_Unaligned_Load, )) + { + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL) +- && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW) +- && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2)) ++ && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)) + return OPTIMIZE (evex); + + if (CPU_FEATURE_USABLE_P (cpu_features, RTM)) +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-04-x86-64-Require-BMI2-for-AVX2-strncmp-implementation.patch glibc-2.36/debian/patches/upstream-updates/0023-04-x86-64-Require-BMI2-for-AVX2-strncmp-implementation.patch --- glibc-2.36/debian/patches/upstream-updates/0023-04-x86-64-Require-BMI2-for-AVX2-strncmp-implementation.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-04-x86-64-Require-BMI2-for-AVX2-strncmp-implementation.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,67 @@ +From 29c577e0f54fe6e70ceacb3659179781c5569903 Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86-64: Require BMI2 for AVX2 strncmp implementation + +The AVX2 strncmp implementations uses the 'bzhi' instruction, which +belongs to the BMI2 CPU feature. + +NB: It also uses the 'tzcnt' BMI1 instruction, but it is executed as BSF +as BSF if the CPU doesn't support TZCNT, and produces the same result +for non-zero input. + +Partially fixes: b77b06e0e296 ("x86: Optimize strcmp-avx2.S") +Partially resolves: BZ #29611 + +Reviewed-by: Noah Goldstein +(cherry picked from commit fc7de1d9b99ae1676bc626ddca422d7abee0eb48) +--- + sysdeps/x86_64/multiarch/ifunc-impl-list.c | 7 +++++-- + sysdeps/x86_64/multiarch/strncmp.c | 4 ++-- + 2 files changed, 7 insertions(+), 4 deletions(-) + +diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +index a42b0a4620..aebef3daaf 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c ++++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +@@ -1176,13 +1176,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + IFUNC_IMPL (i, name, strncmp, + X86_IFUNC_IMPL_ADD_V4 (array, i, strncmp, + (CPU_FEATURE_USABLE (AVX512VL) +- && CPU_FEATURE_USABLE (AVX512BW)), ++ && CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI2)), + __strncmp_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, strncmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __strncmp_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, strncmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __strncmp_avx2_rtm) + X86_IFUNC_IMPL_ADD_V2 (array, i, strncmp, +diff --git a/sysdeps/x86_64/multiarch/strncmp.c b/sysdeps/x86_64/multiarch/strncmp.c +index 4ebe4bde30..c4f8b6bbb5 100644 +--- a/sysdeps/x86_64/multiarch/strncmp.c ++++ b/sysdeps/x86_64/multiarch/strncmp.c +@@ -41,12 +41,12 @@ IFUNC_SELECTOR (void) + const struct cpu_features *cpu_features = __get_cpu_features (); + + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2) ++ && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2) + && X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, + AVX_Fast_Unaligned_Load, )) + { + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL) +- && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW) +- && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2)) ++ && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)) + return OPTIMIZE (evex); + + if (CPU_FEATURE_USABLE_P (cpu_features, RTM)) +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-05-x86-64-Require-BMI2-for-AVX2-wcs-n-cmp-implementatio.patch glibc-2.36/debian/patches/upstream-updates/0023-05-x86-64-Require-BMI2-for-AVX2-wcs-n-cmp-implementatio.patch --- glibc-2.36/debian/patches/upstream-updates/0023-05-x86-64-Require-BMI2-for-AVX2-wcs-n-cmp-implementatio.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-05-x86-64-Require-BMI2-for-AVX2-wcs-n-cmp-implementatio.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,56 @@ +From d8bf4388df679fa5a3ae7889a649e573e3124530 Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86-64: Require BMI2 for AVX2 wcs(n)cmp implementations + +The AVX2 wcs(n)cmp implementations use the 'bzhi' instruction, which +belongs to the BMI2 CPU feature. + +NB: It also uses the 'tzcnt' BMI1 instruction, but it is executed as BSF +as BSF if the CPU doesn't support TZCNT, and produces the same result +for non-zero input. + +Partially fixes: b77b06e0e296 ("x86: Optimize strcmp-avx2.S") +Partially resolves: BZ #29611 + +Reviewed-by: Noah Goldstein +(cherry picked from commit f31a5a884ed84bd37032729d4d1eb9d06c9f3c29) +--- + sysdeps/x86_64/multiarch/ifunc-impl-list.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +index aebef3daaf..fec8790c11 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c ++++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +@@ -810,10 +810,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + && CPU_FEATURE_USABLE (BMI2)), + __wcscmp_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, wcscmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __wcscmp_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, wcscmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __wcscmp_avx2_rtm) + /* ISA V2 wrapper for SSE2 implementation because the SSE2 +@@ -830,10 +832,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + && CPU_FEATURE_USABLE (BMI2)), + __wcsncmp_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, wcsncmp, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __wcsncmp_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, wcsncmp, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __wcsncmp_avx2_rtm) + /* ISA V2 wrapper for GENERIC implementation because the +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-06-x86-64-Require-BMI2-for-AVX2-raw-w-memchr-implementa.patch glibc-2.36/debian/patches/upstream-updates/0023-06-x86-64-Require-BMI2-for-AVX2-raw-w-memchr-implementa.patch --- glibc-2.36/debian/patches/upstream-updates/0023-06-x86-64-Require-BMI2-for-AVX2-raw-w-memchr-implementa.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-06-x86-64-Require-BMI2-for-AVX2-raw-w-memchr-implementa.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,66 @@ +From d9196d4f3fa9997388655813ddd236426a16dd92 Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86-64: Require BMI2 for AVX2 (raw|w)memchr implementations + +The AVX2 memchr, rawmemchr and wmemchr implementations use the 'bzhi' +and 'sarx' instructions, which belongs to the BMI2 CPU feature. + +Fixes: acfd088a1963 ("x86: Optimize memchr-avx2.S") +Partially resolves: BZ #29611 + +Reviewed-by: Noah Goldstein +(cherry picked from commit e3e7fab7fe5186d18ca2046d99ba321c27db30ad) +--- + sysdeps/x86_64/multiarch/ifunc-impl-list.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +index fec8790c11..7c84963d92 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c ++++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +@@ -69,10 +69,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + && CPU_FEATURE_USABLE (BMI2)), + __memchr_evex_rtm) + X86_IFUNC_IMPL_ADD_V3 (array, i, memchr, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __memchr_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, memchr, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __memchr_avx2_rtm) + /* ISA V2 wrapper for SSE2 implementation because the SSE2 +@@ -335,10 +337,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + && CPU_FEATURE_USABLE (BMI2)), + __rawmemchr_evex_rtm) + X86_IFUNC_IMPL_ADD_V3 (array, i, rawmemchr, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __rawmemchr_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, rawmemchr, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __rawmemchr_avx2_rtm) + /* ISA V2 wrapper for SSE2 implementation because the SSE2 +@@ -927,10 +931,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + && CPU_FEATURE_USABLE (BMI2)), + __wmemchr_evex_rtm) + X86_IFUNC_IMPL_ADD_V3 (array, i, wmemchr, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2)), + __wmemchr_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, wmemchr, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __wmemchr_avx2_rtm) + /* ISA V2 wrapper for SSE2 implementation because the SSE2 +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-07-x86-64-Require-BMI2-and-LZCNT-for-AVX2-memrchr-imple.patch glibc-2.36/debian/patches/upstream-updates/0023-07-x86-64-Require-BMI2-and-LZCNT-for-AVX2-memrchr-imple.patch --- glibc-2.36/debian/patches/upstream-updates/0023-07-x86-64-Require-BMI2-and-LZCNT-for-AVX2-memrchr-imple.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-07-x86-64-Require-BMI2-and-LZCNT-for-AVX2-memrchr-imple.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,74 @@ +From 923c3f3c373f499e62160e00831dda576443317b Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86-64: Require BMI2 and LZCNT for AVX2 memrchr + implementation + +The AVX2 memrchr implementation uses the 'shlxl' instruction, which +belongs to the BMI2 CPU feature and uses the 'lzcnt' instruction, which +belongs to the LZCNT CPU feature. + +Fixes: af5306a735eb ("x86: Optimize memrchr-avx2.S") +Partially resolves: BZ #29611 + +Reviewed-by: Noah Goldstein +(cherry picked from commit 3c0c78afabfed4b6fc161c159e628fbf14ff370b) +--- + sysdeps/x86/isa-level.h | 1 + + sysdeps/x86_64/multiarch/ifunc-avx2.h | 1 + + sysdeps/x86_64/multiarch/ifunc-impl-list.c | 10 ++++++++-- + 3 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/sysdeps/x86/isa-level.h b/sysdeps/x86/isa-level.h +index 3c4480aba7..bbb90f5c5e 100644 +--- a/sysdeps/x86/isa-level.h ++++ b/sysdeps/x86/isa-level.h +@@ -80,6 +80,7 @@ + #define AVX_X86_ISA_LEVEL 3 + #define AVX2_X86_ISA_LEVEL 3 + #define BMI2_X86_ISA_LEVEL 3 ++#define LZCNT_X86_ISA_LEVEL 3 + #define MOVBE_X86_ISA_LEVEL 3 + + /* ISA level >= 2 guaranteed includes. */ +diff --git a/sysdeps/x86_64/multiarch/ifunc-avx2.h b/sysdeps/x86_64/multiarch/ifunc-avx2.h +index a57a9952f3..f1741083fd 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-avx2.h ++++ b/sysdeps/x86_64/multiarch/ifunc-avx2.h +@@ -37,6 +37,7 @@ IFUNC_SELECTOR (void) + + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2) ++ && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, LZCNT) + && X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, + AVX_Fast_Unaligned_Load, )) + { +diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +index 7c84963d92..ec1c5b55fb 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c ++++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +@@ -209,13 +209,19 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + IFUNC_IMPL (i, name, memrchr, + X86_IFUNC_IMPL_ADD_V4 (array, i, memrchr, + (CPU_FEATURE_USABLE (AVX512VL) +- && CPU_FEATURE_USABLE (AVX512BW)), ++ && CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI2) ++ && CPU_FEATURE_USABLE (LZCNT)), + __memrchr_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, memrchr, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) ++ && CPU_FEATURE_USABLE (LZCNT)), + __memrchr_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, memrchr, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI2) ++ && CPU_FEATURE_USABLE (LZCNT) + && CPU_FEATURE_USABLE (RTM)), + __memrchr_avx2_rtm) + /* ISA V2 wrapper for SSE2 implementation because the SSE2 +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0023-08-x86-64-Require-BMI1-BMI2-for-AVX2-strrchr-and-wcsrch.patch glibc-2.36/debian/patches/upstream-updates/0023-08-x86-64-Require-BMI1-BMI2-for-AVX2-strrchr-and-wcsrch.patch --- glibc-2.36/debian/patches/upstream-updates/0023-08-x86-64-Require-BMI1-BMI2-for-AVX2-strrchr-and-wcsrch.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0023-08-x86-64-Require-BMI1-BMI2-for-AVX2-strrchr-and-wcsrch.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,94 @@ +From 2d8ef784bd6a784496a6fd460de6b6f57c70a501 Mon Sep 17 00:00:00 2001 +From: Aurelien Jarno +Date: Mon, 3 Oct 2022 23:46:11 +0200 +Subject: [PATCH] x86-64: Require BMI1/BMI2 for AVX2 strrchr and wcsrchr + implementations + +The AVX2 strrchr and wcsrchr implementation uses the 'blsmsk' +instruction which belongs to the BMI1 CPU feature and the 'shrx' +instruction, which belongs to the BMI2 CPU feature. + +Fixes: df7e295d18ff ("x86: Optimize {str|wcs}rchr-avx2") +Partially resolves: BZ #29611 + +Reviewed-by: Noah Goldstein +(cherry picked from commit 7e8283170c5d6805b609a040801d819e362a6292) +--- + sysdeps/x86/isa-level.h | 1 + + sysdeps/x86_64/multiarch/ifunc-avx2.h | 1 + + sysdeps/x86_64/multiarch/ifunc-impl-list.c | 17 ++++++++++++++--- + 3 files changed, 16 insertions(+), 3 deletions(-) + +diff --git a/sysdeps/x86/isa-level.h b/sysdeps/x86/isa-level.h +index bbb90f5c5e..06f6c9663e 100644 +--- a/sysdeps/x86/isa-level.h ++++ b/sysdeps/x86/isa-level.h +@@ -79,6 +79,7 @@ + /* ISA level >= 3 guaranteed includes. */ + #define AVX_X86_ISA_LEVEL 3 + #define AVX2_X86_ISA_LEVEL 3 ++#define BMI1_X86_ISA_LEVEL 3 + #define BMI2_X86_ISA_LEVEL 3 + #define LZCNT_X86_ISA_LEVEL 3 + #define MOVBE_X86_ISA_LEVEL 3 +diff --git a/sysdeps/x86_64/multiarch/ifunc-avx2.h b/sysdeps/x86_64/multiarch/ifunc-avx2.h +index f1741083fd..f2f5e8a211 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-avx2.h ++++ b/sysdeps/x86_64/multiarch/ifunc-avx2.h +@@ -36,6 +36,7 @@ IFUNC_SELECTOR (void) + const struct cpu_features *cpu_features = __get_cpu_features (); + + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2) ++ && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI1) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, LZCNT) + && X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, +diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +index ec1c5b55fb..00a91123d3 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c ++++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c +@@ -578,13 +578,19 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + IFUNC_IMPL (i, name, strrchr, + X86_IFUNC_IMPL_ADD_V4 (array, i, strrchr, + (CPU_FEATURE_USABLE (AVX512VL) +- && CPU_FEATURE_USABLE (AVX512BW)), ++ && CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI1) ++ && CPU_FEATURE_USABLE (BMI2)), + __strrchr_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, strrchr, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI1) ++ && CPU_FEATURE_USABLE (BMI2)), + __strrchr_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, strrchr, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI1) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __strrchr_avx2_rtm) + /* ISA V2 wrapper for SSE2 implementation because the SSE2 +@@ -797,13 +803,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + X86_IFUNC_IMPL_ADD_V4 (array, i, wcsrchr, + (CPU_FEATURE_USABLE (AVX512VL) + && CPU_FEATURE_USABLE (AVX512BW) ++ && CPU_FEATURE_USABLE (BMI1) + && CPU_FEATURE_USABLE (BMI2)), + __wcsrchr_evex) + X86_IFUNC_IMPL_ADD_V3 (array, i, wcsrchr, +- CPU_FEATURE_USABLE (AVX2), ++ (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI1) ++ && CPU_FEATURE_USABLE (BMI2)), + __wcsrchr_avx2) + X86_IFUNC_IMPL_ADD_V3 (array, i, wcsrchr, + (CPU_FEATURE_USABLE (AVX2) ++ && CPU_FEATURE_USABLE (BMI1) ++ && CPU_FEATURE_USABLE (BMI2) + && CPU_FEATURE_USABLE (RTM)), + __wcsrchr_avx2_rtm) + /* ISA V2 wrapper for SSE2 implementation because the SSE2 +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0024-nscd-Drop-local-address-tuple-variable-BZ-29607.patch glibc-2.36/debian/patches/upstream-updates/0024-nscd-Drop-local-address-tuple-variable-BZ-29607.patch --- glibc-2.36/debian/patches/upstream-updates/0024-nscd-Drop-local-address-tuple-variable-BZ-29607.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0024-nscd-Drop-local-address-tuple-variable-BZ-29607.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,62 @@ +From 2bd815d8347851212b9a91dbdca8053f4dbdac87 Mon Sep 17 00:00:00 2001 +From: Siddhesh Poyarekar +Date: Tue, 4 Oct 2022 18:43:50 -0400 +Subject: [PATCH] nscd: Drop local address tuple variable [BZ #29607] +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When a request needs to be resent (e.g. due to insufficient buffer +space), the references to subsequent tuples in the local variable are +stale and should not be used. This used to work by accident before, but +since 1d495912a it no longer does. Instead of trying to reset it, just +let gethostbyname4_r write into TUMPBUF6 for us, thus maintaining a +consistent state at all times. This is now consistent with what is done +in gaih_inet for getaddrinfo. + +Resolves: BZ #29607 +Reported-by: Holger Hoffstätte +Tested-by: Holger Hoffstätte +Reviewed-by: Carlos O'Donell +(cherry picked from commit 6e33e5c4b73cea7b8aa3de0947123db16200fb65) +--- + NEWS | 2 ++ + nscd/aicache.c | 5 ++--- + 2 files changed, 4 insertions(+), 3 deletions(-) + +--- a/NEWS ++++ b/NEWS +@@ -27,6 +27,9 @@ + [29528] elf: Call __libc_early_init for reused namespaces + [29539] libc: LD_TRACE_LOADED_OBJECTS changed how vDSO library are + [29583] Use 64-bit interfaces in gconv_parseconfdir ++ [29607] nscd repeatably crashes calling __strlen_avx2 when hosts cache is ++ enabled ++ + + Version 2.36 + +--- a/nscd/aicache.c ++++ b/nscd/aicache.c +@@ -110,11 +110,10 @@ + "gethostbyname4_r"); + if (fct4 != NULL) + { +- struct gaih_addrtuple atmem; + struct gaih_addrtuple *at; + while (1) + { +- at = &atmem; ++ at = NULL; + rc6 = 0; + herrno = 0; + status[1] = DL_CALL_FCT (fct4, (key, &at, +@@ -137,7 +136,7 @@ + goto next_nip; + + /* We found the data. Count the addresses and the size. */ +- for (const struct gaih_addrtuple *at2 = at = &atmem; at2 != NULL; ++ for (const struct gaih_addrtuple *at2 = at; at2 != NULL; + at2 = at2->next) + { + ++naddrs; diff -Nru glibc-2.36/debian/patches/upstream-updates/0025-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch glibc-2.36/debian/patches/upstream-updates/0025-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch --- glibc-2.36/debian/patches/upstream-updates/0025-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0025-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,38 @@ +From 227c9035872fc9e9e2cf56ec8f89219747ee19bc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=B6rg=20Sonnenberger?= +Date: Mon, 26 Sep 2022 13:59:16 -0400 +Subject: [PATCH] get_nscd_addresses: Fix subscript typos [BZ #29605] + +Fix the subscript on air->family, which was accidentally set to COUNT +when it should have remained as I. + +Resolves: BZ #29605 + +Reviewed-by: Siddhesh Poyarekar +(cherry picked from commit c9226c03da0276593a0918eaa9a14835183343e8) +--- + sysdeps/posix/getaddrinfo.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c +index bcff909b2f..5cda9bb072 100644 +--- a/sysdeps/posix/getaddrinfo.c ++++ b/sysdeps/posix/getaddrinfo.c +@@ -540,11 +540,11 @@ get_nscd_addresses (const char *name, const struct addrinfo *req, + at[count].addr[2] = htonl (0xffff); + } + else if (req->ai_family == AF_UNSPEC +- || air->family[count] == req->ai_family) ++ || air->family[i] == req->ai_family) + { +- at[count].family = air->family[count]; ++ at[count].family = air->family[i]; + memcpy (at[count].addr, addrs, size); +- if (air->family[count] == AF_INET6) ++ if (air->family[i] == AF_INET6) + res->got_ipv6 = true; + } + at[count].next = at + count + 1; +-- +2.34.1 + diff -Nru glibc-2.36/debian/patches/upstream-updates/0026-stdlib-Fix-__getrandom_nocancel-type-and-arc4random-.patch glibc-2.36/debian/patches/upstream-updates/0026-stdlib-Fix-__getrandom_nocancel-type-and-arc4random-.patch --- glibc-2.36/debian/patches/upstream-updates/0026-stdlib-Fix-__getrandom_nocancel-type-and-arc4random-.patch 1970-01-01 01:00:00.000000000 +0100 +++ glibc-2.36/debian/patches/upstream-updates/0026-stdlib-Fix-__getrandom_nocancel-type-and-arc4random-.patch 2022-10-05 22:15:30.000000000 +0200 @@ -0,0 +1,52 @@ +From 76e05613ee28f4ac4a0ab97effc32e0e78e37a56 Mon Sep 17 00:00:00 2001 +From: Adhemerval Zanella +Date: Thu, 29 Sep 2022 16:15:20 -0300 +Subject: [PATCH] stdlib: Fix __getrandom_nocancel type and arc4random usage + (BZ #29638) + +Using an unsigned type prevents the fallback to be used if kernel +does not support getrandom syscall. + +Checked on x86_64-linux-gnu. + +Reviewed-by: Wilco Dijkstra +(cherry picked from commit 13db9ee2cb3b77e25f852be7d6952882e1be6f00) +--- + NEWS | 1 + + stdlib/arc4random.c | 2 +- + sysdeps/unix/sysv/linux/not-cancel.h | 2 +- + 3 files changed, 3 insertions(+), 2 deletions(-) + +--- a/NEWS ++++ b/NEWS +@@ -29,6 +29,8 @@ + [29583] Use 64-bit interfaces in gconv_parseconfdir + [29607] nscd repeatably crashes calling __strlen_avx2 when hosts cache is + enabled ++ [29638] libc: stdlib: arc4random fallback is never used ++ + + + Version 2.36 +--- a/stdlib/arc4random.c ++++ b/stdlib/arc4random.c +@@ -34,7 +34,7 @@ + __arc4random_buf (void *p, size_t n) + { + static int seen_initialized; +- size_t l; ++ ssize_t l; + int fd; + + if (n == 0) +--- a/sysdeps/unix/sysv/linux/not-cancel.h ++++ b/sysdeps/unix/sysv/linux/not-cancel.h +@@ -68,7 +68,7 @@ + INTERNAL_SYSCALL_CALL (writev, fd, iov, iovcnt); + } + +-static inline int ++static inline ssize_t + __getrandom_nocancel (void *buf, size_t buflen, unsigned int flags) + { + return INLINE_SYSCALL_CALL (getrandom, buf, buflen, flags); diff -Nru glibc-2.36/debian/rules.d/control.mk glibc-2.36/debian/rules.d/control.mk --- glibc-2.36/debian/rules.d/control.mk 2022-09-11 23:33:22.000000000 +0200 +++ glibc-2.36/debian/rules.d/control.mk 2022-10-05 22:15:30.000000000 +0200 @@ -1,7 +1,7 @@ libc_packages := libc6 libc6.1 libc0.1 libc0.3 libc0_1_archs := kfreebsd-amd64 kfreebsd-i386 libc0_3_archs := hurd-i386 -libc6_archs := amd64 arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el \ +libc6_archs := amd64 arc arm64 armel armhf hppa i386 m68k mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el \ mipsn32r6 mipsn32r6el mips64r6 mips64r6el nios2 powerpc ppc64 ppc64el riscv64 \ sparc sparc64 s390x sh3 sh4 x32 libc6_1_archs := alpha ia64