From cfae40b9b1422952ce38d132afceb8f904ccbce7 Mon Sep 17 00:00:00 2001 From: Fcc Date: Fri, 27 May 2022 16:37:13 +0800 Subject: [PATCH] linux: Add a getauxval test [BZ #23293] This is for bug 23293 and it relies on the glibc test system running tests via explicit ld.so invokation by default. --- glibc.spec | 6 +- linux-Add-a-getauxval-test-BZ-23293.patch | 112 ++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 linux-Add-a-getauxval-test-BZ-23293.patch diff --git a/glibc.spec b/glibc.spec index f1219b3..5818393 100644 --- a/glibc.spec +++ b/glibc.spec @@ -66,7 +66,7 @@ ############################################################################## Name: glibc Version: 2.34 -Release: 81 +Release: 82 Summary: The GNU libc libraries License: %{all_license} URL: http://www.gnu.org/software/glibc/ @@ -221,6 +221,7 @@ Patch133: posix-glob.c-update-from-gnulib.patch Patch134: linux-Fix-fchmodat-with-AT_SYMLINK_NOFOLLOW-for-64-b.patch Patch135: linux-Fix-posix_spawn-return-code-if-clone-fails-BZ-.patch Patch136: backport-elf-Fix-use-after-free-in-ldconfig-BZ-26779.patch +Patch137: linux-Add-a-getauxval-test-BZ-23293.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 @@ -1389,6 +1390,9 @@ fi %endif %changelog +* Fri May 27 2022 fangchuangchuang - 2.34-82 +- linux: Add a getauxval test [BZ #23293] + * Fri May 20 2022 xujing - 2.34-81 - elf: Fix use-after-free in ldconfig [BZ #26779] diff --git a/linux-Add-a-getauxval-test-BZ-23293.patch b/linux-Add-a-getauxval-test-BZ-23293.patch new file mode 100644 index 0000000..49a1b19 --- /dev/null +++ b/linux-Add-a-getauxval-test-BZ-23293.patch @@ -0,0 +1,112 @@ +From b2585cae2854d7d2868fb2e51e2796042c5e0679 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Tue, 3 May 2022 13:18:04 +0100 +Subject: [PATCH] linux: Add a getauxval test [BZ #23293] + +This is for bug 23293 and it relies on the glibc test system running +tests via explicit ld.so invokation by default. + +Reviewed-by: Florian Weimer +Reviewed-by: Adhemerval Zanella +(cherry picked from commit 9faf5262c77487c96da8a3e961b88c0b1879e186) +--- + sysdeps/unix/sysv/linux/Makefile | 1 + + sysdeps/unix/sysv/linux/tst-getauxval.c | 74 +++++++++++++++++++++++++ + 2 files changed, 75 insertions(+) + create mode 100644 sysdeps/unix/sysv/linux/tst-getauxval.c + +diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile +index c34774806f..dd227c3b4a 100644 +--- a/sysdeps/unix/sysv/linux/Makefile ++++ b/sysdeps/unix/sysv/linux/Makefile +@@ -123,6 +123,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ + tst-close_range \ + tst-prctl \ + tst-scm_rights \ ++ tst-getauxval \ + # tests + + # Test for the symbol version of fcntl that was replaced in glibc 2.28. +diff --git a/sysdeps/unix/sysv/linux/tst-getauxval.c b/sysdeps/unix/sysv/linux/tst-getauxval.c +new file mode 100644 +index 0000000000..c4b6195743 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/tst-getauxval.c +@@ -0,0 +1,74 @@ ++/* Basic test for getauxval. ++ Copyright (C) 2022 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++ ++static int missing; ++static int mismatch; ++ ++static void ++check_nonzero (unsigned long t, const char *s) ++{ ++ unsigned long v = getauxval (t); ++ printf ("%s: %lu (0x%lx)\n", s, v, v); ++ if (v == 0) ++ missing++; ++} ++ ++static void ++check_eq (unsigned long t, const char *s, unsigned long want) ++{ ++ unsigned long v = getauxval (t); ++ printf ("%s: %lu want: %lu\n", s, v, want); ++ if (v != want) ++ mismatch++; ++} ++ ++#define NZ(x) check_nonzero (x, #x) ++#define EQ(x, want) check_eq (x, #x, want) ++ ++static int ++do_test (void) ++{ ++ /* These auxv entries should be non-zero on Linux. */ ++ NZ (AT_PHDR); ++ NZ (AT_PHENT); ++ NZ (AT_PHNUM); ++ NZ (AT_PAGESZ); ++ NZ (AT_ENTRY); ++ NZ (AT_CLKTCK); ++ NZ (AT_RANDOM); ++ NZ (AT_EXECFN); ++ if (missing) ++ FAIL_EXIT1 ("Found %d missing auxv entries.\n", missing); ++ ++ /* Check against syscalls. */ ++ EQ (AT_UID, getuid ()); ++ EQ (AT_EUID, geteuid ()); ++ EQ (AT_GID, getgid ()); ++ EQ (AT_EGID, getegid ()); ++ if (mismatch) ++ FAIL_EXIT1 ("Found %d mismatching auxv entries.\n", mismatch); ++ ++ return 0; ++} ++ ++#include +-- +2.20.1 + -- Gitee