From 46e756739a6ab1beee11438f3609ed29f3f90a5e Mon Sep 17 00:00:00 2001 From: Sergey Kolosov Date: Sun, 31 May 2026 21:04:53 +0200 Subject: [PATCH 1/5] CI Tests: Expand Sanity test suite with branch-specific cases Add additional test cases to the tests/Sanity directory to expand test coverage for this release branch. RPM-Changelog: - RPM-Skip-Release: yes --- .../Improve-test-coverage-for-open/main.fmf | 16 ++++ .../Improve-test-coverage-for-open/runtest.sh | 56 +++++++++++ .../Improve-test-coverage-for-open/test.c | 25 +++++ .../float128-test.c | 5 + .../main.fmf | 17 ++++ .../runtest.sh | 53 +++++++++++ .../main.fmf | 14 +++ .../runtest.sh | 50 ++++++++++ .../main.fmf | 17 ++++ .../runtest.sh | 56 +++++++++++ tests/Sanity/basic-stap-dyninst/main.fmf | 19 ++++ tests/Sanity/basic-stap-dyninst/runtest.sh | 56 +++++++++++ .../main.fmf | 20 ++++ .../runtest.sh | 53 +++++++++++ .../main.fmf | 21 +++++ .../runtest.sh | 45 +++++++++ .../main.fmf | 18 ++++ .../runtest.sh | 55 +++++++++++ .../tst-msgctl.c | 25 +++++ .../tst-semctl.c | 33 +++++++ .../tst-shmctl.c | 26 ++++++ .../main.fmf | 19 ++++ .../runtest.sh | 71 ++++++++++++++ .../main.fmf | 19 ++++ .../runtest.sh | 53 +++++++++++ .../tst.c | 15 +++ .../main.fmf | 18 ++++ .../runtest.sh | 53 +++++++++++ .../tst-proto.c | 33 +++++++ .../main.fmf | 19 ++++ .../runtest.sh | 59 ++++++++++++ .../main.fmf | 15 +++ .../runtest.sh | 45 +++++++++ .../main.fmf | 23 +++++ .../runtest.sh | 53 +++++++++++ .../test.c | 8 ++ .../main.fmf | 16 ++++ .../runtest.sh | 55 +++++++++++ .../main.fmf | 20 ++++ .../runtest.sh | 92 +++++++++++++++++++ .../main.fmf | 20 ++++ .../runtest.sh | 50 ++++++++++ .../main.fmf | 13 +++ .../runtest.sh | 60 ++++++++++++ .../tst-bz31479.c | 9 ++ 45 files changed, 1518 insertions(+) create mode 100644 tests/Sanity/Improve-test-coverage-for-open/main.fmf create mode 100755 tests/Sanity/Improve-test-coverage-for-open/runtest.sh create mode 100644 tests/Sanity/Improve-test-coverage-for-open/test.c create mode 100644 tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/float128-test.c create mode 100644 tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/main.fmf create mode 100755 tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/runtest.sh create mode 100644 tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/main.fmf create mode 100755 tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/runtest.sh create mode 100644 tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/main.fmf create mode 100755 tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/runtest.sh create mode 100644 tests/Sanity/basic-stap-dyninst/main.fmf create mode 100755 tests/Sanity/basic-stap-dyninst/runtest.sh create mode 100644 tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/main.fmf create mode 100755 tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/runtest.sh create mode 100644 tests/Sanity/bz1577333-Remove-abort-warning-in-manual/main.fmf create mode 100755 tests/Sanity/bz1577333-Remove-abort-warning-in-manual/runtest.sh create mode 100644 tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/main.fmf create mode 100755 tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/runtest.sh create mode 100644 tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-msgctl.c create mode 100644 tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-semctl.c create mode 100644 tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-shmctl.c create mode 100644 tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/main.fmf create mode 100755 tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/runtest.sh create mode 100644 tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/main.fmf create mode 100755 tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/runtest.sh create mode 100644 tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/tst.c create mode 100644 tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/main.fmf create mode 100755 tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/runtest.sh create mode 100644 tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/tst-proto.c create mode 100644 tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/main.fmf create mode 100755 tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/runtest.sh create mode 100644 tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/main.fmf create mode 100755 tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/runtest.sh create mode 100644 tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/main.fmf create mode 100755 tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/runtest.sh create mode 100644 tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/test.c create mode 100644 tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/main.fmf create mode 100755 tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/runtest.sh create mode 100644 tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/main.fmf create mode 100755 tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/runtest.sh create mode 100644 tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/main.fmf create mode 100755 tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/runtest.sh create mode 100644 tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/main.fmf create mode 100755 tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/runtest.sh create mode 100644 tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/tst-bz31479.c diff --git a/tests/Sanity/Improve-test-coverage-for-open/main.fmf b/tests/Sanity/Improve-test-coverage-for-open/main.fmf new file mode 100644 index 0000000..21216a2 --- /dev/null +++ b/tests/Sanity/Improve-test-coverage-for-open/main.fmf @@ -0,0 +1,16 @@ +summary: Test FORTIFY handling of missing mode when O_CREAT or O_TMPFILE flags + are used. +description: '' +contact: Martin Coufal +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 5m +extra-summary: + /tools/glibc/Sanity/Improve-test-coverage-for-open +extra-task: + /tools/glibc/Sanity/Improve-test-coverage-for-open diff --git a/tests/Sanity/Improve-test-coverage-for-open/runtest.sh b/tests/Sanity/Improve-test-coverage-for-open/runtest.sh new file mode 100755 index 0000000..7f9066a --- /dev/null +++ b/tests/Sanity/Improve-test-coverage-for-open/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/Improve-test-coverage-for-open +# Description: Test FORTIFY handling of missing mode when O_CREAT or O_TMPFILE flags are used. +# Author: Martin Coufal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2024 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTNAME="test" +ERROR_MESSAGE="error: call to .__open_missing_mode. declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp ${TESTNAME}.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -D_FORTIFY_SOURCE=1 -O1 ${TESTNAME}.c -o ${TESTNAME} 2> ${TESTNAME}.log" 1 + rlAssertNotExists "$TESTNAME" + rlLogInfo "${TESTNAME}.log:\n$(cat ${TESTNAME}.log)" + rlAssertGrep "${ERROR_MESSAGE}" ${TESTNAME}.log + rlAssertEquals "Number of mode missing errors should be 2." "$(cat ${TESTNAME}.log | grep "${ERROR_MESSAGE}" | wc -l)" "2" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/Improve-test-coverage-for-open/test.c b/tests/Sanity/Improve-test-coverage-for-open/test.c new file mode 100644 index 0000000..6feaa76 --- /dev/null +++ b/tests/Sanity/Improve-test-coverage-for-open/test.c @@ -0,0 +1,25 @@ +#define _GNU_SOURCE +#include +#include +#include +#include + +int main() { +int file; +static const char filename[] = "test.test"; + +if ((file = open(filename, O_CREAT)) == 1) +{ + perror("Error opening file."); + exit(EXIT_FAILURE); +} +close(file); + +if ((file = open(filename, O_TMPFILE)) == 1) +{ + perror("Error opening file."); + exit(EXIT_FAILURE); +} +close(file); +} + diff --git a/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/float128-test.c b/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/float128-test.c new file mode 100644 index 0000000..3623dff --- /dev/null +++ b/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/float128-test.c @@ -0,0 +1,5 @@ +int main() +{ + _Float128 a; + return 0; +} diff --git a/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/main.fmf b/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/main.fmf new file mode 100644 index 0000000..6224b46 --- /dev/null +++ b/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/main.fmf @@ -0,0 +1,17 @@ +summary: What the test does +description: '' +adjust: + - enabled: false + when: arch != ppc64le +contact: Sergey Kolosov +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc + - glibc-devel + - gcc +duration: 5m +extra-summary: /tools/glibc/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition +extra-task: /tools/glibc/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition diff --git a/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/runtest.sh b/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/runtest.sh new file mode 100755 index 0000000..ac90018 --- /dev/null +++ b/tests/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/RHEL-10-IBM-POWER-float128-ABI-transition +# Description: What the test does +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2023 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPROG="float128-test" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp ${TESTPROG}.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -c "gcc -mfloat128 -mcpu=power10 ${TESTPROG}.c -o $TESTPROG" + rlAssertExists "$TESTPROG" + rlRun -c "./${TESTPROG}" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/main.fmf b/tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/main.fmf new file mode 100644 index 0000000..2806317 --- /dev/null +++ b/tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/main.fmf @@ -0,0 +1,14 @@ +summary: iconv restore verbosity with unrecognized encoding names +description: '' +contact: Sergey Kolosov +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc +duration: 10m +extra-summary: /tools/glibc/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names +extra-task: /tools/glibc/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names +link: + - verifies: https://issues.redhat.com/browse/RHEL-1018 diff --git a/tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/runtest.sh b/tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/runtest.sh new file mode 100755 index 0000000..c450ff2 --- /dev/null +++ b/tests/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names/runtest.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/RHEL-1018-iconv-restore-verbosity-with-unrecognized-encoding-names +# Description: +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2026 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +NON_EXIST_ENC=NON_EXIST_ENC1 +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -l "echo AAA|LC_ALL=C iconv -f ASCII -t $NON_EXIST_ENC 2>log" 1 + rlAssertGrep "iconv: conversion to .${NON_EXIST_ENC}. is not supported" log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/main.fmf b/tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/main.fmf new file mode 100644 index 0000000..5575950 --- /dev/null +++ b/tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/main.fmf @@ -0,0 +1,17 @@ +summary: + 'Test for RHEL-106166 (glibc: Add Requires(pre) dependency on libgcc).' +description: '' +contact: Sergey Kolosov +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc +duration: 10m +link: + - relates: https://issues.redhat.com/browse/RHEL-106166 + - relates: https://issues.redhat.com/browse/RHEL-110559 +extra-summary: /tools/glibc/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc +extra-task: /tools/glibc/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc +id: 331f2c44-de98-4b6f-be1e-191cc2a7854d diff --git a/tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/runtest.sh b/tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/runtest.sh new file mode 100755 index 0000000..7290ad4 --- /dev/null +++ b/tests/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/RHEL-106166-Add-Requires-pre-dependency-on-libgcc +# Description: Test for RHEL-106166 (glibc: Add Requires(pre) dependency on libgcc). +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2025 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + RPMVER=$(rpm -q glibc.`arch` --qf "%{v}-%{r}\n") + if [ ! $RPMVER ] + then + rlFail "Cannot determinate package version" + fi + rlRpmDownload "${PACKAGE}-${RPMVER}.`arch`" + rlAssertExists "${PACKAGE}-${RPMVER}.`arch`.rpm" + rlRun -l "rpm -qp --qf '[%{REQUIREFLAGS} %{REQUIRES}\n]' "${PACKAGE}-${RPMVER}.`arch`.rpm"|grep \"^512 libgcc\"" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/basic-stap-dyninst/main.fmf b/tests/Sanity/basic-stap-dyninst/main.fmf new file mode 100644 index 0000000..666b8ef --- /dev/null +++ b/tests/Sanity/basic-stap-dyninst/main.fmf @@ -0,0 +1,19 @@ +summary: Basic stap test for glibc dynamic linker +description: '' +contact: Sergey Kolosov +adjust: + - enabled: false + when: arch = s390x +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - gcc + - glibc-common-debuginfo + - glibc-debuginfo + - systemtap + - systemtap-devel +duration: 10m +extra-summary: /tools/glibc/Sanity/basic-stap-dyninst +extra-task: /tools/glibc/Sanity/basic-stap-dyninst diff --git a/tests/Sanity/basic-stap-dyninst/runtest.sh b/tests/Sanity/basic-stap-dyninst/runtest.sh new file mode 100755 index 0000000..54ca286 --- /dev/null +++ b/tests/Sanity/basic-stap-dyninst/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/basic-stap-dyninst +# Description: The test verifies the functionality of SystemTap's dynamic +# instrumentation when interacting with the Glibc dynamic linker. +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2025 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTUSER="slap_dyninst_test_user" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun -c "adduser $TESTUSER" + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -l "sudo -u $TESTUSER -- stap --dyninst -e 'probe process(\"/usr/bin/getent\").function(\"main\") { println(pn()) }' -c '/usr/bin/getent passwd root' &> log" + rlAssertGrep "^root:" log + rlAssertGrep '^process\("/usr/bin/getent"\)\.function\("main@.*glibc-.*nss/getent.*"\)' log "-P" + rlFileSubmit log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun -c "userdel -fr $TESTUSER" + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/main.fmf b/tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/main.fmf new file mode 100644 index 0000000..a49d51c --- /dev/null +++ b/tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/main.fmf @@ -0,0 +1,20 @@ +summary: Test for BZ#1414263 (glibc add ibm-858 to list of charsets for iconv) +description: | + Bug summary: glibc: add ibm-858 to list of charsets for iconv + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1414263 +adjust: + - enabled: false + when: distro < rhel-7.8 +contact: Sergey Kolosov +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1414263 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - util-linux +duration: 10m +extra-summary: /tools/glibc/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv +extra-task: /tools/glibc/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv diff --git a/tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/runtest.sh b/tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/runtest.sh new file mode 100755 index 0000000..0ad4e0c --- /dev/null +++ b/tests/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1414263-glibc-add-ibm-858-to-list-of-charsets-for-iconv +# Description: Test for BZ#1414263 (glibc add ibm-858 to list of charsets for iconv) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -l "echo -e '\xd5' | iconv -f IBM858 -t UTF-8" + rlRun -l "echo -en '\xe2\x82\xac' | iconv -f UTF-8 -t IBM858 > ibm858.euro" + rlRun -l "hexdump ibm858.euro" + rlRun -c "printf '\xd5' > origin.euro" + rlRun -c "cmp ibm858.euro origin.euro" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1577333-Remove-abort-warning-in-manual/main.fmf b/tests/Sanity/bz1577333-Remove-abort-warning-in-manual/main.fmf new file mode 100644 index 0000000..2df1c33 --- /dev/null +++ b/tests/Sanity/bz1577333-Remove-abort-warning-in-manual/main.fmf @@ -0,0 +1,21 @@ +summary: Test for BZ#1577333 (Remove abort() warning in manual.) +description: |+ + Bug summary: Remove abort() warning in manual. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1577333 + + The test should verify that manual doesn't content a joke about abort. + +contact: Sergey Kolosov +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1577333 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc + - glibc-doc + - info +duration: 10m +extra-summary: /tools/glibc/Sanity/bz1577333-Remove-abort-warning-in-manual +extra-task: /tools/glibc/Sanity/bz1577333-Remove-abort-warning-in-manual diff --git a/tests/Sanity/bz1577333-Remove-abort-warning-in-manual/runtest.sh b/tests/Sanity/bz1577333-Remove-abort-warning-in-manual/runtest.sh new file mode 100755 index 0000000..b08ac5d --- /dev/null +++ b/tests/Sanity/bz1577333-Remove-abort-warning-in-manual/runtest.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1577333-Remove-abort-warning-in-manual +# Description: Test for BZ#1577333 (Remove abort() warning in manual.) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlMountAllCommon + rlAssertRpm $PACKAGE + rlPhaseEnd + + rlPhaseStartTest + rlRun "zgrep -qi 'The GNU C Library' /usr/share/info/libc.info*" 0 + rlRun "zcat /usr/share/info/libc.info* 2>/dev/null | grep -qi 'Proposed Federal censorship regulations'" 1 + rlRun "zcat /usr/share/info/libc.info* 2>/dev/null | grep -qi 'prohibit us from giving you information'" 1 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/main.fmf b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/main.fmf new file mode 100644 index 0000000..cdbeeb6 --- /dev/null +++ b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/main.fmf @@ -0,0 +1,18 @@ +summary: Test for BZ#1592475 (glibc headers add ipc STAT_ANY constants) +description: | + Bug summary: glibc headers: add ipc STAT_ANY constants + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1592475 +contact: Sergey Kolosov +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1592475 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - gcc + - glibc + - glibc-devel +duration: 10m +extra-summary: /tools/glibc/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants +extra-task: /tools/glibc/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants diff --git a/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/runtest.sh b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/runtest.sh new file mode 100755 index 0000000..a33b6bc --- /dev/null +++ b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/runtest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants +# Description: Test for BZ#1592475 (glibc headers add ipc STAT_ANY constants) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPROGS="tst-msgctl tst-semctl tst-shmctl" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp tst-msgctl.c tst-semctl.c tst-shmctl.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + for PROG in $TESTPROGS + do + rlPhaseStartTest $PROG + rlRun -c "gcc ${PROG}.c -o $PROG" + rlAssertExists "$PROG" + rlPhaseEnd + done + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-msgctl.c b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-msgctl.c new file mode 100644 index 0000000..8ed2e08 --- /dev/null +++ b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-msgctl.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int idx,mid; + struct msqid_ds ds; + + + if (argc < 2) { + printf("Usage: ./prog \n\n"); + return 1; + } + + idx = atoi(argv[1]); + + mid = msgctl(idx, MSG_STAT_ANY, &ds); + if (mid == -1) { + perror("msgctl"); + exit(1); + } + return 0; +} + diff --git a/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-semctl.c b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-semctl.c new file mode 100644 index 0000000..1a7b54e --- /dev/null +++ b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-semctl.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int idx,sid; + + union semun { + int val; + struct semid_ds *buf; + unsigned short *array; + } semopts; + semopts.val=1; + if (argc < 2) { + printf("Usage: ./prog \n\n"); + return 1; + } + + idx = atoi(argv[1]); + + sid = semctl(idx, 0, SEM_STAT_ANY, semopts); + if( sid == -1) + { + perror("semctl"); + exit(1); + } + + return 0; +} + diff --git a/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-shmctl.c b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-shmctl.c new file mode 100644 index 0000000..0b49e50 --- /dev/null +++ b/tests/Sanity/bz1592475-glibc-headers-add-ipc-STAT-ANY-constants/tst-shmctl.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + struct shmid_ds buf; + int shmid; + int ret; + + if (argc < 2) { + printf("Usage: prog2 \n\n"); + return 1; + } + shmid = atoi(argv[1]); + + ret = shmctl(shmid, SHM_STAT_ANY, &buf); + if (ret < 0) + perror("shmctl SHM_STAT_ANY"); + else + printf("shmctl(%d, SHM_STAT_ANY, ...)=%d\n", shmid, ret); + + return 0; +} diff --git a/tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/main.fmf b/tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/main.fmf new file mode 100644 index 0000000..11ad614 --- /dev/null +++ b/tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/main.fmf @@ -0,0 +1,19 @@ +summary: Test for BZ#1661508 (glibc Adjust to rpm's find-debuginfo.sh changes,) +description: | + Bug summary: glibc: Adjust to rpm's find-debuginfo.sh changes, to keep stripping binaries [rhel-7.7] + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1661508 +contact: Sergey Kolosov +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1661508 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - binutils + - file + - glibc + - glibc-common +duration: 10m +extra-summary: /tools/glibc/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes +extra-task: /tools/glibc/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes diff --git a/tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/runtest.sh b/tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/runtest.sh new file mode 100755 index 0000000..d2e9cf0 --- /dev/null +++ b/tests/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes/runtest.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1661508-glibc-Adjust-to-rpm-s-find-debuginfo-sh-changes +# Description: Test for BZ#1661508 (glibc Adjust to rpm's find-debuginfo.sh changes,) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +SKIPLIST='/usr/bin/ld.so' + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + BINLIST=$(rpm -ql glibc-common glibc|grep bin|tr '\n' ' ') + for BIN in $BINLIST + do + rlAssertExists $BIN + readelf -h $BIN &> /dev/null + RES=$? + if [[ $RES -eq 1 ]] + then + rlLog "$BIN is not binary file" + continue + fi + echo $SKIPLIST | grep -q $BIN + RES=$? + if [[ $RES -eq 0 ]] + then + rlLog "$BIN is marked to be skipped" + continue + fi + rlRun -c "file $BIN > ${BIN}_out" + rlAssertGrep ", stripped" ${BIN}_out + rlAssertNotGrep ", not stripped" ${BIN}_out + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/main.fmf b/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/main.fmf new file mode 100644 index 0000000..dbdcff9 --- /dev/null +++ b/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/main.fmf @@ -0,0 +1,19 @@ +summary: Test for BZ#1699194 (glibc Address conflict between and) +description: | + Bug summary: glibc: Address conflict between and + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1699194 +contact: Sergey Kolosov +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1699194 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - kernel-headers +duration: 10m +extra-summary: /tools/glibc/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and +extra-task: /tools/glibc/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and diff --git a/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/runtest.sh b/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/runtest.sh new file mode 100755 index 0000000..36c1616 --- /dev/null +++ b/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and +# Description: Test for BZ#1699194 (glibc Address conflict between and) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPROG="tst" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp ${TESTPROG}.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG" + rlAssertExists "$TESTPROG" + rlRun -c "./${TESTPROG}" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/tst.c b/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/tst.c new file mode 100644 index 0000000..38f5a20 --- /dev/null +++ b/tests/Sanity/bz1699194-glibc-Address-conflict-between-sys-stat-h-and/tst.c @@ -0,0 +1,15 @@ +#define _GNU_SOURCE +#include +#include +#include + +int main(){ + int dirfd = AT_FDCWD; + const char *pathname=""; + int flags = AT_SYMLINK_NOFOLLOW; + unsigned int mask = STATX_ALL; + struct statx buf; + int ret; + ret = statx(dirfd,pathname,flags,mask,&buf); + return 0; +} diff --git a/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/main.fmf b/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/main.fmf new file mode 100644 index 0000000..abfe96f --- /dev/null +++ b/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/main.fmf @@ -0,0 +1,18 @@ +summary: Test for BZ#1930302 (glibc provide IPPROTO_MPTCP definition) +description: | + Bug summary: glibc: provide IPPROTO_MPTCP definition + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1930302 +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1930302 +contact: Sergey Kolosov +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - gcc + - glibc + - glibc-devel +duration: 5m +extra-summary: /tools/glibc/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition +extra-task: /tools/glibc/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition diff --git a/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/runtest.sh b/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/runtest.sh new file mode 100755 index 0000000..1e7ca6d --- /dev/null +++ b/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition +# Description: Test for BZ#1930302 (glibc provide IPPROTO_MPTCP definition) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPROG="tst-proto" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp ${TESTPROG}.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG" + rlAssertExists "$TESTPROG" + #rlRun -c "./${TESTPROG}" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/tst-proto.c b/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/tst-proto.c new file mode 100644 index 0000000..b68026b --- /dev/null +++ b/tests/Sanity/bz1930302-glibc-provide-IPPROTO-MPTCP-definition/tst-proto.c @@ -0,0 +1,33 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#ifndef IPPROTO_MPTCP +#pragma message "IPPROTO_MPTCP is not defined!" +#endif +#ifndef IPPROTO_ETHERNET +#pragma message "IPPROTO_ETHERNET is not defined!" +#endif + +int main() { + int res; + + int fd1 = socket(AF_INET, SOCK_STREAM, IPPROTO_MPTCP); + if (res<0) { + perror("IPPROTO_MPTCP"); + return 1; + } + close (fd1); + int fd2 = socket(AF_PACKET, SOCK_RAW, IPPROTO_ETHERNET); + if (fd2<0) { + perror("IPPROTO_ETHERNET"); + return 2; + } + close (fd2); + + return 0; +} + diff --git a/tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/main.fmf b/tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/main.fmf new file mode 100644 index 0000000..964c54f --- /dev/null +++ b/tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/main.fmf @@ -0,0 +1,19 @@ +summary: Test for BZ#1940686 (glibc Remove glibc-headers-x86 and) +description: | + Bug summary: glibc: Remove glibc-headers-x86 and glibc-headers-s390 + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1940686 +adjust: + - enabled: false + when: arch != x86_64, s390x +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1940686 +contact: Sergey Kolosov +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc +duration: 10m +extra-summary: /tools/glibc/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and +extra-task: /tools/glibc/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and diff --git a/tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/runtest.sh b/tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/runtest.sh new file mode 100755 index 0000000..36ef331 --- /dev/null +++ b/tests/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and/runtest.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1940686-glibc-Remove-glibc-headers-x86-and +# Description: Test for BZ#1940686 (glibc Remove glibc-headers-x86 and) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPACKAGE="glibc-headers" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun -l "PACK_VERSION=$(rpm --qf "%{version}-%{release}\n" -q ${PACKAGE}.`arch`)" + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + if [[ $(rlGetPrimaryArch) == x86_64 ]] + then + rlRun "dnf repoquery ${TESTPACKAGE}-x86 >log" + rlAssertNotGrep ${TESTPACKAGE}-x86-0:${PACK_VERSION} log + elif [[ $(rlGetPrimaryArch) == s390x ]] + then + rlRun "dnf repoquery ${TESTPACKAGE}-s390 >log" + rlAssertNotGrep ${TESTPACKAGE}-s390-0:${PACK_VERSION} log + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/main.fmf b/tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/main.fmf new file mode 100644 index 0000000..47ab7ca --- /dev/null +++ b/tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/main.fmf @@ -0,0 +1,15 @@ +summary: What the test does +description: '' +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1971664 +contact: Sergey Kolosov +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc + - glibc-gconv-extra +duration: 10m +extra-summary: /tools/glibc/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package +extra-task: /tools/glibc/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package diff --git a/tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/runtest.sh b/tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/runtest.sh new file mode 100755 index 0000000..de2be4a --- /dev/null +++ b/tests/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package/runtest.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz1971664-Split-extra-gconv-modules-into-a-separate-package +# Description: What the test does +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2022 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlPhaseEnd + + rlPhaseStartTest + rlAssertRpm glibc-gconv-extra + rlPhaseEnd + + rlPhaseStartCleanup + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/main.fmf b/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/main.fmf new file mode 100644 index 0000000..d447358 --- /dev/null +++ b/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/main.fmf @@ -0,0 +1,23 @@ +summary: 'Test for BZ#2011754 (RHEL9.0 - S390: Add PCI_MIO and SIE HWCAPs in glibc + header file)' +description: | + Bug summary: RHEL9.0 - S390: Add PCI_MIO and SIE HWCAPs in glibc header file + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=2011754 +contact: Martin Coufal +adjust: + - enabled: false + when: arch != s390x +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011754 +component: + - glibc + - glibc-devel + - gcc +test: ./runtest.sh +framework: beakerlib +require: + - glibc + - gcc +duration: 10m +extra-summary: /tools/glibc/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs +extra-task: /tools/glibc/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs diff --git a/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/runtest.sh b/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/runtest.sh new file mode 100755 index 0000000..5d0ca9a --- /dev/null +++ b/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs +# Description: Test for BZ#2011754 (RHEL9.0 - S390: Add PCI_MIO and SIE HWCAPs in glibc header file) +# Author: Martin Coufal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPROG="test" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp ${TESTPROG}.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG" + rlAssertExists "$TESTPROG" + rlRun -l "./${TESTPROG}" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/test.c b/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/test.c new file mode 100644 index 0000000..b94d80c --- /dev/null +++ b/tests/Sanity/bz2011754-add-PCI_MIO-andSIE-HWCAPs/test.c @@ -0,0 +1,8 @@ +#include +#include + +int main (void) { + printf ("%d\n", HWCAP_S390_PCI_MIO); + printf ("%d\n", HWCAP_S390_SIE); + return 0; +} diff --git a/tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/main.fmf b/tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/main.fmf new file mode 100644 index 0000000..8d01c18 --- /dev/null +++ b/tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/main.fmf @@ -0,0 +1,16 @@ +summary: Test for BZ#2021671 (glibc Backport glibc-docs subpackage to support) +description: | + Bug summary: glibc: Backport glibc-docs subpackage to support smaller production containers. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=2021671 +contact: Sergey Kolosov +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2021671 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc-doc +duration: 5m +extra-summary: /tools/glibc/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support +extra-task: /tools/glibc/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support diff --git a/tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/runtest.sh b/tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/runtest.sh new file mode 100755 index 0000000..457ce37 --- /dev/null +++ b/tests/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support/runtest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz2021671-glibc-Backport-glibc-docs-subpackage-to-support +# Description: Test for BZ#2021671 (glibc Backport glibc-docs subpackage to support) +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlAssertRpm glibc-doc + rlRun -l "rpm -ql glibc-doc > log" + rlAssertGrep "/usr/share/doc/glibc/rtld-debugger-interface.txt" log + rlAssertGrep "/usr/share/info/libc.info-" log + rlAssertNotExists "/usr/share/doc/glibc/README" + rlAssertNotExists "/usr/share/doc/glibc/INSTALL" + rlAssertNotExists "/usr/share/doc/glibc/NEWS" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/main.fmf b/tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/main.fmf new file mode 100644 index 0000000..f11f615 --- /dev/null +++ b/tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/main.fmf @@ -0,0 +1,20 @@ +summary: 'Test for BZ#2054790 (locale: de-duplicate LC_CTYPE files in glibc-langpack-* + by symlinking identical copies to C.utf8 variant)' +description: | + Bug summary: locale: de-duplicate LC_CTYPE files in glibc-langpack-* by symlinking identical copies to C.utf8 variant + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=2054790 +contact: Martin Coufal +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2054790 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - glibc + - glibc-all-langpacks +duration: 10m +extra-summary: + /tools/glibc/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack +extra-task: + /tools/glibc/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack diff --git a/tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/runtest.sh b/tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/runtest.sh new file mode 100755 index 0000000..b8380b4 --- /dev/null +++ b/tests/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack/runtest.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz2054790-locale-de-duplicate-LC_CTYPE-files-in-glibc-langpack +# Description: Test for BZ#2054790 (locale: de-duplicate LC_CTYPE files in glibc-langpack-* by symlinking identical copies to C.utf8 variant) +# Author: Martin Coufal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2022 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +LC_CTYPE_ORIG='/usr/lib/locale/C.utf8/LC_CTYPE' + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "PRESENT_LANGPACKS=\"$(rpm -qa | grep glibc-langpack | tr '\n' ' ')\"" + rlRun "yum -y install glibc-langpack-*" + rlRun "tmpdir=$(mktemp -d)" + rlRun "pushd $tmpdir" + rlRun -l "C_UTF8_LC_CTYPE_MD5SUM=$(md5sum ${LC_CTYPE_ORIG} | cut -d " " -f1)" + rlPhaseEnd + + rlPhaseStartTest + for file in $(find /usr/lib/locale/ -name LC_CTYPE); do + # skip original (dest of symlinks) + if [[ "${file}" == "${LC_CTYPE_ORIG}" ]]; then + rlLogInfo "Original can be skipped" + continue + # symlinks are expected + elif [[ -L ${file} ]]; then + rlLogInfo "Found LC_CTYPE symlink: ${file}" + # if not a symlink, then it shouldn't be identical to '/usr/lib/locale/C.utf8/LC_CTYPE' + else + FILE_MD5SUM=$(md5sum ${file} | cut -d " " -f1) + if [[ "${FILE_MD5SUM}" == "${C_UTF8_LC_CTYPE_MD5SUM}" ]]; then + rlFail "Found LC_CTYPE file that is identical to '${LC_CTYPE_ORIG}' and is not a symlink! (${file})" + fi + fi + done + # test identical files have been grouped via hardlinks - expectiong no output + lang_groups=$(ls -1 /usr/lib/locale | cut -d "_" -f1 | grep -v C.utf8 | grep -v locale-archive | sort -u) + for group in $lang_groups; do + if rlIsRHEL ">=9" || rlIsCentOS ">=9" + then + rlRun -c "hardlink -p -o -t -n -v /usr/lib/locale/${group}_* /usr/lib/locale/C.utf8 > hardlink.out" + # sanity check - at least one file found in each locale group + rlRun -c "grep -E '^Files:[[:space:]]*0' hardlink.out" 1 + rlRun -c "grep '\[DryRun\]' hardlink.out > log" 0,1 + # there are still two small files LC_MEASUREMENT and LC_PAPER in the rest. Talked with developer, that's ok + rlRun -c "grep -v 'LC_MEASUREMENT\|LC_PAPER' log" 1 + rlFileSubmit "hardlink.out" + rlFileSubmit "log" + else + rlRun "hardlink -c -n /usr/lib/locale/${group}_* /usr/lib/locale/C.utf8 > hardlink.out 2>&1" + [[ -s hardlink.out ]] && rlFail "Identical files should be grouped via hardlinks: $(cat hardlink.out)" + fi + done + rlPhaseEnd + + rlPhaseStartCleanup + # remove langpacks installed in setup phase + rpm -qa | grep glibc-langpack > langpack_list.txt + for langpack in $PRESENT_LANGPACKS; do + rlRun "sed -i 's/$langpack//' langpack_list.txt" + done + rlRun "yum -y remove $(cat langpack_list.txt | tr '\n' ' ')" + rlRun "popd" + rlRun "rm -rf $tmpdir" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/main.fmf b/tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/main.fmf new file mode 100644 index 0000000..55c6d7e --- /dev/null +++ b/tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/main.fmf @@ -0,0 +1,20 @@ +summary: What the test does +description: '' +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2063247 +contact: Sergey Kolosov +adjust: + - enabled: false + when: arch != x86_64 +component: + - glibc +test: ./runtest.sh +framework: beakerlib +require: + - binutils + - glibc +duration: 5m +extra-summary: + /tools/glibc/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers +extra-task: + /tools/glibc/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers diff --git a/tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/runtest.sh b/tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/runtest.sh new file mode 100755 index 0000000..b80185f --- /dev/null +++ b/tests/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers/runtest.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/bz2063247-Respin-glibc-with-new-systemtap-to-avoid-XMM-registers +# Description: What the test does +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2022 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -c "readelf -n /lib64/libc.so.6 > log" + rlAssertNotGrep "xmm" log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/main.fmf b/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/main.fmf new file mode 100644 index 0000000..3317abb --- /dev/null +++ b/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/main.fmf @@ -0,0 +1,13 @@ +summary: What the test does +description: '' +contact: Martin Coufal +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 5m +extra-summary: /tools/glibc/Sanity/sched_getcpu-returns-correct-pinned-CPU +extra-task: /tools/glibc/Sanity/sched_getcpu-returns-correct-pinned-CPU +id: 8d0f7a70-771d-43ff-964c-67c05b3935cb diff --git a/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/runtest.sh b/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/runtest.sh new file mode 100755 index 0000000..00205d8 --- /dev/null +++ b/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/runtest.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/sched_getcpu-returns-correct-pinned-CPU +# Description: What the test does +# Author: Martin Coufal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2024 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TEST_NAME="tst-bz31479" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp ${TEST_NAME}.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc ${TEST_NAME}.c -o $TEST_NAME" + rlAssertExists $TEST_NAME + + # select random CPU + CPU_NUMBER=$(lscpu | grep "^CPU(s):" | cut -d ':' -f 2 | xargs) + rlAssertGreaterOrEqual "At least 2 CPUs are needed for this test" $CPU_NUMBER 2 + SELECTED_CPU=$((RANDOM % $CPU_NUMBER)) + rlPhaseEnd + + rlPhaseStartTest + rlRun "taskset -c $SELECTED_CPU ./$TEST_NAME &> ${TEST_NAME}.log" + rlAssertExists "${TEST_NAME}.log" + rlAssertGrep "CPU $SELECTED_CPU" ${TEST_NAME}.log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/tst-bz31479.c b/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/tst-bz31479.c new file mode 100644 index 0000000..7a53a07 --- /dev/null +++ b/tests/Sanity/sched_getcpu-returns-correct-pinned-CPU/tst-bz31479.c @@ -0,0 +1,9 @@ +#define _GNU_SOURCE +#include +#include + +int main() { + printf("CPU %d\n",sched_getcpu()); + return 0; +} + From d7685e74ea0ecdcbc8795726a26c0a1c3a2f4378 Mon Sep 17 00:00:00 2001 From: Sergey Kolosov Date: Mon, 1 Jun 2026 20:35:15 +0200 Subject: [PATCH 2/5] CI Tests: tests: require 2 CPUs in tmt provision and format ci.fmf Clean up YAML indentation in the CI gating plan and explicitly request hardware with at least 2 processors. This is required by some of the new tests. RPM-Changelog: - RPM-Skip-Release: yes --- plans/ci.fmf | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plans/ci.fmf b/plans/ci.fmf index 7ebb797..1ee4b71 100644 --- a/plans/ci.fmf +++ b/plans/ci.fmf @@ -1,13 +1,21 @@ summary: CI Gating Plan + discover: - how: fmf + how: fmf + +provision: + hardware: + cpu: + processors: ">= 2" + prepare: - - name: prepare - how: shell - script: ./plans/prepare.sh - - name: install - how: install - exclude: - - glibc-headers-s390 + - name: prepare + how: shell + script: ./plans/prepare.sh + - name: install + how: install + exclude: + - glibc-headers-s390 + execute: - how: tmt + how: tmt From 04715b79ce9a5bfa65ed38d7f69418693d29700a Mon Sep 17 00:00:00 2001 From: Sergey Kolosov Date: Fri, 19 Jun 2026 14:33:02 +0200 Subject: [PATCH 3/5] CI Gating: Add fail-fast test plan jobs as required rules RPM-Changelog: - RPM-Skip-Release: yes --- gating.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gating.yaml b/gating.yaml index 1a0987b..1eb9868 100644 --- a/gating.yaml +++ b/gating.yaml @@ -15,6 +15,8 @@ product_versions: - rhel-10 decision_context: osci_compose_gate rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.gate-build-fast-lane-fail-fast.functional} + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.gate-build-slow-lane-fail-fast.functional} - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.gate-build-fast-lane-testsuite.functional} - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.gate-build-slow-lane-testsuite.functional} - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.gate-build-fast-lane-tier0.functional} From 0d62f4876493c79f497ad980af5e6f80a568d56a Mon Sep 17 00:00:00 2001 From: Patsy Griffin Date: Mon, 22 Jun 2026 06:52:00 -0400 Subject: [PATCH 4/5] CVE-2026-5450: Fix buffer overflow in scanf (RHEL-172694) Resolves: RHEL-172694 --- glibc-RHEL-172694-1.patch | 123 ++++++++++ glibc-RHEL-172694-2.patch | 76 +++++++ glibc-RHEL-172694-3.patch | 457 ++++++++++++++++++++++++++++++++++++++ glibc-RHEL-172694-4.patch | 193 ++++++++++++++++ 4 files changed, 849 insertions(+) create mode 100644 glibc-RHEL-172694-1.patch create mode 100644 glibc-RHEL-172694-2.patch create mode 100644 glibc-RHEL-172694-3.patch create mode 100644 glibc-RHEL-172694-4.patch diff --git a/glibc-RHEL-172694-1.patch b/glibc-RHEL-172694-1.patch new file mode 100644 index 0000000..9c986da --- /dev/null +++ b/glibc-RHEL-172694-1.patch @@ -0,0 +1,123 @@ +commit 839898777226a3ed88c0859f25ffe712519b4ead +Author: Rocket Ma +Date: Fri Apr 17 23:48:41 2026 -0700 + + stdio-common: Fix buffer overflow in scanf %mc [BZ #34008] + + * stdio-common/vfscanf-internal.c: When enlarging allocated buffer with + format %mc or %mC, glibc allocates one byte less, leading to + user-controlled one byte overflow. This commit fixes BZ #34008, or + CVE-2026-5450. + + Reviewed-by: Carlos O'Donell + Signed-off-by: Rocket Ma + Reviewed-by: H.J. Lu + +diff --git a/stdio-common/Makefile b/stdio-common/Makefile +index 210944837e..0c0085e607 100644 +--- a/stdio-common/Makefile ++++ b/stdio-common/Makefile +@@ -349,6 +349,7 @@ tests := \ + tst-vfprintf-user-type \ + tst-vfprintf-width-i18n \ + tst-vfprintf-width-prec-alloc \ ++ tst-vfscanf-bz34008 \ + tst-wc-printf \ + tstdiomisc \ + tstgetln \ +@@ -564,6 +565,9 @@ tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \ + tst-vfprintf-width-prec-ENV = \ + MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \ + LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so ++tst-vfscanf-bz34008-ENV = \ ++ MALLOC_CHECK_=3 \ ++ LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so + tst-printf-bz25691-ENV = \ + MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \ + LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so +diff --git a/stdio-common/tst-vfscanf-bz34008.c b/stdio-common/tst-vfscanf-bz34008.c +new file mode 100644 +index 0000000000..48371c8a3d +--- /dev/null ++++ b/stdio-common/tst-vfscanf-bz34008.c +@@ -0,0 +1,48 @@ ++/* Regression test for vfscanf %Nmc out-of-bound write (BZ #34008) ++ Copyright (C) 2026 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 ++ 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 "malloc/mcheck.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define WIDTH 0x410 ++#define SCANFSTR "%1040mc" ++static int ++do_test (void) ++{ ++ mcheck_pedantic (NULL); ++ char *input = malloc (WIDTH + 1); ++ TEST_VERIFY (input != NULL); ++ memset (input, 'A', WIDTH); ++ input[WIDTH] = '\0'; ++ ++ char *buf = NULL; ++ TEST_VERIFY (sscanf (input, SCANFSTR, &buf) != -1); ++ TEST_VERIFY (buf != NULL); ++ ++ free (buf); ++ free (input); ++ return 0; ++} ++ ++#include +diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c +index 59fc8208aa..3d11ac261e 100644 +--- a/stdio-common/vfscanf-internal.c ++++ b/stdio-common/vfscanf-internal.c +@@ -855,8 +855,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + { + /* Enlarge the buffer. */ + size_t newsize +- = strsize +- + (strsize >= width ? width - 1 : strsize); ++ = strsize + (strsize >= width ? width : strsize); + + str = (char *) realloc (*strptr, newsize); + if (str == NULL) +@@ -929,7 +928,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + && wstr == (wchar_t *) *strptr + strsize) + { + size_t newsize +- = strsize + (strsize > width ? width - 1 : strsize); ++ = strsize + (strsize >= width ? width : strsize); + /* Enlarge the buffer. */ + wstr = (wchar_t *) realloc (*strptr, + newsize * sizeof (wchar_t)); +@@ -984,7 +983,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + && wstr == (wchar_t *) *strptr + strsize) + { + size_t newsize +- = strsize + (strsize > width ? width - 1 : strsize); ++ = strsize + (strsize >= width ? width : strsize); + /* Enlarge the buffer. */ + wstr = (wchar_t *) realloc (*strptr, + newsize * sizeof (wchar_t)); diff --git a/glibc-RHEL-172694-2.patch b/glibc-RHEL-172694-2.patch new file mode 100644 index 0000000..a2d1182 --- /dev/null +++ b/glibc-RHEL-172694-2.patch @@ -0,0 +1,76 @@ +commit b866ef29773b22a1343ff9084374775114350b78 +Author: Maciej W. Rozycki +Date: Wed May 27 12:57:10 2026 -0400 + + support: Implement 'xfmemopen' for seamless 'fmemopen' use + + Add 'xfmemopen' wrapper for seamless 'fmemopen' use in tests, following + 'xfopen', 'xfclose', etc., and providing a standardized error reporting + facility. + + Reviewed-by: Florian Weimer + (cherry picked from commit fe709cc24578ecfd2ff5b07e10e3829fcb55075b) + + Reviewed-by: Carlos O'Donell + +diff --git a/support/Makefile b/support/Makefile +index d41278eeab..f67f38130a 100644 +--- a/support/Makefile ++++ b/support/Makefile +@@ -134,6 +134,7 @@ libsupport-routines = \ + xfclose \ + xfdopendir \ + xfgets \ ++ xfmemopen \ + xfopen \ + xfork \ + xfread \ +diff --git a/support/xfmemopen.c b/support/xfmemopen.c +new file mode 100644 +index 0000000000..f1dbc72c67 +--- /dev/null ++++ b/support/xfmemopen.c +@@ -0,0 +1,31 @@ ++/* fmemopen with error checking. ++ Copyright (C) 2025 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 ++ ++FILE * ++xfmemopen (void *mem, size_t len, const char *mode) ++{ ++ FILE *fp = fmemopen (mem, len, mode); ++ if (fp == NULL) ++ FAIL_EXIT1 ("fmemopen (mode \"%s\"): %m", mode); ++ return fp; ++} +diff --git a/support/xstdio.h b/support/xstdio.h +index c3fdf9496f..70b83f11da 100644 +--- a/support/xstdio.h ++++ b/support/xstdio.h +@@ -27,6 +27,7 @@ __BEGIN_DECLS + FILE *xfopen (const char *path, const char *mode); + void xfclose (FILE *); + FILE *xfreopen (const char *path, const char *mode, FILE *stream); ++FILE *xfmemopen (void *mem, size_t len, const char *mode); + void xfread (void *ptr, size_t size, size_t nmemb, FILE *stream); + char *xfgets (char *s, int size, FILE *stream); + diff --git a/glibc-RHEL-172694-3.patch b/glibc-RHEL-172694-3.patch new file mode 100644 index 0000000..e12d92b --- /dev/null +++ b/glibc-RHEL-172694-3.patch @@ -0,0 +1,457 @@ +commit 97926e9017f3faeaacce9337f1288460f5e6ec7d +Author: Maciej W. Rozycki +Date: Wed May 27 12:57:10 2026 -0400 + + stdio-common: Reject insufficient character data in scanf [BZ #12701] + + Reject invalid formatted scanf character data with the 'c' conversion + where there is not enough input available to satisfy the field width + requested. It is required by ISO C that this conversion matches a + sequence of characters of exactly the number specified by the field + width and it is also already documented as such in our own manual: + + "It reads precisely the next N characters, and fails if it cannot get + that many." + + Currently a matching success is instead incorrectly produced where the + EOF condition is encountered before the required number of characters + has been retrieved, and the characters actually obtained are stored in + the buffer provided. + + Add test cases accordingly and remove placeholders from 'c' conversion + input data for the existing scanf tests. + + Reviewed-by: Adhemerval Zanella + + [This is a modified version of commit 2b16c76609, which tests for the + old behavior and only includes the test cases, for older branches + and downstream backports - DJ] + + Reviewed-by: Carlos O'Donell + +Conflicts: + localedata/Makefile + (usual test differences) + +diff -Nrup a/localedata/Makefile b/localedata/Makefile +--- a/localedata/Makefile 2024-01-30 19:34:58.000000000 -0500 ++++ b/localedata/Makefile 2026-06-18 17:22:24.351290348 -0400 +@@ -234,6 +234,7 @@ tests = \ + bug-iconv-trans \ + bug-setlocale1 \ + bug-usesetlocale \ ++ tst-bz12701-lc \ + tst-c-utf8-consistency \ + tst-digits \ + tst-iconv-emojis-trans \ +diff --git a/localedata/tst-bz12701-lc.c b/localedata/tst-bz12701-lc.c +new file mode 100644 +index 0000000000..23c2ab7d2a +--- /dev/null ++++ b/localedata/tst-bz12701-lc.c +@@ -0,0 +1,218 @@ ++/* Verify scanf field width handling with the 'lc' conversion (BZ #12701). ++ Copyright (C) 2025-2026 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 ++#include ++ ++#include ++#include ++#include ++#include ++ ++/* Compare character-wise the initial part of the wide character object ++ pointed to by WS corresponding to wide characters obtained by the ++ conversion of first N bytes of the multibyte character object pointed ++ to by S. */ ++ ++static int ++tst_bz12701_lc_memcmp (const wchar_t *ds, const char *s, size_t n) ++{ ++ size_t nc = mbsnrtowcs (NULL, &s, n, 0, NULL); ++ ++ struct support_next_to_fault ntf; ++ ntf = support_next_to_fault_allocate (nc * sizeof (wchar_t)); ++ wchar_t *ss = (wchar_t *) ntf.buffer; ++ ++ mbsnrtowcs (ss, &s, n, nc, NULL); ++ int r = wmemcmp (ds, ss, nc); ++ ++ support_next_to_fault_free (&ntf); ++ ++ return r; ++} ++ ++/* Verify various aspects of field width handling, including the data ++ obtained, the number of bytes consumed, and the stream position. */ ++ ++static int ++do_test (void) ++{ ++ if (setlocale (LC_ALL, "pl_PL.UTF-8") == NULL) ++ FAIL_EXIT1 ("setlocale (LC_ALL, \"pl_PL.UTF-8\")"); ++ ++ /* Part of a tongue-twister in Polish, which says: ++ "On a rainy morning cuckoos and warblers, rather than starting ++ on earthworms, stuffed themselves fasted with the flesh of cress." */ ++ static const char s[126] = "Dżdżystym rankiem gżegżółki i piegże, " ++ "zamiast wziąć się za dżdżownice, " ++ "nażarły się na czczo miąższu rzeżuchy"; ++ ++ const char *sp = s; ++ size_t nc; ++ TEST_VERIFY_EXIT ((nc = mbsnrtowcs (NULL, &sp, sizeof (s), 0, NULL)) == 108); ++ ++ struct support_next_to_fault ntfo, ntfi; ++ ntfo = support_next_to_fault_allocate (nc * sizeof (wchar_t)); ++ ntfi = support_next_to_fault_allocate (sizeof (s)); ++ wchar_t *e = (wchar_t *) ntfo.buffer + nc; ++ char *b = ntfi.buffer; ++ ++ wchar_t *c; ++ FILE *f; ++ int ic; ++ int n; ++ int i; ++ ++ memcpy (ntfi.buffer, s, sizeof (s)); ++ ++ ic = i = 0; ++ f = xfmemopen (b, sizeof (s), "r"); ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ /* Avoid: "warning: zero width in gnu_scanf format [-Werror=format=]". */ ++ DIAG_PUSH_NEEDS_COMMENT; ++ DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat"); ++ TEST_VERIFY_EXIT (fscanf (f, "%0lc%n", c, &n) == 1); ++ DIAG_POP_NEEDS_COMMENT; ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 1; ++ i += n; ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 2); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 1; ++ i += n; ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%1lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 1; ++ i += n; ++ ++ c = e - 2; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 3); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 2; ++ i += n; ++ ++ c = e - 4; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%4lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 4); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 4; ++ i += n; ++ ++ c = e - 8; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%8lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 8); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 8; ++ i += n; ++ ++ c = e - 16; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%16lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 20); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 16; ++ i += n; ++ ++ c = e - 32; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%32lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 38); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 32; ++ i += n; ++ ++ c = e - (nc - ic); ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_COMPARE (fscanf (f, "%64lc%n", c, &n), 1); ++ TEST_COMPARE (n , 49); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, sizeof (s) - i) == 0); ++ ++ TEST_VERIFY_EXIT (ftell (f) == sizeof (s)); ++ TEST_VERIFY_EXIT (feof (f) != 0); ++ ++ xfclose (f); ++ ++ ic = i = 0; ++ f = xfmemopen (b, 3, "r"); ++ ++ c = e - 2; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 3); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 2; ++ i += n; ++ ++ c = e - (nc - ic); ++ TEST_VERIFY_EXIT (feof (f) == 0); ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2lc%n", c, &n) == EOF); ++ TEST_VERIFY_EXIT (n == 3); ++ ++ TEST_VERIFY_EXIT (ftell (f) == 3); ++ TEST_VERIFY_EXIT (feof (f) != 0); ++ ++ xfclose (f); ++ ++ ic = i = 0; ++ f = xfmemopen (b, 3, "r"); ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, n) == 0); ++ ic += 1; ++ i += n; ++ ++ c = e - (nc - ic); ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2lc%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 2); ++ TEST_VERIFY_EXIT (tst_bz12701_lc_memcmp (c, s + i, 3 - i) == 0); ++ ++ TEST_VERIFY_EXIT (ftell (f) == 3); ++ TEST_VERIFY_EXIT (feof (f) != 0); ++ ++ xfclose (f); ++ ++ support_next_to_fault_free (&ntfi); ++ support_next_to_fault_free (&ntfo); ++ ++ return 0; ++} ++ ++#include +diff --git a/stdio-common/Makefile b/stdio-common/Makefile +index e52c333808..fdb545242e 100644 +--- a/stdio-common/Makefile ++++ b/stdio-common/Makefile +@@ -260,6 +260,7 @@ tests := \ + tllformat \ + tst-bz11319 \ + tst-bz11319-fortify2 \ ++ tst-bz12701-c \ + tst-cookie \ + tst-dprintf-length \ + tst-fclose-devzero \ +diff --git a/stdio-common/tst-bz12701-c.c b/stdio-common/tst-bz12701-c.c +new file mode 100644 +index 0000000000..4f3616fbfd +--- /dev/null ++++ b/stdio-common/tst-bz12701-c.c +@@ -0,0 +1,169 @@ ++/* Verify scanf field width handling with the 'c' conversion (BZ #12701). ++ Copyright (C) 2025-2026 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 ++#include ++#include ++ ++/* Verify various aspects of field width handling, including the data ++ obtained, the number of bytes consumed, and the stream position. */ ++ ++static int ++do_test (void) ++{ ++ static const char s[43] = "The quick brown fox jumps over the lazy dog"; ++ struct support_next_to_fault ntfo, ntfi; ++ ntfo = support_next_to_fault_allocate (sizeof (s)); ++ ntfi = support_next_to_fault_allocate (sizeof (s)); ++ char *e = ntfo.buffer + sizeof (s); ++ char *b = ntfi.buffer; ++ ++ char *c; ++ FILE *f; ++ int n; ++ int i; ++ ++ memcpy (ntfi.buffer, s, sizeof (s)); ++ ++ i = 0; ++ f = xfmemopen (b, sizeof (s), "r"); ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ /* Avoid: "warning: zero width in gnu_scanf format [-Werror=format=]". */ ++ DIAG_PUSH_NEEDS_COMMENT; ++ DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat"); ++ TEST_VERIFY_EXIT (fscanf (f, "%0c%n", c, &n) == 1); ++ DIAG_POP_NEEDS_COMMENT; ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%1c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - 2; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 2); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - 4; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%4c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 4); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - 8; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%8c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 8); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - 16; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%16c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 16); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - (sizeof (s) - i); ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%32c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 10); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, sizeof (s) - i) == 0); ++ ++ TEST_VERIFY_EXIT (ftell (f) == sizeof (s)); ++ TEST_VERIFY_EXIT (feof (f) != 0); ++ ++ xfclose (f); ++ ++ i = 0; ++ f = xfmemopen (b, 3, "r"); ++ ++ c = e - 1; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - 2; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 2); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - (3 - i); ++ TEST_VERIFY_EXIT (feof (f) == 0); ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == EOF); ++ TEST_VERIFY_EXIT (n == 2); ++ ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (feof (f) != 0); ++ ++ xfclose (f); ++ ++ i = 0; ++ f = xfmemopen (b, 3, "r"); ++ ++ c = e - 2; ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 2); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); ++ i += n; ++ ++ c = e - (3 - i); ++ TEST_VERIFY_EXIT (ftell (f) == i); ++ TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == 1); ++ TEST_VERIFY_EXIT (n == 1); ++ TEST_VERIFY_EXIT (memcmp (c, s + i, 3 - i) == 0); ++ ++ TEST_VERIFY_EXIT (ftell (f) == 3); ++ TEST_VERIFY_EXIT (feof (f) != 0); ++ ++ xfclose (f); ++ ++ support_next_to_fault_free (&ntfi); ++ support_next_to_fault_free (&ntfo); ++ ++ return 0; ++} ++ ++#include diff --git a/glibc-RHEL-172694-4.patch b/glibc-RHEL-172694-4.patch new file mode 100644 index 0000000..038227c --- /dev/null +++ b/glibc-RHEL-172694-4.patch @@ -0,0 +1,193 @@ +commit 6cebb0b80fd783e442a8ad27c3f52cde52a9cac7 +Author: DJ Delorie +Date: Wed May 27 12:57:10 2026 -0400 + + stdio-common: Allow partially-filled %mc buffers [BZ #12701] + + This is a backwards-compatible alternative to the main solution to + the %mc part of 12701. The allocated buffer is expanded to the + requested size and NUL padded, but truncated reads are allowed. + + Reviewed-by: Carlos O'Donell + +Conflicts: + localedata/Makefile + (usual test differences) + +diff -Nrup a/localedata/Makefile b/localedata/Makefile +--- a/localedata/Makefile 2026-06-18 17:24:13.116929727 -0400 ++++ b/localedata/Makefile 2026-06-18 17:24:46.030126591 -0400 +@@ -235,6 +235,7 @@ tests = \ + bug-setlocale1 \ + bug-usesetlocale \ + tst-bz12701-lc \ ++ tst-bz12701-lc2 \ + tst-c-utf8-consistency \ + tst-digits \ + tst-iconv-emojis-trans \ +diff --git a/localedata/tst-bz12701-lc2.c b/localedata/tst-bz12701-lc2.c +new file mode 100644 +index 0000000000..b24e86df0b +--- /dev/null ++++ b/localedata/tst-bz12701-lc2.c +@@ -0,0 +1,47 @@ ++/* Verify scanf memory handling with the 'c' conversion (BZ #12701). ++ Copyright (C) 2026 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 ++#include ++#include ++#include ++ ++static int ++do_test (void) ++{ ++ wchar_t *c = NULL; ++ int i; ++ ++ TEST_VERIFY (sscanf ("1234", "%30mlc", &c) == 1); ++ ++ TEST_VERIFY (c != NULL); ++ TEST_COMPARE_BLOB (c, 5 * sizeof (wchar_t), ++ L"1234\0", 5 * sizeof (wchar_t)); ++ for (i = 5; i < 30; i ++) ++ TEST_VERIFY (c[i] == L'\0'); ++ ++ TEST_VERIFY (malloc_usable_size (c) >= 30 * sizeof(wchar_t)); ++ ++ return 0; ++} ++ ++#include +diff --git a/stdio-common/Makefile b/stdio-common/Makefile +index fdb545242e..27e7ea20f0 100644 +--- a/stdio-common/Makefile ++++ b/stdio-common/Makefile +@@ -261,6 +261,7 @@ tests := \ + tst-bz11319 \ + tst-bz11319-fortify2 \ + tst-bz12701-c \ ++ tst-bz12701-c2 \ + tst-cookie \ + tst-dprintf-length \ + tst-fclose-devzero \ +diff --git a/stdio-common/tst-bz12701-c2.c b/stdio-common/tst-bz12701-c2.c +new file mode 100644 +index 0000000000..5f9ca7c592 +--- /dev/null ++++ b/stdio-common/tst-bz12701-c2.c +@@ -0,0 +1,46 @@ ++/* Verify scanf memory handling with the 'c' conversion (BZ #12701). ++ Copyright (C) 2026 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 ++#include ++#include ++#include ++ ++static int ++do_test (void) ++{ ++ char *c = NULL; ++ int i; ++ ++ TEST_VERIFY (sscanf ("1234", "%30mc", &c) == 1); ++ ++ TEST_VERIFY (c != NULL); ++ TEST_COMPARE_BLOB (c, 5, "1234\0", 5); ++ for (i = 5; i < 30; i ++) ++ TEST_VERIFY (c[i] == '\0'); ++ ++ TEST_VERIFY (malloc_usable_size (c) >= 30); ++ ++ return 0; ++} ++ ++#include +diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c +index 17b5565d0f..90a1886951 100644 +--- a/stdio-common/vfscanf-internal.c ++++ b/stdio-common/vfscanf-internal.c +@@ -780,9 +780,9 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + conv_error (); \ + } while (0) + #ifdef COMPILE_WSCANF +- STRING_ARG (str, char, 100); ++ STRING_ARG (str, char, (width > 0 ? width : 1)); + #else +- STRING_ARG (str, char, (width > 1024 ? 1024 : width)); ++ STRING_ARG (str, char, (width > 0 ? width : 1)); + #endif + + c = inchar (); +@@ -891,6 +891,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + + if (!(flags & SUPPRESS)) + { ++ /* If the buffer isn't completely filled, pad it with NULs. */ ++ if (flags & MALLOC) ++ while (width-- > 0) ++ *str++ = '\0'; ++ + if ((flags & MALLOC) && str - *strptr != strsize) + { + char *cp = (char *) realloc (*strptr, str - *strptr); +@@ -908,7 +913,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + if (width == -1) + width = 1; + +- STRING_ARG (wstr, wchar_t, (width > 1024 ? 1024 : width)); ++ STRING_ARG (wstr, wchar_t, (width > 0 ? width : 1)); + + c = inchar (); + if (__glibc_unlikely (c == EOF)) +@@ -1044,6 +1049,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + + if (!(flags & SUPPRESS)) + { ++ /* If the buffer isn't completely filled, pad it with NULs. */ ++ if (flags & MALLOC) ++ while (width-- > 0) ++ *wstr++ = L'\0'; ++ + if ((flags & MALLOC) && wstr - (wchar_t *) *strptr != strsize) + { + wchar_t *cp = (wchar_t *) realloc (*strptr, From 50833c84b12427684b80cf68765ce770d76bca88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= Date: Fri, 12 Jun 2026 10:23:20 +0200 Subject: [PATCH 5/5] x86-64: Prefer EVEX512 string and memory functions on AMD Zen5 (RHEL-174869) Resolves: RHEL-174869 --- glibc-RHEL-174869-1.patch | 199 ++++++++++++++++++++++++++++++ glibc-RHEL-174869-2.patch | 246 ++++++++++++++++++++++++++++++++++++++ glibc-RHEL-174869-3.patch | 50 ++++++++ 3 files changed, 495 insertions(+) create mode 100644 glibc-RHEL-174869-1.patch create mode 100644 glibc-RHEL-174869-2.patch create mode 100644 glibc-RHEL-174869-3.patch diff --git a/glibc-RHEL-174869-1.patch b/glibc-RHEL-174869-1.patch new file mode 100644 index 0000000..82eed26 --- /dev/null +++ b/glibc-RHEL-174869-1.patch @@ -0,0 +1,199 @@ +commit f446d90fe6605ac473aaa6cd17a1800e72dcc1a2 +Author: Noah Goldstein +Date: Wed Aug 14 14:37:31 2024 +0800 + + x86: Add `Avoid_STOSB` tunable to allow NT memset without ERMS + + The goal of this flag is to allow targets which don't prefer/have ERMS + to still access the non-temporal memset implementation. + + There are 4 cases for tuning memset: + 1) `Avoid_STOSB && Avoid_Non_Temporal_Memset` + - Memset with temporal stores + 2) `Avoid_STOSB && !Avoid_Non_Temporal_Memset` + - Memset with temporal/non-temporal stores. Non-temporal path + goes through `rep stosb` path. We accomplish this by setting + `x86_rep_stosb_threshold` to + `x86_memset_non_temporal_threshold`. + 3) `!Avoid_STOSB && Avoid_Non_Temporal_Memset` + - Memset with temporal stores/`rep stosb` + 3) `!Avoid_STOSB && !Avoid_Non_Temporal_Memset` + - Memset with temporal stores/`rep stosb`/non-temporal stores. + Reviewed-by: H.J. Lu + +diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c +index f87d6d354924f3d9..e0728cb010aae637 100644 +--- a/sysdeps/x86/cpu-features.c ++++ b/sysdeps/x86/cpu-features.c +@@ -1103,6 +1103,10 @@ disable_tsx: + if (CPU_FEATURES_CPU_P (cpu_features, CMOV)) + cpu_features->preferred[index_arch_I686] |= bit_arch_I686; + ++ /* No ERMS, we want to avoid stosb for memset. */ ++ if (!CPU_FEATURE_USABLE_P (cpu_features, ERMS)) ++ cpu_features->preferred[index_arch_Avoid_STOSB] |= bit_arch_Avoid_STOSB; ++ + #if !HAS_CPUID + no_cpuid: + #endif +diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu-tunables.c +index a0b31d80f64127c5..98da2c54a5c58851 100644 +--- a/sysdeps/x86/cpu-tunables.c ++++ b/sysdeps/x86/cpu-tunables.c +@@ -195,6 +195,8 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) + 11); + CHECK_GLIBC_IFUNC_PREFERRED_BOTH (n, cpu_features, Prefer_FSRM, + 11); ++ CHECK_GLIBC_IFUNC_PREFERRED_BOTH (n, cpu_features, Avoid_STOSB, ++ 11); + CHECK_GLIBC_IFUNC_PREFERRED_NEED_BOTH (n, cpu_features, + Slow_SSE4_2, + SSE4_2, +diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h +index ebfea0a32ce0cff6..e21592e166a041dd 100644 +--- a/sysdeps/x86/dl-cacheinfo.h ++++ b/sysdeps/x86/dl-cacheinfo.h +@@ -1039,18 +1039,42 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + slightly better than ERMS. */ + rep_stosb_threshold = SIZE_MAX; + ++ /* ++ For memset, the non-temporal implementation is only accessed through the ++ stosb code. ie: ++ ``` ++ if (size >= rep_stosb_thresh) ++ { ++ if (size >= non_temporal_thresh) ++ { ++ do_non_temporal (); ++ } ++ do_stosb (); ++ } ++ do_normal_vec_loop (); ++ ``` ++ So if we prefer non-temporal, set `rep_stosb_thresh = non_temporal_thresh` ++ to enable the implementation. If `rep_stosb_thresh = non_temporal_thresh`, ++ `rep stosb` will never be used. ++ */ ++ TUNABLE_SET_WITH_BOUNDS (x86_memset_non_temporal_threshold, ++ memset_non_temporal_threshold, ++ minimum_non_temporal_threshold, SIZE_MAX); ++ /* Do `rep_stosb_thresh = non_temporal_thresh` after setting/getting the ++ final value of `x86_memset_non_temporal_threshold`. In some cases this can ++ be a matter of correctness. */ ++ if (CPU_FEATURES_ARCH_P (cpu_features, Avoid_STOSB)) ++ rep_stosb_threshold ++ = TUNABLE_GET (x86_memset_non_temporal_threshold, long int, NULL); ++ TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1, ++ SIZE_MAX); + TUNABLE_SET_WITH_BOUNDS (x86_data_cache_size, data, 0, SIZE_MAX); + TUNABLE_SET_WITH_BOUNDS (x86_shared_cache_size, shared, 0, SIZE_MAX); + TUNABLE_SET_WITH_BOUNDS (x86_non_temporal_threshold, non_temporal_threshold, + minimum_non_temporal_threshold, + maximum_non_temporal_threshold); +- TUNABLE_SET_WITH_BOUNDS (x86_memset_non_temporal_threshold, +- memset_non_temporal_threshold, +- minimum_non_temporal_threshold, SIZE_MAX); + TUNABLE_SET_WITH_BOUNDS (x86_rep_movsb_threshold, rep_movsb_threshold, + minimum_rep_movsb_threshold, SIZE_MAX); +- TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1, +- SIZE_MAX); + + unsigned long int rep_movsb_stop_threshold; + /* Setting the upper bound of ERMS to the computed value of +diff --git a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def +index 61bbbc2e8983482e..2a58000147d22ddb 100644 +--- a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def ++++ b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def +@@ -34,3 +34,4 @@ BIT (MathVec_Prefer_No_AVX512) + BIT (Prefer_FSRM) + BIT (Avoid_Short_Distance_REP_MOVSB) + BIT (Avoid_Non_Temporal_Memset) ++BIT (Avoid_STOSB) +diff --git a/sysdeps/x86/tst-hwcap-tunables.c b/sysdeps/x86/tst-hwcap-tunables.c +index 94307283d7cdbdc7..1920f5057e69c48a 100644 +--- a/sysdeps/x86/tst-hwcap-tunables.c ++++ b/sysdeps/x86/tst-hwcap-tunables.c +@@ -60,7 +60,8 @@ static const struct test_t + /* Disable everything. */ + "-Prefer_ERMS,-Prefer_FSRM,-AVX,-AVX2,-AVX512F,-AVX512VL," + "-SSE4_1,-SSE4_2,-SSSE3,-Fast_Unaligned_Load,-ERMS," +- "-AVX_Fast_Unaligned_Load,-Avoid_Non_Temporal_Memset", ++ "-AVX_Fast_Unaligned_Load,-Avoid_Non_Temporal_Memset," ++ "-Avoid_STOSB", + test_1, + array_length (test_1) + }, +@@ -68,7 +69,8 @@ static const struct test_t + /* Same as before, but with some empty suboptions. */ + ",-,-Prefer_ERMS,-Prefer_FSRM,-AVX,-AVX2,-AVX512F,-AVX512VL," + "-SSE4_1,-SSE4_2,-SSSE3,-Fast_Unaligned_Load,,-," +- "-ERMS,-AVX_Fast_Unaligned_Load,-Avoid_Non_Temporal_Memset,-,", ++ "-ERMS,-AVX_Fast_Unaligned_Load,-Avoid_Non_Temporal_Memset," ++ "-Avoid_STOSB,-,", + test_1, + array_length (test_1) + } +diff --git a/sysdeps/x86_64/multiarch/ifunc-memset.h b/sysdeps/x86_64/multiarch/ifunc-memset.h +index 7a637ef7ca286694..8dc3d7ab5abaaecb 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-memset.h ++++ b/sysdeps/x86_64/multiarch/ifunc-memset.h +@@ -46,6 +46,13 @@ extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2_unaligned) + extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2_unaligned_erms) + attribute_hidden; + ++static inline int ++prefer_erms_nt_impl (const struct cpu_features *cpu_features) ++{ ++ return CPU_FEATURE_USABLE_P (cpu_features, ERMS) ++ || !CPU_FEATURES_ARCH_P (cpu_features, Avoid_Non_Temporal_Memset); ++} ++ + static inline void * + IFUNC_SELECTOR (void) + { +@@ -61,7 +68,7 @@ IFUNC_SELECTOR (void) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2)) + { +- if (CPU_FEATURE_USABLE_P (cpu_features, ERMS)) ++ if (prefer_erms_nt_impl (cpu_features)) + return OPTIMIZE (avx512_unaligned_erms); + + return OPTIMIZE (avx512_unaligned); +@@ -76,7 +83,7 @@ IFUNC_SELECTOR (void) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2)) + { +- if (CPU_FEATURE_USABLE_P (cpu_features, ERMS)) ++ if (prefer_erms_nt_impl (cpu_features)) + return OPTIMIZE (evex_unaligned_erms); + + return OPTIMIZE (evex_unaligned); +@@ -84,7 +91,7 @@ IFUNC_SELECTOR (void) + + if (CPU_FEATURE_USABLE_P (cpu_features, RTM)) + { +- if (CPU_FEATURE_USABLE_P (cpu_features, ERMS)) ++ if (prefer_erms_nt_impl (cpu_features)) + return OPTIMIZE (avx2_unaligned_erms_rtm); + + return OPTIMIZE (avx2_unaligned_rtm); +@@ -93,14 +100,15 @@ IFUNC_SELECTOR (void) + if (X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, + Prefer_No_VZEROUPPER, !)) + { +- if (CPU_FEATURE_USABLE_P (cpu_features, ERMS)) ++ if (prefer_erms_nt_impl (cpu_features)) + return OPTIMIZE (avx2_unaligned_erms); + + return OPTIMIZE (avx2_unaligned); + } + } + +- if (CPU_FEATURE_USABLE_P (cpu_features, ERMS)) ++ if (CPU_FEATURE_USABLE_P (cpu_features, ERMS) ++ || !CPU_FEATURES_ARCH_P (cpu_features, Avoid_Non_Temporal_Memset)) + return OPTIMIZE (sse2_unaligned_erms); + + return OPTIMIZE (sse2_unaligned); diff --git a/glibc-RHEL-174869-2.patch b/glibc-RHEL-174869-2.patch new file mode 100644 index 0000000..33ebed5 --- /dev/null +++ b/glibc-RHEL-174869-2.patch @@ -0,0 +1,246 @@ +commit cd5fda114ece002945ace3d54a8f80a4f67d1fbb +Author: Sajan Karumanchi +Date: Thu Mar 26 09:21:30 2026 +0000 + + x86_64: Prefer EVEX512 code-path on AMD Zen5 CPUs + + Introduced a synthetic architecture preference flag (Prefer_EVEX512) + and enabled it for AMD Zen5 (CPUID Family 0x1A) when AVX-512 is supported. + + This flag modifies IFUNC dispatch to prefer 512-bit EVEX variants over + 256-bit EVEX variants for string and memory functions on Zen5 processors, + leveraging their native 512-bit execution units for improved throughput. + When Prefer_EVEX512 is set, the dispatcher selects evex512 implementations; + otherwise, it falls back to evex (256-bit) variants. + + The implementation updates the IFUNC selection logic in ifunc-avx2.h and + ifunc-evex.h to check for the Prefer_EVEX512 flag before dispatching to + EVEX512 implementations. This change affects six string/memory functions: + + - strchr + - strlen + - strnlen + - strrchr + - strchrnul + - memchr + + Benchmarks conducted on AMD Zen5 hardware demonstrate significant + performance improvements across all affected functions: + + Function Baseline Patched Avg Avg Avg Max + Variant Variant Baseline Patched Change Improve + (ns) (ns) % % + ------------+----------+----------+-----------+----------+--------+-------- + STRCHR evex evex512 16.408 12.293 25.08% 37.69% + STRLEN evex evex512 16.862 11.436 32.18% 56.74% + STRNLEN evex evex512 18.493 11.762 36.40% 64.40% + STRRCHR evex evex512 15.154 10.874 28.24% 44.38% + STRCHRNUL evex evex512 16.464 12.605 23.44% 45.56% + MEMCHR evex evex512 9.984 8.268 17.19% 39.99% + + Additionally, a tunable option (glibc.cpu.x86_cpu_features.preferred) + is provided to allow runtime control of the Prefer_EVEX512 flag for testing + and compatibility. + + Reviewed-by: Ganesh Gopalasubramanian + Reviewed-by: H.J. Lu + +diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c +index e0728cb010aae637..55c952dded4c1030 100644 +--- a/sysdeps/x86/cpu-features.c ++++ b/sysdeps/x86/cpu-features.c +@@ -1013,6 +1013,12 @@ disable_tsx: + cpu_features->preferred[index_arch_Avoid_Non_Temporal_Memset] + &= ~bit_arch_Avoid_Non_Temporal_Memset; + ++ /* Prefer EVEX512 string/memory variants on AMD Zen5 (Family 0x1A) ++ when AVX-512 is usable. */ ++ if (family == 0x1A && CPU_FEATURE_USABLE_P (cpu_features, AVX512F)) ++ cpu_features->preferred[index_arch_Prefer_EVEX512] ++ |= bit_arch_Prefer_EVEX512; ++ + if (CPU_FEATURE_USABLE_P (cpu_features, AVX)) + { + /* Since the FMA4 bit is in CPUID_INDEX_80000001 and +diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu-tunables.c +index 98da2c54a5c58851..4627748670f6da84 100644 +--- a/sysdeps/x86/cpu-tunables.c ++++ b/sysdeps/x86/cpu-tunables.c +@@ -203,6 +203,12 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) + 11); + } + break; ++ case 14: ++ { ++ CHECK_GLIBC_IFUNC_PREFERRED_NEED_BOTH ++ (n, cpu_features, Prefer_EVEX512, AVX512F, 14); ++ } ++ break; + case 15: + { + CHECK_GLIBC_IFUNC_PREFERRED_BOTH (n, cpu_features, +diff --git a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def +index 2a58000147d22ddb..25e535af62615449 100644 +--- a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def ++++ b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def +@@ -35,3 +35,4 @@ BIT (Prefer_FSRM) + BIT (Avoid_Short_Distance_REP_MOVSB) + BIT (Avoid_Non_Temporal_Memset) + BIT (Avoid_STOSB) ++BIT (Prefer_EVEX512) +diff --git a/sysdeps/x86_64/multiarch/ifunc-avx2.h b/sysdeps/x86_64/multiarch/ifunc-avx2.h +index 4174928dab666878..5566e9760933ad2d 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-avx2.h ++++ b/sysdeps/x86_64/multiarch/ifunc-avx2.h +@@ -1,4 +1,4 @@ +-/* Common definition for ifunc selections optimized with SSE2 and AVX2. ++/* Common definition for ifunc selections optimized with SSE2, AVX2 and EVEX512. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. +@@ -25,6 +25,10 @@ + + extern __typeof (REDIRECT_NAME) OPTIMIZE (evex) attribute_hidden; + ++#ifdef USE_EVEX512 ++extern __typeof (REDIRECT_NAME) OPTIMIZE (evex512) attribute_hidden; ++#endif ++ + extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden; + extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_rtm) attribute_hidden; + +@@ -44,8 +48,13 @@ IFUNC_SELECTOR (void) + { + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)) +- return OPTIMIZE (evex); +- ++ { ++#ifdef USE_EVEX512 ++ if (CPU_FEATURES_ARCH_P (cpu_features, Prefer_EVEX512)) ++ return OPTIMIZE (evex512); ++#endif ++ return OPTIMIZE (evex); ++ } + if (CPU_FEATURE_USABLE_P (cpu_features, RTM)) + return OPTIMIZE (avx2_rtm); + +diff --git a/sysdeps/x86_64/multiarch/ifunc-evex.h b/sysdeps/x86_64/multiarch/ifunc-evex.h +index bbd1e3115f2e3a7c..643817a515b3fd71 100644 +--- a/sysdeps/x86_64/multiarch/ifunc-evex.h ++++ b/sysdeps/x86_64/multiarch/ifunc-evex.h +@@ -1,4 +1,4 @@ +-/* Common definition for ifunc selection optimized with EVEX. ++/* Common definition for ifunc selection optimized with EVEX and EVEX512. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. +@@ -22,6 +22,10 @@ + extern __typeof (REDIRECT_NAME) OPTIMIZE (evex) attribute_hidden; + extern __typeof (REDIRECT_NAME) OPTIMIZE (evex_rtm) attribute_hidden; + ++#ifdef USE_EVEX512 ++extern __typeof (REDIRECT_NAME) OPTIMIZE (evex512) attribute_hidden; ++#endif ++ + extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden; + extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_rtm) attribute_hidden; + +@@ -42,6 +46,11 @@ IFUNC_SELECTOR (void) + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)) + { ++#ifdef USE_EVEX512 ++ if (CPU_FEATURES_ARCH_P (cpu_features, Prefer_EVEX512)) ++ return OPTIMIZE (evex512); ++#endif ++ + if (CPU_FEATURE_USABLE_P (cpu_features, RTM)) + return OPTIMIZE (evex_rtm); + +diff --git a/sysdeps/x86_64/multiarch/memchr.c b/sysdeps/x86_64/multiarch/memchr.c +index 2c7754e759d2f1dd..9f915861a40498d8 100644 +--- a/sysdeps/x86_64/multiarch/memchr.c ++++ b/sysdeps/x86_64/multiarch/memchr.c +@@ -24,6 +24,7 @@ + # undef memchr + + # define SYMBOL_NAME memchr ++# define USE_EVEX512 1 + # include "ifunc-evex.h" + + libc_ifunc_redirected (__redirect_memchr, memchr, IFUNC_SELECTOR ()); +diff --git a/sysdeps/x86_64/multiarch/strchr.c b/sysdeps/x86_64/multiarch/strchr.c +index 4b15d53e97e682db..2d3d084aa8d3bdd1 100644 +--- a/sysdeps/x86_64/multiarch/strchr.c ++++ b/sysdeps/x86_64/multiarch/strchr.c +@@ -27,6 +27,7 @@ + # include + + extern __typeof (REDIRECT_NAME) OPTIMIZE (evex) attribute_hidden; ++extern __typeof (REDIRECT_NAME) OPTIMIZE (evex512) attribute_hidden; + + extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden; + extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_rtm) attribute_hidden; +@@ -46,7 +47,12 @@ IFUNC_SELECTOR (void) + { + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL) + && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)) +- return OPTIMIZE (evex); ++ { ++ if (CPU_FEATURES_ARCH_P (cpu_features, Prefer_EVEX512)) ++ return OPTIMIZE (evex512); ++ ++ return OPTIMIZE (evex); ++ } + + if (CPU_FEATURE_USABLE_P (cpu_features, RTM)) + return OPTIMIZE (avx2_rtm); +diff --git a/sysdeps/x86_64/multiarch/strchrnul.c b/sysdeps/x86_64/multiarch/strchrnul.c +index 663819918e103083..e3fb2503eade9764 100644 +--- a/sysdeps/x86_64/multiarch/strchrnul.c ++++ b/sysdeps/x86_64/multiarch/strchrnul.c +@@ -26,6 +26,7 @@ + # undef strchrnul + + # define SYMBOL_NAME strchrnul ++# define USE_EVEX512 1 + # include "ifunc-avx2.h" + + libc_ifunc_redirected (__redirect_strchrnul, __strchrnul, +diff --git a/sysdeps/x86_64/multiarch/strlen.c b/sysdeps/x86_64/multiarch/strlen.c +index a362c2bf8bce9dcf..9b39da5c760a9fa4 100644 +--- a/sysdeps/x86_64/multiarch/strlen.c ++++ b/sysdeps/x86_64/multiarch/strlen.c +@@ -24,6 +24,7 @@ + # undef strlen + + # define SYMBOL_NAME strlen ++# define USE_EVEX512 1 + # include "ifunc-avx2.h" + + libc_ifunc_redirected (__redirect_strlen, strlen, IFUNC_SELECTOR ()); +diff --git a/sysdeps/x86_64/multiarch/strnlen.c b/sysdeps/x86_64/multiarch/strnlen.c +index d1537e039052551d..a09ff4bea54bb0d1 100644 +--- a/sysdeps/x86_64/multiarch/strnlen.c ++++ b/sysdeps/x86_64/multiarch/strnlen.c +@@ -26,6 +26,7 @@ + # undef strnlen + + # define SYMBOL_NAME strnlen ++# define USE_EVEX512 1 + # include "ifunc-avx2.h" + + libc_ifunc_redirected (__redirect_strnlen, __strnlen, IFUNC_SELECTOR ()); +diff --git a/sysdeps/x86_64/multiarch/strrchr.c b/sysdeps/x86_64/multiarch/strrchr.c +index f14237d1ffeb8e11..2ad1192d3ec013d8 100644 +--- a/sysdeps/x86_64/multiarch/strrchr.c ++++ b/sysdeps/x86_64/multiarch/strrchr.c +@@ -23,6 +23,7 @@ + # undef strrchr + + # define SYMBOL_NAME strrchr ++# define USE_EVEX512 1 + # include "ifunc-avx2.h" + + libc_ifunc_redirected (__redirect_strrchr, strrchr, IFUNC_SELECTOR ()); diff --git a/glibc-RHEL-174869-3.patch b/glibc-RHEL-174869-3.patch new file mode 100644 index 0000000..6350257 --- /dev/null +++ b/glibc-RHEL-174869-3.patch @@ -0,0 +1,50 @@ +commit 54abc8566fea592e795cb443949266ef206462a8 +Author: zombie12138 +Date: Tue May 5 22:38:01 2026 -0700 + + x86: Fix non-temporal memset unreachable on AMD Zen 3/4/5 + + On AMD Zen 3/4/5 with ERMS, the non-temporal memset path is unreachable + because rep_stosb_threshold is set to SIZE_MAX (vectorized loop is faster + than ERMS on these CPUs), but the non-temporal code path is nested inside + the rep_stosb branch. + + The existing rescue logic at the Avoid_STOSB check only covers the case + where the CPU lacks ERMS hardware support. It does not cover AMD Zen 3+ + where ERMS is supported but deliberately unused for performance reasons. + + Extend the condition to also lower rep_stosb_threshold when: + - The user has not explicitly set x86_rep_stosb_threshold (respect tunables) + - rep_stosb_threshold is higher than memset_non_temporal_threshold (NT gated) + + This makes the non-temporal path reachable for large memset operations, + providing ~2x speedup on pre-faulted buffers larger than L3 cache. + + Tested on AMD Ryzen 7 8745HS (Zen 4): + - Pre-faulted 64MB memset: 2.02 ms -> 0.94 ms (2.15x faster) + - First-touch 64MB memset: 19.3 ms -> 21.3 ms (11% regression, expected: + kernel clear_page cache warming bypassed by NT stores) + + * sysdeps/x86/dl-cacheinfo.h (dl_init_cacheinfo): Extend + rep_stosb_threshold lowering condition to cover AMD Zen 3/4/5 + where ERMS is supported but stosb is disabled via threshold. + + Signed-off-by: zombie12138 + Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34129 + Reviewed-by: Adhemerval Zanella + +diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h +index e21592e166a041dd..f3477a1c5e190dc9 100644 +--- a/sysdeps/x86/dl-cacheinfo.h ++++ b/sysdeps/x86/dl-cacheinfo.h +@@ -1063,7 +1063,9 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + /* Do `rep_stosb_thresh = non_temporal_thresh` after setting/getting the + final value of `x86_memset_non_temporal_threshold`. In some cases this can + be a matter of correctness. */ +- if (CPU_FEATURES_ARCH_P (cpu_features, Avoid_STOSB)) ++ if (CPU_FEATURES_ARCH_P (cpu_features, Avoid_STOSB) ++ || (!TUNABLE_IS_INITIALIZED (x86_rep_stosb_threshold) ++ && rep_stosb_threshold > memset_non_temporal_threshold)) + rep_stosb_threshold + = TUNABLE_GET (x86_memset_non_temporal_threshold, long int, NULL); + TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1,