diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2020-02-08 18:22:56 +0100 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2020-02-08 18:22:56 +0100 |
commit | d3c5f0d519f8fb374942907acfcb0af8fe1295d8 (patch) | |
tree | 4dff2640b19a1da477789b6f2ad4156430cf1ecb | |
parent | a4823c6d60de3c7cecc92a9c8a18ef3f353d85a2 (diff) |
New upstream release:
* New upstream release:
- Adds GNU hash support on MIPS (closes: #943538).
- debian/symbols.wildcard: add 2.31.
- debian/debhelper.in/libc-dev{,-alt}.install: drop libmvec_nonshared.a.
- debian/patches/localedata/locales/ku_TR: rebased.
- debian/patches/localedata/fo_FO-date_fmt.diff: rebased.
- debian/patches/localedata/locales-fr.diff: rebased.
- debian/patches/localedata/locale-zh_TW.diff: rebased.
- debian/patches/localedata/submitted-bz9725-locale-sv_SE.diff:
upstreamed.
- debian/patches/localedata/submitted-en_AU-date_fmt.diff: upstreamed.
- debian/patches/alpha/local-string-functions.diff: rebased.
- debian/patches/hurd-i386/git-ONSTACK.diff: upstreamed.
- debian/patches/hurd-i386/git-getrandom.diff: upstreamed.
- debian/patches/hurd-i386/git-altstack-RPC.diff: upstreamed.
- debian/patches/hurd-i386/local-enable-ldconfig.diff: rebased.
- debian/patches/hurd-i386/git-context_functions.diff: upstreamed.
- debian/patches/hurd-i386/tg-thread-cancel.diff: rebased.
- debian/patches/hurd-i386/git-sendmsg-SCM_RIGHTS.diff: upstreamed.
- debian/patches/hurd-i386/git-hurdsig-fixes.diff: upstreamed.
- debian/patches/hurd-i386/git-hurdsig-global-dispositions.diff:
upstreamed.
- debian/patches/hurd-i386/git-hurdsig-globaldisp-version.diff: upstreamed.
- debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff: rebased.
- debian/patches/hurd-i386/git-hurdsig-fixes-2.diff: upstreamed.
- debian/patches/hurd-i386/git-hurdsig-boot-fix.diff: upstreamed.
- debian/patches/hurd-i386/git-single-select-timeout.diff: upstreamed.
- debian/patches/hurd-i386/git-setitimer.diff: upstreamed.
- debian/patches/hurd-i386/git-remap_getcwd.diff: upstreamed.
- debian/patches/hurd-i386/git-io_select_timeout.diff: upstreamed.
- debian/patches/hurd-i386/git-poll_errors_fixes.diff: upstreamed.
- debian/patches/hurd-i386/local-mach_print.diff: rebased.
- debian/patches/hurd-i386/local-exec_filename.diff: rebased.
- debian/patches/hurd-i386/git-libpthread_sigs.diff: upstreamed.
- debian/patches/hurd-i386/git-hurd_sigstate-PLT.diff: upstreamed.
- debian/patches/hurd-i386/git-rlock.diff: upstreamed.
- debian/patches/hurd-i386/git-errno_location.diff: upstreamed.
- debian/patches/powerpc/local-powerpc8xx-dcbz.diff: rebased.
- debian/patches/sh4/local-fpscr_values.diff: rebased.
- debian/patches/any/local-ldconfig.diff: upstreamed.
- debian/patches/any/submitted-bits-fcntl_h-at.diff: rebased.
- debian/patches/any/unsubmitted-dlopen-static-crash.diff: obsolete.
- debian/patches/any/local-test-install.diff: rebased.
44 files changed, 159 insertions, 8150 deletions
diff --git a/debian/changelog b/debian/changelog index 3fc31178..e6b00411 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,52 @@ +glibc (2.31-0experimental0) UNRELEASED; urgency=medium + + [ Aurelien Jarno ] + * New upstream release: + - Adds GNU hash support on MIPS (closes: #943538). + - debian/symbols.wildcard: add 2.31. + - debian/debhelper.in/libc-dev{,-alt}.install: drop libmvec_nonshared.a. + - debian/patches/localedata/locales/ku_TR: rebased. + - debian/patches/localedata/fo_FO-date_fmt.diff: rebased. + - debian/patches/localedata/locales-fr.diff: rebased. + - debian/patches/localedata/locale-zh_TW.diff: rebased. + - debian/patches/localedata/submitted-bz9725-locale-sv_SE.diff: + upstreamed. + - debian/patches/localedata/submitted-en_AU-date_fmt.diff: upstreamed. + - debian/patches/alpha/local-string-functions.diff: rebased. + - debian/patches/hurd-i386/git-ONSTACK.diff: upstreamed. + - debian/patches/hurd-i386/git-getrandom.diff: upstreamed. + - debian/patches/hurd-i386/git-altstack-RPC.diff: upstreamed. + - debian/patches/hurd-i386/local-enable-ldconfig.diff: rebased. + - debian/patches/hurd-i386/git-context_functions.diff: upstreamed. + - debian/patches/hurd-i386/tg-thread-cancel.diff: rebased. + - debian/patches/hurd-i386/git-sendmsg-SCM_RIGHTS.diff: upstreamed. + - debian/patches/hurd-i386/git-hurdsig-fixes.diff: upstreamed. + - debian/patches/hurd-i386/git-hurdsig-global-dispositions.diff: + upstreamed. + - debian/patches/hurd-i386/git-hurdsig-globaldisp-version.diff: upstreamed. + - debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff: rebased. + - debian/patches/hurd-i386/git-hurdsig-fixes-2.diff: upstreamed. + - debian/patches/hurd-i386/git-hurdsig-boot-fix.diff: upstreamed. + - debian/patches/hurd-i386/git-single-select-timeout.diff: upstreamed. + - debian/patches/hurd-i386/git-setitimer.diff: upstreamed. + - debian/patches/hurd-i386/git-remap_getcwd.diff: upstreamed. + - debian/patches/hurd-i386/git-io_select_timeout.diff: upstreamed. + - debian/patches/hurd-i386/git-poll_errors_fixes.diff: upstreamed. + - debian/patches/hurd-i386/local-mach_print.diff: rebased. + - debian/patches/hurd-i386/local-exec_filename.diff: rebased. + - debian/patches/hurd-i386/git-libpthread_sigs.diff: upstreamed. + - debian/patches/hurd-i386/git-hurd_sigstate-PLT.diff: upstreamed. + - debian/patches/hurd-i386/git-rlock.diff: upstreamed. + - debian/patches/hurd-i386/git-errno_location.diff: upstreamed. + - debian/patches/powerpc/local-powerpc8xx-dcbz.diff: rebased. + - debian/patches/sh4/local-fpscr_values.diff: rebased. + - debian/patches/any/local-ldconfig.diff: upstreamed. + - debian/patches/any/submitted-bits-fcntl_h-at.diff: rebased. + - debian/patches/any/unsubmitted-dlopen-static-crash.diff: obsolete. + - debian/patches/any/local-test-install.diff: rebased. + + -- Aurelien Jarno <aurel32@debian.org> Sat, 08 Feb 2020 13:52:09 +0100 + glibc (2.30-0experimental3) UNRELEASED; urgency=medium [ Samuel Thibault ] diff --git a/debian/control b/debian/control index 4d65cb1d..040b8584 100644 --- a/debian/control +++ b/debian/control @@ -13,7 +13,7 @@ Build-Depends: gettext, dpkg (>= 1.18.7), dpkg-dev (>= 1.17.14), xz-utils, file, g++-9, g++-9-multilib [amd64 i386 kfreebsd-amd64 mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el powerpc ppc64 s390x sparc sparc64 x32] <!nobiarch>, python3:native, libidn2-0 (>= 2.0.5~) <!nocheck>, - libc-bin (>= 2.30) <cross> + libc-bin (>= 2.31) <cross> Build-Depends-Indep: perl, po-debconf (>= 1.0) Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org> Uploaders: Clint Adams <clint@debian.org>, Aurelien Jarno <aurel32@debian.org>, Adam Conrad <adconrad@0c3.net>, Samuel Thibault <sthibault@debian.org> @@ -99,7 +99,7 @@ Package: locales Architecture: all Section: localization Priority: standard -Depends: libc-bin (>> 2.30), libc-l10n (>> 2.30), ${misc:Depends}, debconf | debconf-2.0 +Depends: libc-bin (>> 2.31), libc-l10n (>> 2.31), ${misc:Depends}, debconf | debconf-2.0 Replaces: manpages-fr-extra (<< 20141022) Build-Profiles: <!stage1> Description: GNU C Library: National Language (locale) data [support] @@ -117,7 +117,7 @@ Architecture: any Section: localization Priority: optional Multi-Arch: foreign -Depends: libc-l10n (>> 2.30), ${misc:Depends} +Depends: libc-l10n (>> 2.31), ${misc:Depends} Breaks: locales (<< 2.13-17) Build-Profiles: <!stage1> Description: GNU C Library: Precompiled locale data @@ -149,7 +149,7 @@ Recommends: libidn2-0 (>= 2.0.5~) Suggests: glibc-doc, debconf | debconf-2.0, libc-l10n, locales [!hurd-i386] Provides: libc6-sparcv9b [sparc sparc64], libc0.1-i686 [kfreebsd-i386], libc0.3-i686 [hurd-i386], libc6-i686 [i386] Conflicts: libc6-loongson2f [mipsel], libc0.1-i686 [kfreebsd-i386], libc6-i686 [i386], openrc (<< 0.27-2~) -Breaks: nscd (<< 2.30), locales (<< 2.30), locales-all (<< 2.30), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) +Breaks: nscd (<< 2.31), locales (<< 2.31), locales-all (<< 2.31), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) Replaces: libc6-amd64 [amd64], libc6-i386 [i386], libc0.1-i686 [kfreebsd-i386], @@ -239,7 +239,7 @@ Recommends: libidn2-0 (>= 2.0.5~) Suggests: glibc-doc, debconf | debconf-2.0, libc-l10n, locales [!hurd-i386] Provides: libc6-sparcv9b [sparc sparc64], libc0.1-i686 [kfreebsd-i386], libc0.3-i686 [hurd-i386], libc6-i686 [i386] Conflicts: libc6-loongson2f [mipsel], libc0.1-i686 [kfreebsd-i386], libc6-i686 [i386], openrc (<< 0.27-2~) -Breaks: nscd (<< 2.30), locales (<< 2.30), locales-all (<< 2.30), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) +Breaks: nscd (<< 2.31), locales (<< 2.31), locales-all (<< 2.31), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) Replaces: libc6-amd64 [amd64], libc6-i386 [i386], libc0.1-i686 [kfreebsd-i386], @@ -329,7 +329,7 @@ Recommends: libidn2-0 (>= 2.0.5~) Suggests: glibc-doc, debconf | debconf-2.0, libc-l10n, locales [!hurd-i386] Provides: libc6-sparcv9b [sparc sparc64], libc0.1-i686 [kfreebsd-i386], libc0.3-i686 [hurd-i386], libc6-i686 [i386] Conflicts: libc6-loongson2f [mipsel], libc0.1-i686 [kfreebsd-i386], libc6-i686 [i386], openrc (<< 0.27-2~) -Breaks: nscd (<< 2.30), locales (<< 2.30), locales-all (<< 2.30), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) +Breaks: nscd (<< 2.31), locales (<< 2.31), locales-all (<< 2.31), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) Replaces: libc6-amd64 [amd64], libc6-i386 [i386], libc0.1-i686 [kfreebsd-i386], @@ -419,7 +419,7 @@ Recommends: libidn2-0 (>= 2.0.5~) Suggests: glibc-doc, debconf | debconf-2.0, libc-l10n, locales [!hurd-i386] Provides: libc6-sparcv9b [sparc sparc64], libc0.1-i686 [kfreebsd-i386], libc0.3-i686 [hurd-i386], libc6-i686 [i386] Conflicts: libc6-loongson2f [mipsel], libc0.1-i686 [kfreebsd-i386], libc6-i686 [i386], openrc (<< 0.27-2~) -Breaks: nscd (<< 2.30), locales (<< 2.30), locales-all (<< 2.30), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) +Breaks: nscd (<< 2.31), locales (<< 2.31), locales-all (<< 2.31), hurd (<< 1:0.9.git20170910-1), libtirpc1 (<< 0.2.3), r-cran-later (<< 0.7.5+dfsg-2), nocache (<< 1.1-1~), iraf-fitsutil (<< 2018.07.06-4), wcc (<< 0.0.2+dfsg-3) Replaces: libc6-amd64 [amd64], libc6-i386 [i386], libc0.1-i686 [kfreebsd-i386], diff --git a/debian/debhelper.in/libc-dev-alt.install b/debian/debhelper.in/libc-dev-alt.install index d4ee0de9..d26e3cd3 100644 --- a/debian/debhelper.in/libc-dev-alt.install +++ b/debian/debhelper.in/libc-dev-alt.install @@ -10,7 +10,6 @@ TMPDIR/LIBDIR/libm.a LIBDIR TMPDIR/LIBDIR/libm-*.a LIBDIR TMPDIR/LIBDIR/libmcheck.a LIBDIR TMPDIR/LIBDIR/libmvec.a LIBDIR -TMPDIR/LIBDIR/libmvec_nonshared.a LIBDIR TMPDIR/LIBDIR/libnsl.a LIBDIR TMPDIR/LIBDIR/libpthread.a LIBDIR TMPDIR/LIBDIR/libresolv.a LIBDIR diff --git a/debian/debhelper.in/libc-dev.install b/debian/debhelper.in/libc-dev.install index 0e33b243..fcd6a364 100644 --- a/debian/debhelper.in/libc-dev.install +++ b/debian/debhelper.in/libc-dev.install @@ -9,7 +9,6 @@ TMPDIR/LIBDIR/libm.a LIBDIR TMPDIR/LIBDIR/libm-*.a LIBDIR TMPDIR/LIBDIR/libmcheck.a LIBDIR TMPDIR/LIBDIR/libmvec.a LIBDIR -TMPDIR/LIBDIR/libmvec_nonshared.a LIBDIR TMPDIR/LIBDIR/libnsl.a LIBDIR TMPDIR/LIBDIR/libpthread.a LIBDIR TMPDIR/LIBDIR/libresolv.a LIBDIR diff --git a/debian/patches/alpha/local-string-functions.diff b/debian/patches/alpha/local-string-functions.diff index df74fad8..9d12e68a 100644 --- a/debian/patches/alpha/local-string-functions.diff +++ b/debian/patches/alpha/local-string-functions.diff @@ -15,7 +15,7 @@ This patch removes them. --- a/sysdeps/alpha/strncat.S +++ /dev/null @@ -1,94 +0,0 @@ --/* Copyright (C) 1996-2019 Free Software Foundation, Inc. +-/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Richard Henderson <rth@tamu.edu>, 1996. - @@ -31,7 +31,7 @@ This patch removes them. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see -- <http://www.gnu.org/licenses/>. */ +- <https://www.gnu.org/licenses/>. */ - -/* Append no more than COUNT characters from the null-terminated string SRC - to the null-terminated string DST. Always null-terminate the new DST. */ @@ -112,7 +112,7 @@ This patch removes them. --- a/sysdeps/alpha/strncpy.S +++ /dev/null @@ -1,87 +0,0 @@ --/* Copyright (C) 1996-2019 Free Software Foundation, Inc. +-/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - Contributed by Richard Henderson (rth@tamu.edu) - This file is part of the GNU C Library. - @@ -128,7 +128,7 @@ This patch removes them. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see -- <http://www.gnu.org/licenses/>. */ +- <https://www.gnu.org/licenses/>. */ - -/* Copy no more than COUNT bytes of the null-terminated string from - SRC to DST. If SRC does not cover all of COUNT, the balance is @@ -202,7 +202,7 @@ This patch removes them. --- a/sysdeps/alpha/alphaev67/strncat.S +++ /dev/null @@ -1,87 +0,0 @@ --/* Copyright (C) 2000-2019 Free Software Foundation, Inc. +-/* Copyright (C) 2000-2020 Free Software Foundation, Inc. - Contributed by Richard Henderson <rth@tamu.edu>, 1996. - EV67 optimized by Rick Gorton <rick.gorton@alpha-processor.com>. - This file is part of the GNU C Library. @@ -219,7 +219,7 @@ This patch removes them. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see -- <http://www.gnu.org/licenses/>. */ +- <https://www.gnu.org/licenses/>. */ - -/* Append no more than COUNT characters from the null-terminated string SRC - to the null-terminated string DST. Always null-terminate the new DST. */ @@ -292,7 +292,7 @@ This patch removes them. --- a/sysdeps/alpha/stpncpy.S +++ /dev/null @@ -1,106 +0,0 @@ --/* Copyright (C) 1996-2019 Free Software Foundation, Inc. +-/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Richard Henderson (rth@tamu.edu) - @@ -308,7 +308,7 @@ This patch removes them. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see -- <http://www.gnu.org/licenses/>. */ +- <https://www.gnu.org/licenses/>. */ - -/* Copy no more than COUNT bytes of the null-terminated string from - SRC to DST. If SRC does not cover all of COUNT, the balance is @@ -401,7 +401,7 @@ This patch removes them. --- a/sysdeps/alpha/alphaev67/stpncpy.S +++ /dev/null @@ -1,115 +0,0 @@ --/* Copyright (C) 2000-2019 Free Software Foundation, Inc. +-/* Copyright (C) 2000-2020 Free Software Foundation, Inc. - Contributed by Richard Henderson (rth@redhat.com) - This file is part of the GNU C Library. - @@ -417,7 +417,7 @@ This patch removes them. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see -- <http://www.gnu.org/licenses/>. */ +- <https://www.gnu.org/licenses/>. */ - -/* Copy no more than N bytes from SRC to DEST, returning the address of - the terminating '\0' in DEST. */ @@ -519,7 +519,7 @@ This patch removes them. --- a/sysdeps/alpha/strcmp.S +++ /dev/null @@ -1,194 +0,0 @@ --/* Copyright (C) 1996-2019 Free Software Foundation, Inc. +-/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - Contributed by Richard Henderson (rth@tamu.edu) - This file is part of the GNU C Library. - @@ -535,7 +535,7 @@ This patch removes them. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see -- <http://www.gnu.org/licenses/>. */ +- <https://www.gnu.org/licenses/>. */ - -/* Bytewise compare two null-terminated strings. */ - @@ -716,7 +716,7 @@ This patch removes them. --- a/sysdeps/alpha/strncmp.S +++ /dev/null @@ -1,277 +0,0 @@ --/* Copyright (C) 1996-2019 Free Software Foundation, Inc. +-/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - Contributed by Richard Henderson (rth@tamu.edu) - This file is part of the GNU C Library. - @@ -732,7 +732,7 @@ This patch removes them. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see -- <http://www.gnu.org/licenses/>. */ +- <https://www.gnu.org/licenses/>. */ - -/* Bytewise compare two null-terminated strings of length no longer than N. */ - diff --git a/debian/patches/any/local-ldconfig.diff b/debian/patches/any/local-ldconfig.diff deleted file mode 100644 index d812ee95..00000000 --- a/debian/patches/any/local-ldconfig.diff +++ /dev/null @@ -1,73 +0,0 @@ -# DP: Make it so that a missing /etc/ld.so.conf does not cause an error -# DP: message, unless --verbose is enabled. This keeps the debian -# DP: installer from barfing during bootstrap of the system. -# DP: -# DP: Updated by gotom, the previous one seems being wrong because it suppresses -# DP: _all_ warnings about "can't open configuration file". otoh, I introduce -# DP: newer patches. it should be checked using chroot and should be contacted -# DP: to the upstream. -# DP: Date: (Updated 2005-01-02 gotom) - -# previous patch. -#--- elf/ldconfig.c 2003-07-08 23:26:27.000000000 +0900 -#+++ elf/ldconfig.c.debian 2003-07-08 23:29:43.000000000 +0900 -#@@ -920,26 +920,24 @@ -# { -# FILE *file = NULL; -# char *line = NULL; -#- const char *canon; -#+ const char *canon = filename; -# size_t len = 0; -#+ int file_fd; -# -# if (opt_chroot) -# { -# canon = chroot_canon (opt_chroot, filename); -#- if (canon) -#- file = fopen (canon, "r"); -#- else -#+ if (!canon) -# canon = filename; -# } -#- else -#- { -#- canon = filename; -#- file = fopen (filename, "r"); -#- } -#+ -#+ if ((file_fd = open(canon, O_RDONLY | O_EXCL, 0022)) != -1) -#+ file = fdopen (file_fd, "r"); -# -# if (file == NULL) -# { -#- error (0, errno, _("Can't open configuration file %s"), canon); -#+ if (opt_verbose) -#+ error (0, errno, _("Can't open configuration file %s"), canon); -# if (canon != filename) -# free ((char *) canon); -# return; - -2004-10-25 GOTO Masanori <gotom@debian.or.jp> - - * elf/ldconfig.c: Don't print error when default ld.so.conf - is not existed. - ---- - elf/ldconfig.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - ---- a/elf/ldconfig.c -+++ b/elf/ldconfig.c -@@ -1064,9 +1064,10 @@ - - if (file == NULL) - { -- error (0, errno, _("\ -+ if (strcmp(canon, LD_SO_CONF) != 0 || opt_verbose) -+ error (0, errno, _("\ - Warning: ignoring configuration file that cannot be opened: %s"), -- canon); -+ canon); - if (canon != filename) - free ((char *) canon); - return; diff --git a/debian/patches/any/local-test-install.diff b/debian/patches/any/local-test-install.diff index a91d5535..dbb0e6e3 100644 --- a/debian/patches/any/local-test-install.diff +++ b/debian/patches/any/local-test-install.diff @@ -1,16 +1,16 @@ Description: Use install_root for test destination override, not DESTDIR Author: Adam Conrad <adconrad@ubuntu.com> Forwarded: no -Last-Update: 2019-09-16 +Last-Update: 2020-02-08 --- glibc-2.30.orig/Makefile +++ glibc-2.30/Makefile -@@ -418,7 +418,7 @@ ifeq ($(run-built-tests),yes) - $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\ - done - endif +@@ -618,7 +618,7 @@ endif + # Setting INSTALL_UNCOMPRESSED causes localedata/Makefile to + # install the charmaps uncompressed, as the testroot does not + # provide a gunzip program. - $(MAKE) install DESTDIR=$(objpfx)testroot.pristine \ + $(MAKE) install install_root=$(objpfx)testroot.pristine \ - subdirs='$(sorted-subdirs)' + INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)' + rm -f $(symbolic-link-list) touch $(objpfx)testroot.pristine/install.stamp - diff --git a/debian/patches/any/submitted-bits-fcntl_h-at.diff b/debian/patches/any/submitted-bits-fcntl_h-at.diff index 16998898..d09ad971 100644 --- a/debian/patches/any/submitted-bits-fcntl_h-at.diff +++ b/debian/patches/any/submitted-bits-fcntl_h-at.diff @@ -28,14 +28,14 @@ constants. --- - io/fcntl.h | 27 --------------------------- - sysdeps/mach/hurd/bits/fcntl.h | 22 ++++++++++++++++++++++ - sysdeps/unix/sysv/linux/bits/fcntl-linux.h | 22 ++++++++++++++++++++++ - 3 files changed, 44 insertions(+), 27 deletions(-) + io/fcntl.h | 28 ---------------------------- + sysdeps/mach/hurd/bits/fcntl.h | 23 +++++++++++++++++++++++ + sysdeps/unix/sysv/linux/bits/fcntl-linux.h | 23 +++++++++++++++++++++++ + 3 files changed, 46 insertions(+), 28 deletions(-) --- a/io/fcntl.h +++ b/io/fcntl.h -@@ -139,33 +139,6 @@ +@@ -139,34 +139,6 @@ # define SEEK_END 2 /* Seek from end of file. */ #endif /* XPG */ @@ -61,6 +61,7 @@ -# define AT_STATX_SYNC_AS_STAT 0x0000 -# define AT_STATX_FORCE_SYNC 0x2000 -# define AT_STATX_DONT_SYNC 0x4000 +-# define AT_RECURSIVE 0x8000 /* Apply to the entire subtree. */ -# endif -# define AT_EACCESS 0x200 /* Test access permitted for - effective IDs, not real IDs. */ @@ -71,7 +72,7 @@ --- a/sysdeps/mach/hurd/bits/fcntl.h +++ b/sysdeps/mach/hurd/bits/fcntl.h -@@ -219,3 +219,25 @@ +@@ -228,3 +228,26 @@ # define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */ # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif @@ -93,13 +94,14 @@ +# define AT_STATX_SYNC_AS_STAT 0x0000 +# define AT_STATX_FORCE_SYNC 0x2000 +# define AT_STATX_DONT_SYNC 0x4000 ++# define AT_RECURSIVE 0x8000 /* Apply to the entire subtree. */ +# endif +# define AT_EACCESS 0x200 /* Test access permitted for + effective IDs, not real IDs. */ +#endif --- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h +++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h -@@ -359,6 +359,28 @@ +@@ -366,6 +366,29 @@ # define MAX_HANDLE_SZ 128 #endif @@ -120,6 +122,7 @@ +# define AT_STATX_SYNC_AS_STAT 0x0000 +# define AT_STATX_FORCE_SYNC 0x2000 +# define AT_STATX_DONT_SYNC 0x4000 ++# define AT_RECURSIVE 0x8000 /* Apply to the entire subtree. */ +# endif +# define AT_EACCESS 0x200 /* Test access permitted for + effective IDs, not real IDs. */ diff --git a/debian/patches/any/unsubmitted-dlopen-static-crash.diff b/debian/patches/any/unsubmitted-dlopen-static-crash.diff deleted file mode 100644 index 71b56b48..00000000 --- a/debian/patches/any/unsubmitted-dlopen-static-crash.diff +++ /dev/null @@ -1,33 +0,0 @@ -Description: Fix dlopen segfault in statically linked programs -Author: Maciej Rozycki -Origin: http://www.eglibc.org/archives/issues/msg00084.html -Last-Update: 2013-10-09 - -Index: b/elf/dl-open.c -=================================================================== ---- a/elf/dl-open.c -+++ b/elf/dl-open.c -@@ -92,11 +92,22 @@ - anymore. Instead the malloc() implementation of the libc is - used. But this means the block from the main map cannot be used - in an realloc() call. Therefore we allocate a completely new -- array the first time we have to add something to the locale scope. */ -+ array the first time we have to add something to the locale scope. -+ -+ Also the list may be missing altogether if we are called via -+ dlopen() from a statically linked executable as in this case ld.so -+ has not been called and no dynamic symbols have been pulled yet. -+ Start a new list in this case. */ - - struct link_namespaces *ns = &GL(dl_ns)[new->l_ns]; - if (ns->_ns_global_scope_alloc == 0) - { -+ /* See if we've got a list at all. */ -+ if (ns->_ns_main_searchlist == NULL) -+ ns->_ns_main_searchlist = calloc (1, sizeof (struct r_scope_elem)); -+ if (ns->_ns_main_searchlist == NULL) -+ goto nomem; -+ - /* This is the first dynamic object given global scope. */ - ns->_ns_global_scope_alloc - = ns->_ns_main_searchlist->r_nlist + to_add + 8; diff --git a/debian/patches/git-updates.diff b/debian/patches/git-updates.diff index 6b663310..f9395175 100644 --- a/debian/patches/git-updates.diff +++ b/debian/patches/git-updates.diff @@ -1,3681 +1,2 @@ -GIT update of https://sourceware.org/git/glibc.git/release/2.30/master from glibc-2.30 +GIT update of https://sourceware.org/git/glibc.git/release/2.31/master from glibc-2.31 -diff --git a/ChangeLog b/ChangeLog -index cdb9e14881..bc2f4aae69 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,214 @@ -+2019-08-15 Florian Weimer <fweimer@redhat.com> -+ -+ [BZ #24899] -+ * sysdeps/gnu/bits/utmpx.h (struct utmpx): Add -+ __attribute_nonstring__ to ut_line, ut_id, ut_user, ut_host. -+ * sysdeps/unix/sysv/linux/s390/bits/utmpx.h (struct utmpx): -+ Likewise. -+ * sysdeps/gnu/bits/utmp.h (struct utmp): Add -+ __attribute_nonstring__ to ut_id. -+ * sysdeps/unix/sysv/linux/s390/bits/utmpx.h (struct utmp): -+ Likewise. -+ -+2019-08-28 Florian Weimer <fweimer@redhat.com> -+ -+ [BZ #24902] -+ * login/Makefile (tests): Add tst-pututxline-lockfail. -+ (tst-pututxline-lockfail): Link with -lpthread. -+ * login/utmp_file.c (internal_getut_r): Remove buffer argument. -+ (__libc_getutid_r): Adjust. -+ (__libc_pututline): Likewise. Check for file_offset == -1. -+ * login/tst-pututxline-lockfail.c: New file. -+ -+2019-08-15 Florian Weimer <fweimer@redhat.com> -+ -+ [BZ #24880] -+ * login/utmp_file.c (file_locking_failed): Use struct flock64. -+ (file_locking_unlock): Likewise. -+ -+2019-08-15 Florian Weimer <fweimer@redhat.com> -+ -+ [BZ #24879] -+ login: Disarm timer after utmp lock acquisition. -+ * login/utmp_file.c (struct file_locking): Remove. -+ (try_file_lock): Adjust. -+ (file_lock_restore): Remove function. -+ (__libc_getutent_r): . -+ (internal_getut_r): Likewise. -+ (__libc_getutline_r): Likewise. -+ (__libc_pututline): Likewise. -+ (__libc_updwtmp): Likewise. -+ -+2019-08-15 Florian Weimer <fweimer@redhat.com> -+ -+ * login/utmp_file.c (__libc_updwtmp): Unlock the right file -+ descriptor. -+ * login/Makefile (tests): Add tst-updwtmpx. -+ * login/tst-updwtmpx.c: New file. -+ -+2019-08-13 Florian Weimer <fweimer@redhat.com> -+ -+ * login/utmp_file.c (LOCK_FILE, LOCKING_FAILED, UNLOCK_FILE): -+ Remove macros. -+ (struct file_locking): New. -+ (try_file_lock, file_unlock, file_lock_restore): New functions. -+ (__libc_getutent_r): Use the new functions. -+ (internal_getut_r): Likewise. -+ (__libc_getutline_r): Likewise. -+ (__libc_pututline): Likewise. -+ (__libc_updwtmp): Likewise. -+ -+2019-08-13 Florian Weimer <fweimer@redhat.com> -+ -+ * login/getutid_r.c (__getutid_r): _HAVE_UT_ID and _HAVE_UT_TYPE -+ are always true. -+ * login/getutmp.c (getutmp): _HAVE_UT_TYPE, _HAVE_UT_PID, -+ _HAVE_UT_ID, _HAVE_UT_HOST, _HAVE_UT_TV are always true. -+ * login/getutmpx.c (getutmpx): Likewise. -+ * login/login.c (login): _HAVE_UT_TYPE, _HAVE_UT_PID are always -+ true. -+ * login/logout.c (logout): _HAVE_UT_TYPE, _HAVE_UT_HOST, -+ _HAVE_UT_TV are always true. -+ * login/logwtmp.c (logwtmp): _HAVE_UT_PID, _HAVE_UT_TYPE, -+ _HAVE_UT_HOST, _HAVE_UT_TV are always true. -+ * login/tst-utmp.c: _HAVE_UT_TYPE, _HAVE_UT_TV are always true. -+ * login/utmp_file.c (__libc_setutent): _HAVE_UT_TYPE, _HAVE_UT_ID -+ are always true. -+ (internal_getut_r): _HAVE_UT_TYPE is always true. -+ (__libc_pututline): Likewise. -+ * login/programs/utmpdump.c (print_entry): Assume that -+ _HAVE_UT_TYPE, _HAVE_UT_PID, _HAVE_UT_ID, _HAVE_UT_HOST, -+ _HAVE_UT_TV are always true. -+ * sysdeps/generic/utmp-equal.h (__utmp_equal): _HAVE_UT_TYPE, -+ _HAVE_UT_ID are always true. -+ * sysdeps/gnu/bits/utmp.h: Move to ... -+ * bits/utmp.h: ... here, replacing the old file. -+ -+2019-08-05 Florian Weimer <fweimer@redhat.com> -+ -+ [BZ #23518] -+ * login/uptmp-private.h (struct ufuncs): Remove definition. -+ (__libc_utmp_file_functions, __libc_utmp_unknown_functions) -+ (__libc_utmp_jump_table): Remove declarations. -+ (__libc_setutent, __libc_getutent_r, __libc_getutid_r) -+ (__libc_getutline_r, __libc_pututline, __libc_endutent) -+ (__libc_updwtmp): Declare. -+ * login/getutent_r.c (__libc_utmp_unknown_functions) -+ (__libc_utmp_jump_table, setutent_unknown, getutent_r_unknown) -+ (getutid_r_unknown, getutline_r_unknown, pututline_unknown) -+ (endutent_unknown): Remove definitions. -+ (__setutent): Call __libc_setutent. -+ (__getutent_r): Call __libc_getutent_r. -+ (__pututline): Call __libc_pututline. -+ (__endutent): Call __libc_endutent. -+ * login/getutid_r.c (__getutid_r): Call __libc_getutid_r. -+ * login/getutline_r.c (__getutline_r): Call __libc_getutline_r. -+ * login/updwtmp.c (__updwtmp): Call __libc_updwtmp. -+ * login/utmp_file.c (__libc_utmp_file_functions): Remove definition -+ (__libc_setutent): Rename from stetutent_file. Drop static. -+ (maybe_setutent): New function. -+ (__libc_getutent_r): Rename from getutent_r_file. Drop static. -+ Check for initialization. -+ (__libc_getutid_r): Rename from getutid_r_file. Drop static. -+ Check for initialization. -+ (__libc_getutline_r): Rename from getutline_r_file. Drop static. -+ Check for initialization. -+ (__libc_pututline): Rename from pututline_file. Drop static. -+ Check for initialization. -+ (__libc_endutent): Rename from endutent_file. Drop static. Check -+ for initialization. -+ (__libc_updwtmp): Rename from updwtmp_file. Drop static. -+ * login/utmpname.c (__utmpname): Call __libc_endutent. -+ * sysdeps/unix/getlogin_r (__getlogin_r): Call __libc_setutent, -+ __libc_getutlien_r, __libc_endutent. -+ * manual/users.texi (Who Logged In, Manipulating the Database): -+ Adjust. -+ -+2019-08-15 Florian Weimer <fweimer@redhat.com> -+ -+ * malloc/Makefile (tests): Only add tst-mxfast for -+ $(have-tunables). -+ * malloc/tst-mxfast.c: Fix copyright year. -+ (do_test): Fix GNU style issues. Use TEST_COMPARE instead of -+ assert for checks. -+ -+2019-08-09 DJ Delorie <dj@redhat.com> -+ -+ * elf/dl-tunables.list: Add glibc.malloc.mxfast. -+ * manual/tunables.texi: Document it. -+ * malloc/malloc.c (do_set_mxfast): New. -+ (__libc_mallopt): Call it. -+ * malloc/arena.c: Add mxfast tunable. -+ * malloc/tst-mxfast.c: New. -+ * malloc/Makefile: Add it. -+ -+2019-08-08 Niklas Hambüchen <mail@nh2.me> -+ Carlos O'Donell <carlos@redhat.com> -+ -+ [BZ #24026] -+ * malloc/malloc.c (__malloc_info): Account for top chunk. -+ -+2019-11-01 Dragan Mladjenovic <dmladjenovic@wavecomp.com> -+ -+ * sysdeps/unix/sysv/linux/mips/Makefile -+ (test-xfail-check-execstack): -+ Move under mips-has-gnustack != yes. -+ (CFLAGS-.o*, ASFLAGS-.o*): New rules. -+ Apply -Wa,-execstack if mips-force-execstack == yes. -+ * sysdeps/unix/sysv/linux/mips/configure: Regenerated. -+ * sysdeps/unix/sysv/linux/mips/configure.ac -+ (mips-force-execstack): New var. -+ Set to yes for hard-float builds with minimum_kernel < 4.8.0 -+ or minimum_kernel not set at all. -+ (mips-has-gnustack): New var. -+ Use value of libc_cv_as_noexecstack -+ if mips-force-execstack != yes, otherwise set to no. -+ -+2019-10-08 Gabriel F. T. Gomes <gabrielftg@linux.ibm.com> -+ -+ * Makefile: Fix locale dependency for a couple of tests. -+ ($(objpfx)tst-strftime2.out): New rule. -+ ($(objpfx)tst-strftime3.out): Likewise. -+ -+2019-09-20 Joseph Myers <joseph@codesourcery.com> -+ -+ * sysdeps/unix/sysv/linux/riscv/vfork.S: Do not include -+ <linux/sched.h>. -+ (CLONE_VM): New macro. -+ (CLONE_VFORK): Likewise. -+ -+2019-09-14 Aurelien Jarno <aurelien@aurel32.net> -+ -+ [BZ #24986] -+ * sysdeps/unix/alpha/getegid.S: Move to ... -+ * sysdeps/unix/sysv/linux/alpha/getegid.S: ... here. -+ * sysdeps/unix/alpha/geteuid.S: Move to ... -+ * sysdeps/unix/sysv/linux/alpha/geteuid.S: ... here. -+ * sysdeps/unix/alpha/getppid.S: Move to ... -+ * sysdeps/unix/sysv/linux/alpha/getppid.S: ... here -+ -+2019-09-08 Adhemerval Zanella <adhemerval.zanella@linaro.org> -+ -+ * sysdeps/hppa/fpu/libm-test-ulps: Update. -+ -+2019-09-03 Aurelien Jarno <aurelien@aurel32.net> -+ -+ * sysdeps/alpha/fpu/libm-test-ulps: Regenerated using GCC 9.2. -+ -+2019-08-28 Rafal Luzynski <digitalfreak@lingonborough.com> -+ -+ [BZ #24682] -+ * NEWS: Mention this bug fixed. -+ * localedata/locales/bo_CN (first_weekday): Add, set to 2 (Monday). -+ * localedata/locales/ug_CN (first_weekday): Likewise. -+ * localedata/locales/zh_CN (first_weekday): Likewise. -+ -+2019-08-01 Florian Weimer <fweimer@redhat.com> -+ -+ [BZ #24867] -+ * malloc/malloc.c (__malloc_info): Remove unwanted leading -+ whitespace. -+ - 2019-08-01 Carlos O'Donell <carlos@redhat.com> - - * version.h (RELEASE): Set to "stable". -diff --git a/NEWS b/NEWS -index ee9ed4de5a..15df670edc 100644 ---- a/NEWS -+++ b/NEWS -@@ -4,6 +4,38 @@ See the end for copying conditions. - - Please send GNU C library bug reports via <https://sourceware.org/bugzilla/> - using `glibc' in the "product" field. -+ -+Version 2.30.1 -+ -+Security related changes: -+ -+CVE-2019-19126: ld.so failed to ignore the LD_PREFER_MAP_32BIT_EXEC -+ environment variable during program execution after a security -+ transition, allowing local attackers to restrict the possible mapping -+ addresses for loaded libraries and thus bypass ASLR for a setuid -+ program. Reported by Marcin Kościelnicki. -+ -+The following bugs are resolved with this release: -+ -+ [23518] login: Remove utmp backend jump tables -+ [24682] localedata: zh_CN first weekday should be Monday per GB/T -+ 7408-2005 -+ [24867] malloc: Remove unwanted leading whitespace in malloc_info -+ [24879] login: Disarm timer after utmp lock acquisition -+ [24880] login: Use struct flock64 in utmp -+ [24882] login: Acquire write lock early in pututline -+ [24986] alpha: new getegid, geteuid and getppid syscalls used -+ unconditionally -+ [24899] login: Add nonstring attributes to struct utmp, struct utmpx -+ [24902] login: pututxline could fail to overwrite existing entries -+ [25066] FAIL: nptl/tst-tls1 on hppa -+ [25189] Don't use a custom wrapper macro around __has_include -+ [25203] libio: Disable vtable validation for pre-2.1 interposed handles -+ [25204] Ignore LD_PREFER_MAP_32BIT_EXEC for SUID programs -+ [25225] ld.so fails to link on x86 if GCC defaults to -fcf-protection -+ [25232] No const correctness for strchr et al. for Clang++ -+ [25401] Remove incorrect alloc_size attribute from pvalloc -+ - - Version 2.30 - -diff --git a/bits/utmp.h b/bits/utmp.h -index 4c36ca19ce..854b342164 100644 ---- a/bits/utmp.h -+++ b/bits/utmp.h -@@ -1,4 +1,4 @@ --/* The `struct utmp' type, describing entries in the utmp file. Generic/BSDish -+/* The `struct utmp' type, describing entries in the utmp file. - Copyright (C) 1993-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - -@@ -21,29 +21,107 @@ - #endif - - #include <paths.h> --#include <time.h> -+#include <sys/time.h> -+#include <sys/types.h> -+#include <bits/wordsize.h> - - --#define UT_NAMESIZE 8 --#define UT_LINESIZE 8 --#define UT_HOSTSIZE 16 -+#define UT_LINESIZE 32 -+#define UT_NAMESIZE 32 -+#define UT_HOSTSIZE 256 - - -+/* The structure describing an entry in the database of -+ previous logins. */ - struct lastlog - { -- time_t ll_time; -+#if __WORDSIZE_TIME64_COMPAT32 -+ int32_t ll_time; -+#else -+ __time_t ll_time; -+#endif - char ll_line[UT_LINESIZE]; - char ll_host[UT_HOSTSIZE]; - }; - --struct utmp -+ -+/* The structure describing the status of a terminated process. This -+ type is used in `struct utmp' below. */ -+struct exit_status - { -- char ut_line[UT_LINESIZE]; -- char ut_user[UT_NAMESIZE]; --#define ut_name ut_user -- char ut_host[UT_HOSTSIZE]; -- long int ut_time; -+ short int e_termination; /* Process termination status. */ -+ short int e_exit; /* Process exit status. */ - }; - - --#define _HAVE_UT_HOST 1 /* We have the ut_host field. */ -+/* The structure describing an entry in the user accounting database. */ -+struct utmp -+{ -+ short int ut_type; /* Type of login. */ -+ pid_t ut_pid; /* Process ID of login process. */ -+ char ut_line[UT_LINESIZE] -+ __attribute_nonstring__; /* Devicename. */ -+ char ut_id[4] -+ __attribute_nonstring__; /* Inittab ID. */ -+ char ut_user[UT_NAMESIZE] -+ __attribute_nonstring__; /* Username. */ -+ char ut_host[UT_HOSTSIZE] -+ __attribute_nonstring__; /* Hostname for remote login. */ -+ struct exit_status ut_exit; /* Exit status of a process marked -+ as DEAD_PROCESS. */ -+/* The ut_session and ut_tv fields must be the same size when compiled -+ 32- and 64-bit. This allows data files and shared memory to be -+ shared between 32- and 64-bit applications. */ -+#if __WORDSIZE_TIME64_COMPAT32 -+ int32_t ut_session; /* Session ID, used for windowing. */ -+ struct -+ { -+ int32_t tv_sec; /* Seconds. */ -+ int32_t tv_usec; /* Microseconds. */ -+ } ut_tv; /* Time entry was made. */ -+#else -+ long int ut_session; /* Session ID, used for windowing. */ -+ struct timeval ut_tv; /* Time entry was made. */ -+#endif -+ -+ int32_t ut_addr_v6[4]; /* Internet address of remote host. */ -+ char __glibc_reserved[20]; /* Reserved for future use. */ -+}; -+ -+/* Backwards compatibility hacks. */ -+#define ut_name ut_user -+#ifndef _NO_UT_TIME -+/* We have a problem here: `ut_time' is also used otherwise. Define -+ _NO_UT_TIME if the compiler complains. */ -+# define ut_time ut_tv.tv_sec -+#endif -+#define ut_xtime ut_tv.tv_sec -+#define ut_addr ut_addr_v6[0] -+ -+ -+/* Values for the `ut_type' field of a `struct utmp'. */ -+#define EMPTY 0 /* No valid user accounting information. */ -+ -+#define RUN_LVL 1 /* The system's runlevel. */ -+#define BOOT_TIME 2 /* Time of system boot. */ -+#define NEW_TIME 3 /* Time after system clock changed. */ -+#define OLD_TIME 4 /* Time when system clock changed. */ -+ -+#define INIT_PROCESS 5 /* Process spawned by the init process. */ -+#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ -+#define USER_PROCESS 7 /* Normal process. */ -+#define DEAD_PROCESS 8 /* Terminated process. */ -+ -+#define ACCOUNTING 9 -+ -+/* Old Linux name for the EMPTY type. */ -+#define UT_UNKNOWN EMPTY -+ -+ -+/* Tell the user that we have a modern system with UT_HOST, UT_PID, -+ UT_TYPE, UT_ID and UT_TV fields. */ -+#define _HAVE_UT_TYPE 1 -+#define _HAVE_UT_PID 1 -+#define _HAVE_UT_ID 1 -+#define _HAVE_UT_TV 1 -+#define _HAVE_UT_HOST 1 -diff --git a/configure b/configure -index c773c487b5..6d26b8246f 100755 ---- a/configure -+++ b/configure -@@ -3777,11 +3777,32 @@ else - fi - - -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+#ifndef __CET__ -+#error no CET compiler support -+#endif -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ libc_cv_compiler_default_cet=yes -+else -+ libc_cv_compiler_default_cet=no -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ - # Check whether --enable-cet was given. - if test "${enable_cet+set}" = set; then : - enableval=$enable_cet; enable_cet=$enableval - else -- enable_cet=no -+ enable_cet=$libc_cv_compiler_default_cet - fi - - -diff --git a/configure.ac b/configure.ac -index 598ba6c4ae..7436485419 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -472,11 +472,18 @@ AC_ARG_ENABLE([mathvec], - [build_mathvec=$enableval], - [build_mathvec=notset]) - -+AC_TRY_COMPILE([], [ -+#ifndef __CET__ -+# error no CET compiler support -+#endif], -+ [libc_cv_compiler_default_cet=yes], -+ [libc_cv_compiler_default_cet=no]) -+ - AC_ARG_ENABLE([cet], - AC_HELP_STRING([--enable-cet], - [enable Intel Control-flow Enforcement Technology (CET), x86 only]), - [enable_cet=$enableval], -- [enable_cet=no]) -+ [enable_cet=$libc_cv_compiler_default_cet]) - - # We keep the original values in `$config_*' and never modify them, so we - # can write them unchanged into config.make. Everything else uses -diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list -index 1fc2d8886b..525c3767b5 100644 ---- a/elf/dl-tunables.list -+++ b/elf/dl-tunables.list -@@ -85,6 +85,11 @@ glibc { - tcache_unsorted_limit { - type: SIZE_T - } -+ mxfast { -+ type: SIZE_T -+ minval: 0 -+ security_level: SXID_IGNORE -+ } - } - cpu { - hwcap_mask { -diff --git a/libio/oldstdfiles.c b/libio/oldstdfiles.c -index 2b861cd754..7503cdd62d 100644 ---- a/libio/oldstdfiles.c -+++ b/libio/oldstdfiles.c -@@ -83,6 +83,11 @@ _IO_check_libio (void) - = stderr->_vtable_offset = - ((int) sizeof (struct _IO_FILE) - - (int) sizeof (struct _IO_FILE_complete)); -+ -+ if (_IO_stdin_.vtable != &_IO_old_file_jumps -+ || _IO_stdout_.vtable != &_IO_old_file_jumps -+ || _IO_stderr_.vtable != &_IO_old_file_jumps) -+ IO_set_accept_foreign_vtables (&_IO_vtable_check); - } - } - -diff --git a/localedata/locales/bo_CN b/localedata/locales/bo_CN -index 90cbc7807b..9df91a1721 100644 ---- a/localedata/locales/bo_CN -+++ b/localedata/locales/bo_CN -@@ -128,6 +128,7 @@ t_fmt_ampm "<U0F46><U0F74><U0F0B><U0F5A><U0F7C><U0F51>/ - <U0025><U0070>" - - week 7;19971130;1 -+first_weekday 2 - END LC_TIME - - LC_MESSAGES -diff --git a/localedata/locales/ug_CN b/localedata/locales/ug_CN -index 1ba583c588..83d15c90e4 100644 ---- a/localedata/locales/ug_CN -+++ b/localedata/locales/ug_CN -@@ -165,6 +165,7 @@ am_pm "";"" - date_fmt "%a<U060C> %d-%m-%Y<U060C> %T" - - week 7;19971130;1 -+first_weekday 2 - END LC_TIME - - LC_MESSAGES -diff --git a/localedata/locales/zh_CN b/localedata/locales/zh_CN -index 62a46415c1..cd4b33602a 100644 ---- a/localedata/locales/zh_CN -+++ b/localedata/locales/zh_CN -@@ -139,6 +139,7 @@ t_fmt_ampm "%p %I<U65F6>%M<U5206>%S<U79D2>" - - date_fmt "%Y<U5E74> %m<U6708> %d<U65E5> %A %H:%M:%S %Z" - week 7;19971130;1 -+first_weekday 2 - END LC_TIME - - LC_MESSAGES -diff --git a/login/Makefile b/login/Makefile -index 92535f0aec..4fd8195e73 100644 ---- a/login/Makefile -+++ b/login/Makefile -@@ -43,7 +43,8 @@ endif - subdir-dirs = programs - vpath %.c programs - --tests := tst-utmp tst-utmpx tst-grantpt tst-ptsname tst-getlogin -+tests := tst-utmp tst-utmpx tst-grantpt tst-ptsname tst-getlogin tst-updwtmpx \ -+ tst-pututxline-lockfail tst-pututxline-cache - - # Build the -lutil library with these extra functions. - extra-libs := libutil -@@ -71,3 +72,6 @@ endif - $(inst_libexecdir)/pt_chown: $(objpfx)pt_chown $(+force) - $(make-target-directory) - -$(INSTALL_PROGRAM) -m 4755 -o root $< $@ -+ -+$(objpfx)tst-pututxline-lockfail: $(shared-thread-library) -+$(objpfx)tst-pututxline-cache: $(shared-thread-library) -diff --git a/login/getutent_r.c b/login/getutent_r.c -index 98ffc5d1c6..fd13be8a1e 100644 ---- a/login/getutent_r.c -+++ b/login/getutent_r.c -@@ -23,115 +23,16 @@ - - #include "utmp-private.h" - -- --/* Functions defined here. */ --static int setutent_unknown (void); --static int getutent_r_unknown (struct utmp *buffer, struct utmp **result); --static int getutid_r_unknown (const struct utmp *line, struct utmp *buffer, -- struct utmp **result); --static int getutline_r_unknown (const struct utmp *id, struct utmp *buffer, -- struct utmp **result); --static struct utmp *pututline_unknown (const struct utmp *data); --static void endutent_unknown (void); -- --/* Initial Jump table. */ --const struct utfuncs __libc_utmp_unknown_functions = --{ -- setutent_unknown, -- getutent_r_unknown, -- getutid_r_unknown, -- getutline_r_unknown, -- pututline_unknown, -- endutent_unknown, -- NULL --}; -- --/* Currently selected backend. */ --const struct utfuncs *__libc_utmp_jump_table = &__libc_utmp_unknown_functions; -- - /* We need to protect the opening of the file. */ - __libc_lock_define_initialized (, __libc_utmp_lock attribute_hidden) - - --static int --setutent_unknown (void) --{ -- int result; -- -- result = (*__libc_utmp_file_functions.setutent) (); -- if (result) -- __libc_utmp_jump_table = &__libc_utmp_file_functions; -- -- return result; --} -- -- --static int --getutent_r_unknown (struct utmp *buffer, struct utmp **result) --{ -- /* The backend was not yet initialized. */ -- if (setutent_unknown ()) -- return (*__libc_utmp_jump_table->getutent_r) (buffer, result); -- -- /* Not available. */ -- *result = NULL; -- return -1; --} -- -- --static int --getutid_r_unknown (const struct utmp *id, struct utmp *buffer, -- struct utmp **result) --{ -- /* The backend was not yet initialized. */ -- if (setutent_unknown ()) -- return (*__libc_utmp_jump_table->getutid_r) (id, buffer, result); -- -- /* Not available. */ -- *result = NULL; -- return -1; --} -- -- --static int --getutline_r_unknown (const struct utmp *line, struct utmp *buffer, -- struct utmp **result) --{ -- /* The backend was not yet initialized. */ -- if (setutent_unknown ()) -- return (*__libc_utmp_jump_table->getutline_r) (line, buffer, result); -- -- /* Not available. */ -- *result = NULL; -- return -1; --} -- -- --static struct utmp * --pututline_unknown (const struct utmp *data) --{ -- /* The backend was not yet initialized. */ -- if (setutent_unknown ()) -- return (*__libc_utmp_jump_table->pututline) (data); -- -- /* Not available. */ -- return NULL; --} -- -- --static void --endutent_unknown (void) --{ -- /* Nothing to do. */ --} -- -- - void - __setutent (void) - { - __libc_lock_lock (__libc_utmp_lock); - -- (*__libc_utmp_jump_table->setutent) (); -+ __libc_setutent (); - - __libc_lock_unlock (__libc_utmp_lock); - } -@@ -145,7 +46,7 @@ __getutent_r (struct utmp *buffer, struct utmp **result) - - __libc_lock_lock (__libc_utmp_lock); - -- retval = (*__libc_utmp_jump_table->getutent_r) (buffer, result); -+ retval = __libc_getutent_r (buffer, result); - - __libc_lock_unlock (__libc_utmp_lock); - -@@ -162,7 +63,7 @@ __pututline (const struct utmp *data) - - __libc_lock_lock (__libc_utmp_lock); - -- buffer = (*__libc_utmp_jump_table->pututline) (data); -+ buffer = __libc_pututline (data); - - __libc_lock_unlock (__libc_utmp_lock); - -@@ -177,8 +78,7 @@ __endutent (void) - { - __libc_lock_lock (__libc_utmp_lock); - -- (*__libc_utmp_jump_table->endutent) (); -- __libc_utmp_jump_table = &__libc_utmp_unknown_functions; -+ __libc_endutent (); - - __libc_lock_unlock (__libc_utmp_lock); - } -diff --git a/login/getutid_r.c b/login/getutid_r.c -index 34ea61d8f4..460d94be0c 100644 ---- a/login/getutid_r.c -+++ b/login/getutid_r.c -@@ -32,7 +32,6 @@ __libc_lock_define (extern, __libc_utmp_lock attribute_hidden) - int - __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result) - { --#if (_HAVE_UT_ID - 0) && (_HAVE_UT_TYPE - 0) - int retval; - - /* Test whether ID has any of the legal types. */ -@@ -49,15 +48,11 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result) - - __libc_lock_lock (__libc_utmp_lock); - -- retval = (*__libc_utmp_jump_table->getutid_r) (id, buffer, result); -+ retval = __libc_getutid_r (id, buffer, result); - - __libc_lock_unlock (__libc_utmp_lock); - - return retval; --#else /* !_HAVE_UT_ID && !_HAVE_UT_TYPE */ -- __set_errno (ENOSYS); -- return -1; --#endif - } - libc_hidden_def (__getutid_r) - weak_alias (__getutid_r, getutid_r) -diff --git a/login/getutline_r.c b/login/getutline_r.c -index 110b89e438..f03255dbbd 100644 ---- a/login/getutline_r.c -+++ b/login/getutline_r.c -@@ -36,7 +36,7 @@ __getutline_r (const struct utmp *line, struct utmp *buffer, - - __libc_lock_lock (__libc_utmp_lock); - -- retval = (*__libc_utmp_jump_table->getutline_r) (line, buffer, result); -+ retval = __libc_getutline_r (line, buffer, result); - - __libc_lock_unlock (__libc_utmp_lock); - -diff --git a/login/getutmp.c b/login/getutmp.c -index 73bc15d781..4e3be11216 100644 ---- a/login/getutmp.c -+++ b/login/getutmp.c -@@ -23,23 +23,11 @@ - void - getutmp (const struct utmpx *utmpx, struct utmp *utmp) - { --#if _HAVE_UT_TYPE - 0 - utmp->ut_type = utmpx->ut_type; --#endif --#if _HAVE_UT_PID - 0 - utmp->ut_pid = utmpx->ut_pid; --#endif - memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line)); - memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user)); --#if _HAVE_UT_ID - 0 - memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id)); --#endif --#if _HAVE_UT_HOST - 0 - memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host)); --#endif --#if _HAVE_UT_TV - 0 - utmp->ut_tv = utmpx->ut_tv; --#else -- utmp->ut_time = utmpx->ut_time; --#endif - } -diff --git a/login/getutmpx.c b/login/getutmpx.c -index b181d9bc30..da28d339ab 100644 ---- a/login/getutmpx.c -+++ b/login/getutmpx.c -@@ -24,24 +24,11 @@ void - getutmpx (const struct utmp *utmp, struct utmpx *utmpx) - { - memset (utmpx, 0, sizeof (struct utmpx)); -- --#if _HAVE_UT_TYPE - 0 - utmpx->ut_type = utmp->ut_type; --#endif --#if _HAVE_UT_PID - 0 - utmpx->ut_pid = utmp->ut_pid; --#endif - memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line)); - memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user)); --#if _HAVE_UT_ID - 0 - memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id)); --#endif --#if _HAVE_UT_HOST - 0 - memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host)); --#endif --#if _HAVE_UT_TV - 0 - utmpx->ut_tv = utmp->ut_tv; --#else -- utmpx->ut_time = utmp->ut_time; --#endif - } -diff --git a/login/login.c b/login/login.c -index 09ef3f75a5..b7d638c692 100644 ---- a/login/login.c -+++ b/login/login.c -@@ -91,12 +91,8 @@ login (const struct utmp *ut) - struct utmp copy = *ut; - - /* Fill in those fields we supply. */ --#if _HAVE_UT_TYPE - 0 - copy.ut_type = USER_PROCESS; --#endif --#if _HAVE_UT_PID - 0 - copy.ut_pid = getpid (); --#endif - - /* Seek tty. */ - found_tty = tty_name (STDIN_FILENO, &tty, sizeof (_tty)); -diff --git a/login/logout.c b/login/logout.c -index 85254d0324..5015c1af0b 100644 ---- a/login/logout.c -+++ b/login/logout.c -@@ -36,9 +36,7 @@ logout (const char *line) - setutent (); - - /* Fill in search information. */ --#if _HAVE_UT_TYPE - 0 - tmp.ut_type = USER_PROCESS; --#endif - strncpy (tmp.ut_line, line, sizeof tmp.ut_line); - - /* Read the record. */ -@@ -46,20 +44,12 @@ logout (const char *line) - { - /* Clear information about who & from where. */ - memset (ut->ut_name, '\0', sizeof ut->ut_name); --#if _HAVE_UT_HOST - 0 - memset (ut->ut_host, '\0', sizeof ut->ut_host); --#endif --#if _HAVE_UT_TV - 0 - struct timeval tv; - __gettimeofday (&tv, NULL); - ut->ut_tv.tv_sec = tv.tv_sec; - ut->ut_tv.tv_usec = tv.tv_usec; --#else -- ut->ut_time = time (NULL); --#endif --#if _HAVE_UT_TYPE - 0 - ut->ut_type = DEAD_PROCESS; --#endif - - if (pututline (ut) != NULL) - result = 1; -diff --git a/login/logwtmp.c b/login/logwtmp.c -index f53187121c..50d14976c7 100644 ---- a/login/logwtmp.c -+++ b/login/logwtmp.c -@@ -30,26 +30,16 @@ logwtmp (const char *line, const char *name, const char *host) - - /* Set information in new entry. */ - memset (&ut, 0, sizeof (ut)); --#if _HAVE_UT_PID - 0 - ut.ut_pid = getpid (); --#endif --#if _HAVE_UT_TYPE - 0 - ut.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS; --#endif - strncpy (ut.ut_line, line, sizeof ut.ut_line); - strncpy (ut.ut_name, name, sizeof ut.ut_name); --#if _HAVE_UT_HOST - 0 - strncpy (ut.ut_host, host, sizeof ut.ut_host); --#endif - --#if _HAVE_UT_TV - 0 - struct timeval tv; - __gettimeofday (&tv, NULL); - ut.ut_tv.tv_sec = tv.tv_sec; - ut.ut_tv.tv_usec = tv.tv_usec; --#else -- ut.ut_time = time (NULL); --#endif - - updwtmp (_PATH_WTMP, &ut); - } -diff --git a/login/programs/utmpdump.c b/login/programs/utmpdump.c -index 4c312f0939..85d8e31b43 100644 ---- a/login/programs/utmpdump.c -+++ b/login/programs/utmpdump.c -@@ -37,47 +37,11 @@ print_entry (struct utmp *up) - temp_tv.tv_sec = up->ut_tv.tv_sec; - temp_tv.tv_usec = up->ut_tv.tv_usec; - -- (printf) ( -- /* The format string. */ --#if _HAVE_UT_TYPE -- "[%d] " --#endif --#if _HAVE_UT_PID -- "[%05d] " --#endif --#if _HAVE_UT_ID -- "[%-4.4s] " --#endif -- "[%-8.8s] [%-12.12s]" --#if _HAVE_UT_HOST -- " [%-16.16s]" --#endif -- " [%-15.15s]" --#if _HAVE_UT_TV -- " [%ld]" --#endif -- "\n" -- /* The arguments. */ --#if _HAVE_UT_TYPE -- , up->ut_type --#endif --#if _HAVE_UT_PID -- , up->ut_pid --#endif --#if _HAVE_UT_ID -- , up->ut_id --#endif -- , up->ut_user, up->ut_line --#if _HAVE_UT_HOST -- , up->ut_host --#endif --#if _HAVE_UT_TV -- , 4 + ctime (&temp_tv.tv_sec) -- , (long int) temp_tv.tv_usec --#else -- , 4 + ctime (&up->ut_time) --#endif -- ); -+ printf ("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-16.16s] [%-15.15s]" -+ " [%ld]\n", -+ up->ut_type, up->ut_pid, up->ut_id, up->ut_user, up->ut_line, -+ up->ut_host, 4 + ctime (&temp_tv.tv_sec), -+ (long int) temp_tv.tv_usec); - } - - int -diff --git a/login/tst-pututxline-cache.c b/login/tst-pututxline-cache.c -new file mode 100644 -index 0000000000..3f30dd1776 ---- /dev/null -+++ b/login/tst-pututxline-cache.c -@@ -0,0 +1,193 @@ -+/* Test case for cache invalidation after concurrent write (bug 24882). -+ Copyright (C) 2019 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; see the file COPYING.LIB. If -+ not, see <http://www.gnu.org/licenses/>. */ -+ -+/* This test writes an entry to the utmpx file, reads it (so that it -+ is cached) in process1, and overwrites the same entry in process2 -+ with something that does not match the search criteria. At this -+ point, the cache of the first process is stale, and when process1 -+ attempts to write a new record which would have gone to the same -+ place (as indicated by the cache), it needs to realize that it has -+ to pick a different slot because the old slot is now used for -+ something else. */ -+ -+#include <errno.h> -+#include <stdlib.h> -+#include <string.h> -+#include <support/check.h> -+#include <support/namespace.h> -+#include <support/support.h> -+#include <support/temp_file.h> -+#include <support/xthread.h> -+#include <support/xunistd.h> -+#include <utmp.h> -+#include <utmpx.h> -+ -+/* Set to the path of the utmp file. */ -+static char *utmp_file; -+ -+/* Used to synchronize the subprocesses. The barrier itself is -+ allocated in shared memory. */ -+static pthread_barrier_t *barrier; -+ -+/* setutxent with error checking. */ -+static void -+xsetutxent (void) -+{ -+ errno = 0; -+ setutxent (); -+ TEST_COMPARE (errno, 0); -+} -+ -+/* getutxent with error checking. */ -+static struct utmpx * -+xgetutxent (void) -+{ -+ errno = 0; -+ struct utmpx *result = getutxent (); -+ if (result == NULL) -+ FAIL_EXIT1 ("getutxent: %m"); -+ return result; -+} -+ -+static void -+put_entry (const char *id, pid_t pid, const char *user, const char *line) -+{ -+ struct utmpx ut = -+ { -+ .ut_type = LOGIN_PROCESS, -+ .ut_pid = pid, -+ .ut_host = "localhost", -+ }; -+ strcpy (ut.ut_id, id); -+ strncpy (ut.ut_user, user, sizeof (ut.ut_user)); -+ strncpy (ut.ut_line, line, sizeof (ut.ut_line)); -+ TEST_VERIFY (pututxline (&ut) != NULL); -+} -+ -+/* Use two cooperating subprocesses to avoid issues related to -+ unlock-on-close semantics of POSIX advisory locks. */ -+ -+static __attribute__ ((noreturn)) void -+process1 (void) -+{ -+ TEST_COMPARE (utmpname (utmp_file), 0); -+ -+ /* Create an entry. */ -+ xsetutxent (); -+ put_entry ("1", 101, "root", "process1"); -+ -+ /* Retrieve the entry. This will fill the internal cache. */ -+ { -+ errno = 0; -+ setutxent (); -+ TEST_COMPARE (errno, 0); -+ struct utmpx ut = -+ { -+ .ut_type = LOGIN_PROCESS, -+ .ut_line = "process1", -+ }; -+ struct utmpx *result = getutxline (&ut); -+ if (result == NULL) -+ FAIL_EXIT1 ("getutxline (\"process1\"): %m"); -+ TEST_COMPARE (result->ut_pid, 101); -+ } -+ -+ /* Signal the other process to overwrite the entry. */ -+ xpthread_barrier_wait (barrier); -+ -+ /* Wait for the other process to complete the write operation. */ -+ xpthread_barrier_wait (barrier); -+ -+ /* Add another entry. Note: This time, there is no setutxent call. */ -+ put_entry ("1", 103, "root", "process1"); -+ -+ _exit (0); -+} -+ -+static void -+process2 (void *closure) -+{ -+ /* Wait for the first process to write its entry. */ -+ xpthread_barrier_wait (barrier); -+ -+ /* Truncate the file. The glibc interface does not support -+ re-purposing records, but an external expiration mechanism may -+ trigger this. */ -+ TEST_COMPARE (truncate64 (utmp_file, 0), 0); -+ -+ /* Write the replacement entry. */ -+ TEST_COMPARE (utmpname (utmp_file), 0); -+ xsetutxent (); -+ put_entry ("2", 102, "user", "process2"); -+ -+ /* Signal the other process that the entry has been replaced. */ -+ xpthread_barrier_wait (barrier); -+} -+ -+static int -+do_test (void) -+{ -+ xclose (create_temp_file ("tst-tumpx-cache-write-", &utmp_file)); -+ { -+ pthread_barrierattr_t attr; -+ xpthread_barrierattr_init (&attr); -+ xpthread_barrierattr_setpshared (&attr, PTHREAD_SCOPE_PROCESS); -+ barrier = support_shared_allocate (sizeof (*barrier)); -+ xpthread_barrier_init (barrier, &attr, 2); -+ } -+ -+ /* Run both subprocesses in parallel. */ -+ { -+ pid_t pid1 = xfork (); -+ if (pid1 == 0) -+ process1 (); -+ support_isolate_in_subprocess (process2, NULL); -+ int status; -+ xwaitpid (pid1, &status, 0); -+ TEST_COMPARE (status, 0); -+ } -+ -+ /* Check that the utmpx database contains the expected records. */ -+ { -+ TEST_COMPARE (utmpname (utmp_file), 0); -+ xsetutxent (); -+ -+ struct utmpx *ut = xgetutxent (); -+ TEST_COMPARE_STRING (ut->ut_id, "2"); -+ TEST_COMPARE (ut->ut_pid, 102); -+ TEST_COMPARE_STRING (ut->ut_user, "user"); -+ TEST_COMPARE_STRING (ut->ut_line, "process2"); -+ -+ ut = xgetutxent (); -+ TEST_COMPARE_STRING (ut->ut_id, "1"); -+ TEST_COMPARE (ut->ut_pid, 103); -+ TEST_COMPARE_STRING (ut->ut_user, "root"); -+ TEST_COMPARE_STRING (ut->ut_line, "process1"); -+ -+ if (getutxent () != NULL) -+ FAIL_EXIT1 ("additional utmpx entry"); -+ } -+ -+ xpthread_barrier_destroy (barrier); -+ support_shared_free (barrier); -+ free (utmp_file); -+ -+ return 0; -+} -+ -+#include <support/test-driver.c> -diff --git a/login/tst-pututxline-lockfail.c b/login/tst-pututxline-lockfail.c -new file mode 100644 -index 0000000000..47c25dc065 ---- /dev/null -+++ b/login/tst-pututxline-lockfail.c -@@ -0,0 +1,176 @@ -+/* Test the lock upgrade path in tst-pututxline. -+ Copyright (C) 2019 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; see the file COPYING.LIB. If -+ not, see <http://www.gnu.org/licenses/>. */ -+ -+/* pututxline upgrades the read lock on the file to a write lock. -+ This test verifies that if the lock upgrade fails, the utmp -+ subsystem remains in a consistent state, so that pututxline can be -+ called again. */ -+ -+#include <errno.h> -+#include <fcntl.h> -+#include <stdlib.h> -+#include <support/check.h> -+#include <support/namespace.h> -+#include <support/support.h> -+#include <support/temp_file.h> -+#include <support/xthread.h> -+#include <support/xunistd.h> -+#include <unistd.h> -+#include <utmp.h> -+#include <utmpx.h> -+ -+/* Path to the temporary utmp file. */ -+static char *path; -+ -+/* Used to synchronize the subprocesses. The barrier itself is -+ allocated in shared memory. */ -+static pthread_barrier_t *barrier; -+ -+/* Use pututxline to write an entry for PID. */ -+static struct utmpx * -+write_entry (pid_t pid) -+{ -+ struct utmpx ut = -+ { -+ .ut_type = LOGIN_PROCESS, -+ .ut_id = "1", -+ .ut_user = "root", -+ .ut_pid = pid, -+ .ut_line = "entry", -+ .ut_host = "localhost", -+ }; -+ return pututxline (&ut); -+} -+ -+/* Create the initial entry in a subprocess, so that the utmp -+ subsystem in the original process is not disturbed. */ -+static void -+subprocess_create_entry (void *closure) -+{ -+ TEST_COMPARE (utmpname (path), 0); -+ TEST_VERIFY (write_entry (101) != NULL); -+} -+ -+/* Acquire an advisory read lock on PATH. */ -+__attribute__ ((noreturn)) static void -+subprocess_lock_file (void) -+{ -+ int fd = xopen (path, O_RDONLY, 0); -+ -+ struct flock64 fl = -+ { -+ .l_type = F_RDLCK, -+ fl.l_whence = SEEK_SET, -+ }; -+ TEST_COMPARE (fcntl64 (fd, F_SETLKW, &fl), 0); -+ -+ /* Signal to the main process that the lock has been acquired. */ -+ xpthread_barrier_wait (barrier); -+ -+ /* Wait for the unlock request from the main process. */ -+ xpthread_barrier_wait (barrier); -+ -+ /* Implicitly unlock the file. */ -+ xclose (fd); -+ -+ /* Overwrite the existing entry. */ -+ TEST_COMPARE (utmpname (path), 0); -+ errno = 0; -+ setutxent (); -+ TEST_COMPARE (errno, 0); -+ TEST_VERIFY (write_entry (102) != NULL); -+ errno = 0; -+ endutxent (); -+ TEST_COMPARE (errno, 0); -+ -+ _exit (0); -+} -+ -+static int -+do_test (void) -+{ -+ xclose (create_temp_file ("tst-pututxline-lockfail-", &path)); -+ -+ { -+ pthread_barrierattr_t attr; -+ xpthread_barrierattr_init (&attr); -+ xpthread_barrierattr_setpshared (&attr, PTHREAD_SCOPE_PROCESS); -+ barrier = support_shared_allocate (sizeof (*barrier)); -+ xpthread_barrier_init (barrier, &attr, 2); -+ xpthread_barrierattr_destroy (&attr); -+ } -+ -+ /* Write the initial entry. */ -+ support_isolate_in_subprocess (subprocess_create_entry, NULL); -+ -+ pid_t locker_pid = xfork (); -+ if (locker_pid == 0) -+ subprocess_lock_file (); -+ -+ /* Wait for the file locking to complete. */ -+ xpthread_barrier_wait (barrier); -+ -+ /* Try to add another entry. This attempt will fail, with EINTR or -+ EAGAIN. */ -+ TEST_COMPARE (utmpname (path), 0); -+ TEST_VERIFY (write_entry (102) == NULL); -+ if (errno != EINTR) -+ TEST_COMPARE (errno, EAGAIN); -+ -+ /* Signal the subprocess to overwrite the entry. */ -+ xpthread_barrier_wait (barrier); -+ -+ /* Wait for write and unlock to complete. */ -+ { -+ int status; -+ xwaitpid (locker_pid, &status, 0); -+ TEST_COMPARE (status, 0); -+ } -+ -+ /* The file is no longer locked, so this operation will succeed. */ -+ TEST_VERIFY (write_entry (103) != NULL); -+ errno = 0; -+ endutxent (); -+ TEST_COMPARE (errno, 0); -+ -+ /* Check that there is just one entry with the expected contents. -+ If pututxline becomes desynchronized internally, the entry is not -+ overwritten (bug 24902). */ -+ errno = 0; -+ setutxent (); -+ TEST_COMPARE (errno, 0); -+ struct utmpx *ut = getutxent (); -+ TEST_VERIFY_EXIT (ut != NULL); -+ TEST_COMPARE (ut->ut_type, LOGIN_PROCESS); -+ TEST_COMPARE_STRING (ut->ut_id, "1"); -+ TEST_COMPARE_STRING (ut->ut_user, "root"); -+ TEST_COMPARE (ut->ut_pid, 103); -+ TEST_COMPARE_STRING (ut->ut_line, "entry"); -+ TEST_COMPARE_STRING (ut->ut_host, "localhost"); -+ TEST_VERIFY (getutxent () == NULL); -+ errno = 0; -+ endutxent (); -+ TEST_COMPARE (errno, 0); -+ -+ xpthread_barrier_destroy (barrier); -+ support_shared_free (barrier); -+ free (path); -+ return 0; -+} -+ -+#include <support/test-driver.c> -diff --git a/login/tst-updwtmpx.c b/login/tst-updwtmpx.c -new file mode 100644 -index 0000000000..0a4a27daeb ---- /dev/null -+++ b/login/tst-updwtmpx.c -@@ -0,0 +1,112 @@ -+/* Basic test coverage for updwtmpx. -+ Copyright (C) 2019 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; see the file COPYING.LIB. If -+ not, see <http://www.gnu.org/licenses/>. */ -+ -+/* This program runs a series of tests. Each one calls updwtmpx -+ twice, to write two records, optionally with misalignment in the -+ file, and reads back the results. */ -+ -+#include <errno.h> -+#include <stdlib.h> -+#include <support/check.h> -+#include <support/descriptors.h> -+#include <support/support.h> -+#include <support/temp_file.h> -+#include <support/test-driver.h> -+#include <support/xunistd.h> -+#include <unistd.h> -+#include <utmpx.h> -+ -+static int -+do_test (void) -+{ -+ /* Two entries filled with an arbitrary bit pattern. */ -+ struct utmpx entries[2]; -+ unsigned char pad; -+ { -+ unsigned char *p = (unsigned char *) &entries[0]; -+ for (size_t i = 0; i < sizeof (entries); ++i) -+ { -+ p[i] = i; -+ } -+ /* Make sure that the first and second entry and the padding are -+ different. */ -+ p[sizeof (struct utmpx)] = p[0] + 1; -+ pad = p[0] + 2; -+ } -+ -+ char *path; -+ int fd = create_temp_file ("tst-updwtmpx-", &path); -+ -+ /* Used to check that updwtmpx does not leave an open file -+ descriptor around. */ -+ struct support_descriptors *descriptors = support_descriptors_list (); -+ -+ /* updwtmpx is expected to remove misalignment. Optionally insert -+ one byte of misalignment at the start and in the middle (after -+ the first entry). */ -+ for (int misaligned_start = 0; misaligned_start < 2; ++misaligned_start) -+ for (int misaligned_middle = 0; misaligned_middle < 2; ++misaligned_middle) -+ { -+ if (test_verbose > 0) -+ printf ("info: misaligned_start=%d misaligned_middle=%d\n", -+ misaligned_start, misaligned_middle); -+ -+ xftruncate (fd, 0); -+ TEST_COMPARE (pwrite64 (fd, &pad, misaligned_start, 0), -+ misaligned_start); -+ -+ /* Write first entry and check it. */ -+ errno = 0; -+ updwtmpx (path, &entries[0]); -+ TEST_COMPARE (errno, 0); -+ support_descriptors_check (descriptors); -+ TEST_COMPARE (xlseek (fd, 0, SEEK_END), sizeof (struct utmpx)); -+ struct utmpx buffer; -+ TEST_COMPARE (pread64 (fd, &buffer, sizeof (buffer), 0), -+ sizeof (buffer)); -+ TEST_COMPARE_BLOB (&entries[0], sizeof (entries[0]), -+ &buffer, sizeof (buffer)); -+ -+ /* Middle mis-alignmet. */ -+ TEST_COMPARE (pwrite64 (fd, &pad, misaligned_middle, -+ sizeof (struct utmpx)), misaligned_middle); -+ -+ /* Write second entry and check both entries. */ -+ errno = 0; -+ updwtmpx (path, &entries[1]); -+ TEST_COMPARE (errno, 0); -+ support_descriptors_check (descriptors); -+ TEST_COMPARE (xlseek (fd, 0, SEEK_END), 2 * sizeof (struct utmpx)); -+ TEST_COMPARE (pread64 (fd, &buffer, sizeof (buffer), 0), -+ sizeof (buffer)); -+ TEST_COMPARE_BLOB (&entries[0], sizeof (entries[0]), -+ &buffer, sizeof (buffer)); -+ TEST_COMPARE (pread64 (fd, &buffer, sizeof (buffer), sizeof (buffer)), -+ sizeof (buffer)); -+ TEST_COMPARE_BLOB (&entries[1], sizeof (entries[1]), -+ &buffer, sizeof (buffer)); -+ } -+ -+ support_descriptors_free (descriptors); -+ free (path); -+ xclose (fd); -+ -+ return 0; -+} -+ -+#include <support/test-driver.c> -diff --git a/login/tst-utmp.c b/login/tst-utmp.c -index ce48e8326e..02d0c1fe8c 100644 ---- a/login/tst-utmp.c -+++ b/login/tst-utmp.c -@@ -39,8 +39,6 @@ - #endif - - --#if defined UTMPX || _HAVE_UT_TYPE -- - /* Prototype for our test function. */ - static int do_test (int argc, char *argv[]); - -@@ -75,11 +73,7 @@ do_prepare (int argc, char *argv[]) - - struct utmp entry[] = - { --#if defined UTMPX || _HAVE_UT_TV - #define UT(a) .ut_tv = { .tv_sec = (a)} --#else --#define UT(a) .ut_time = (a) --#endif - - { .ut_type = BOOT_TIME, .ut_pid = 1, UT(1000) }, - { .ut_type = RUN_LVL, .ut_pid = 1, UT(2000) }, -@@ -167,11 +161,7 @@ simulate_login (const char *line, const char *user) - entry[n].ut_pid = (entry_pid += 27); - entry[n].ut_type = USER_PROCESS; - strncpy (entry[n].ut_user, user, sizeof (entry[n].ut_user)); --#if defined UTMPX || _HAVE_UT_TV - 0 - entry[n].ut_tv.tv_sec = (entry_time += 1000); --#else -- entry[n].ut_time = (entry_time += 1000); --#endif - setutent (); - - if (pututline (&entry[n]) == NULL) -@@ -201,11 +191,7 @@ simulate_logout (const char *line) - { - entry[n].ut_type = DEAD_PROCESS; - strncpy (entry[n].ut_user, "", sizeof (entry[n].ut_user)); --#if defined UTMPX || _HAVE_UT_TV - 0 - entry[n].ut_tv.tv_sec = (entry_time += 1000); --#else -- entry[n].ut_time = (entry_time += 1000); --#endif - setutent (); - - if (pututline (&entry[n]) == NULL) -@@ -390,14 +376,3 @@ do_test (int argc, char *argv[]) - - return result; - } -- --#else -- --/* No field 'ut_type' in struct utmp. */ --int --main (void) --{ -- return 0; --} -- --#endif -diff --git a/login/updwtmp.c b/login/updwtmp.c -index b9bccd9b67..387e580828 100644 ---- a/login/updwtmp.c -+++ b/login/updwtmp.c -@@ -29,7 +29,7 @@ __updwtmp (const char *wtmp_file, const struct utmp *utmp) - { - const char *file_name = TRANSFORM_UTMP_FILE_NAME (wtmp_file); - -- (*__libc_utmp_file_functions.updwtmp) (file_name, utmp); -+ __libc_updwtmp (file_name, utmp); - } - libc_hidden_def (__updwtmp) - weak_alias (__updwtmp, updwtmp) -diff --git a/login/utmp-private.h b/login/utmp-private.h -index a82a923657..d60461d644 100644 ---- a/login/utmp-private.h -+++ b/login/utmp-private.h -@@ -24,24 +24,17 @@ - #include <utmp.h> - #include <libc-lock.h> - --/* The structure describing the functions in a backend. */ --struct utfuncs --{ -- int (*setutent) (void); -- int (*getutent_r) (struct utmp *, struct utmp **); -- int (*getutid_r) (const struct utmp *, struct utmp *, struct utmp **); -- int (*getutline_r) (const struct utmp *, struct utmp *, struct utmp **); -- struct utmp *(*pututline) (const struct utmp *); -- void (*endutent) (void); -- int (*updwtmp) (const char *, const struct utmp *); --}; -- --/* The tables from the services. */ --extern const struct utfuncs __libc_utmp_file_functions attribute_hidden; --extern const struct utfuncs __libc_utmp_unknown_functions attribute_hidden; -- --/* Currently selected backend. */ --extern const struct utfuncs *__libc_utmp_jump_table attribute_hidden; -+/* These functions check for initialization, but not perform any -+ locking. */ -+int __libc_setutent (void) attribute_hidden; -+int __libc_getutent_r (struct utmp *, struct utmp **) attribute_hidden; -+int __libc_getutid_r (const struct utmp *, struct utmp *, struct utmp **) -+ attribute_hidden; -+int __libc_getutline_r (const struct utmp *, struct utmp *, struct utmp **) -+ attribute_hidden; -+struct utmp *__libc_pututline (const struct utmp *) attribute_hidden; -+void __libc_endutent (void) attribute_hidden; -+int __libc_updwtmp (const char *, const struct utmp *) attribute_hidden; - - /* Current file name. */ - extern const char *__libc_utmp_file_name attribute_hidden; -diff --git a/login/utmp_file.c b/login/utmp_file.c -index b19d3caf0d..e98bc31899 100644 ---- a/login/utmp_file.c -+++ b/login/utmp_file.c -@@ -43,6 +43,25 @@ static off64_t file_offset; - /* Cache for the last read entry. */ - static struct utmp last_entry; - -+/* Returns true if *ENTRY matches last_entry, based on -+ data->ut_type. */ -+static bool -+matches_last_entry (const struct utmp *data) -+{ -+ if (file_offset <= 0) -+ /* Nothing has been read. last_entry is stale and cannot match. */ -+ return false; -+ -+ if (data->ut_type == RUN_LVL -+ || data->ut_type == BOOT_TIME -+ || data->ut_type == OLD_TIME -+ || data->ut_type == NEW_TIME) -+ /* For some entry types, only a type match is required. */ -+ return data->ut_type == last_entry.ut_type; -+ else -+ /* For the process-related entries, a full match is needed. */ -+ return __utmp_equal (&last_entry, data); -+} - - /* Locking timeout. */ - #ifndef TIMEOUT -@@ -52,90 +71,70 @@ static struct utmp last_entry; - /* Do-nothing handler for locking timeout. */ - static void timeout_handler (int signum) {}; - --/* LOCK_FILE(fd, type) failure_statement -- attempts to get a lock on the utmp file referenced by FD. If it fails, -- the failure_statement is executed, otherwise it is skipped. -- LOCKING_FAILED() -- jumps into the UNLOCK_FILE macro and ensures cleanup of LOCK_FILE. -- UNLOCK_FILE(fd) -- unlocks the utmp file referenced by FD and performs the cleanup of -- LOCK_FILE. -- */ --#define LOCK_FILE(fd, type) \ --{ \ -- struct flock fl; \ -- struct sigaction action, old_action; \ -- unsigned int old_timeout; \ -- \ -- /* Cancel any existing alarm. */ \ -- old_timeout = alarm (0); \ -- \ -- /* Establish signal handler. */ \ -- action.sa_handler = timeout_handler; \ -- __sigemptyset (&action.sa_mask); \ -- action.sa_flags = 0; \ -- __sigaction (SIGALRM, &action, &old_action); \ -- \ -- alarm (TIMEOUT); \ -- \ -- /* Try to get the lock. */ \ -- memset (&fl, '\0', sizeof (struct flock)); \ -- fl.l_type = (type); \ -- fl.l_whence = SEEK_SET; \ -- if (__fcntl64_nocancel ((fd), F_SETLKW, &fl) < 0) -- --#define LOCKING_FAILED() \ -- goto unalarm_return -- --#define UNLOCK_FILE(fd) \ -- /* Unlock the file. */ \ -- fl.l_type = F_UNLCK; \ -- __fcntl64_nocancel ((fd), F_SETLKW, &fl); \ -- \ -- unalarm_return: \ -- /* Reset the signal handler and alarm. We must reset the alarm \ -- before resetting the handler so our alarm does not generate a \ -- spurious SIGALRM seen by the user. However, we cannot just set \ -- the user's old alarm before restoring the handler, because then \ -- it's possible our handler could catch the user alarm's SIGARLM \ -- and then the user would never see the signal he expected. */ \ -- alarm (0); \ -- __sigaction (SIGALRM, &old_action, NULL); \ -- if (old_timeout != 0) \ -- alarm (old_timeout); \ --} while (0) -- -- --/* Functions defined here. */ --static int setutent_file (void); --static int getutent_r_file (struct utmp *buffer, struct utmp **result); --static int getutid_r_file (const struct utmp *key, struct utmp *buffer, -- struct utmp **result); --static int getutline_r_file (const struct utmp *key, struct utmp *buffer, -- struct utmp **result); --static struct utmp *pututline_file (const struct utmp *data); --static void endutent_file (void); --static int updwtmp_file (const char *file, const struct utmp *utmp); -- --/* Jump table for file functions. */ --const struct utfuncs __libc_utmp_file_functions = -+ -+/* try_file_lock (LOCKING, FD, TYPE) returns true if the locking -+ operation failed and recovery needs to be performed. -+ -+ file_unlock (FD) removes the lock (which must have been -+ successfully acquired). */ -+ -+static bool -+try_file_lock (int fd, int type) - { -- setutent_file, -- getutent_r_file, -- getutid_r_file, -- getutline_r_file, -- pututline_file, -- endutent_file, -- updwtmp_file --}; -+ /* Cancel any existing alarm. */ -+ int old_timeout = alarm (0); -+ -+ /* Establish signal handler. */ -+ struct sigaction old_action; -+ struct sigaction action; -+ action.sa_handler = timeout_handler; -+ __sigemptyset (&action.sa_mask); -+ action.sa_flags = 0; -+ __sigaction (SIGALRM, &action, &old_action); -+ -+ alarm (TIMEOUT); -+ -+ /* Try to get the lock. */ -+ struct flock64 fl = -+ { -+ .l_type = type, -+ .l_whence = SEEK_SET, -+ }; -+ -+ bool status = __fcntl64_nocancel (fd, F_SETLKW, &fl) < 0; -+ int saved_errno = errno; -+ -+ /* Reset the signal handler and alarm. We must reset the alarm -+ before resetting the handler so our alarm does not generate a -+ spurious SIGALRM seen by the user. However, we cannot just set -+ the user's old alarm before restoring the handler, because then -+ it's possible our handler could catch the user alarm's SIGARLM and -+ then the user would never see the signal he expected. */ -+ alarm (0); -+ __sigaction (SIGALRM, &old_action, NULL); -+ if (old_timeout != 0) -+ alarm (old_timeout); -+ -+ __set_errno (saved_errno); -+ return status; -+} - -+static void -+file_unlock (int fd) -+{ -+ struct flock64 fl = -+ { -+ .l_type = F_UNLCK, -+ }; -+ __fcntl64_nocancel (fd, F_SETLKW, &fl); -+} - - #ifndef TRANSFORM_UTMP_FILE_NAME - # define TRANSFORM_UTMP_FILE_NAME(file_name) (file_name) - #endif - --static int --setutent_file (void) -+int -+__libc_setutent (void) - { - if (file_fd < 0) - { -@@ -153,56 +152,68 @@ setutent_file (void) - __lseek64 (file_fd, 0, SEEK_SET); - file_offset = 0; - -- /* Make sure the entry won't match. */ --#if _HAVE_UT_TYPE - 0 -- last_entry.ut_type = -1; --#else -- last_entry.ut_line[0] = '\177'; --# if _HAVE_UT_ID - 0 -- last_entry.ut_id[0] = '\0'; --# endif --#endif -- - return 1; - } - -+/* Preform initialization if necessary. */ -+static bool -+maybe_setutent (void) -+{ -+ return file_fd >= 0 || __libc_setutent (); -+} - --static int --getutent_r_file (struct utmp *buffer, struct utmp **result) -+/* Reads the entry at file_offset, storing it in last_entry and -+ updating file_offset on success. Returns -1 for a read error, 0 -+ for EOF, and 1 for a successful read. last_entry and file_offset -+ are only updated on a successful and complete read. */ -+static ssize_t -+read_last_entry (void) - { -- ssize_t nbytes; -+ struct utmp buffer; -+ ssize_t nbytes = __pread64_nocancel (file_fd, &buffer, sizeof (buffer), -+ file_offset); -+ if (nbytes < 0) -+ return -1; -+ else if (nbytes != sizeof (buffer)) -+ /* Assume EOF. */ -+ return 0; -+ else -+ { -+ last_entry = buffer; -+ file_offset += sizeof (buffer); -+ return 1; -+ } -+} - -- assert (file_fd >= 0); -+int -+__libc_getutent_r (struct utmp *buffer, struct utmp **result) -+{ -+ int saved_errno = errno; - -- if (file_offset == -1l) -+ if (!maybe_setutent ()) - { - /* Not available. */ - *result = NULL; - return -1; - } - -- LOCK_FILE (file_fd, F_RDLCK) -- { -- nbytes = 0; -- LOCKING_FAILED (); -- } -- -- /* Read the next entry. */ -- nbytes = __read_nocancel (file_fd, &last_entry, sizeof (struct utmp)); -+ if (try_file_lock (file_fd, F_RDLCK)) -+ return -1; - -- UNLOCK_FILE (file_fd); -+ ssize_t nbytes = read_last_entry (); -+ file_unlock (file_fd); - -- if (nbytes != sizeof (struct utmp)) -+ if (nbytes <= 0) /* Read error or EOF. */ - { -- if (nbytes != 0) -- file_offset = -1l; -+ if (nbytes == 0) -+ /* errno should be unchanged to indicate success. A premature -+ EOF is treated like an EOF (missing complete record at the -+ end). */ -+ __set_errno (saved_errno); - *result = NULL; - return -1; - } - -- /* Update position pointer. */ -- file_offset += sizeof (struct utmp); -- - memcpy (buffer, &last_entry, sizeof (struct utmp)); - *result = buffer; - -@@ -210,82 +221,55 @@ getutent_r_file (struct utmp *buffer, struct utmp **result) - } - - -+/* Search for *ID, updating last_entry and file_offset. Return 0 on -+ success and -1 on failure. Does not perform locking; for that see -+ internal_getut_r below. */ - static int --internal_getut_r (const struct utmp *id, struct utmp *buffer, -- bool *lock_failed) -+internal_getut_nolock (const struct utmp *id) - { -- int result = -1; -- -- LOCK_FILE (file_fd, F_RDLCK) -- { -- *lock_failed = true; -- LOCKING_FAILED (); -- } -- --#if _HAVE_UT_TYPE - 0 -- if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME -- || id->ut_type == OLD_TIME || id->ut_type == NEW_TIME) -+ while (1) - { -- /* Search for next entry with type RUN_LVL, BOOT_TIME, -- OLD_TIME, or NEW_TIME. */ -- -- while (1) -+ ssize_t nbytes = read_last_entry (); -+ if (nbytes < 0) -+ return -1; -+ if (nbytes == 0) - { -- /* Read the next entry. */ -- if (__read_nocancel (file_fd, buffer, sizeof (struct utmp)) -- != sizeof (struct utmp)) -- { -- __set_errno (ESRCH); -- file_offset = -1l; -- goto unlock_return; -- } -- file_offset += sizeof (struct utmp); -- -- if (id->ut_type == buffer->ut_type) -- break; -+ /* End of file reached. */ -+ __set_errno (ESRCH); -+ return -1; - } -- } -- else --#endif /* _HAVE_UT_TYPE */ -- { -- /* Search for the next entry with the specified ID and with type -- INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS. */ - -- while (1) -- { -- /* Read the next entry. */ -- if (__read_nocancel (file_fd, buffer, sizeof (struct utmp)) -- != sizeof (struct utmp)) -- { -- __set_errno (ESRCH); -- file_offset = -1l; -- goto unlock_return; -- } -- file_offset += sizeof (struct utmp); -- -- if (__utmp_equal (buffer, id)) -- break; -- } -+ if (matches_last_entry (id)) -+ break; - } - -- result = 0; -+ return 0; -+} - --unlock_return: -- UNLOCK_FILE (file_fd); -+/* Search for *ID, updating last_entry and file_offset. Return 0 on -+ success and -1 on failure. If the locking operation failed, write -+ true to *LOCK_FAILED. */ -+static int -+internal_getut_r (const struct utmp *id, bool *lock_failed) -+{ -+ if (try_file_lock (file_fd, F_RDLCK)) -+ { -+ *lock_failed = true; -+ return -1; -+ } - -+ int result = internal_getut_nolock (id); -+ file_unlock (file_fd); - return result; - } - -- - /* For implementing this function we don't use the getutent_r function - because we can avoid the reposition on every new entry this way. */ --static int --getutid_r_file (const struct utmp *id, struct utmp *buffer, -- struct utmp **result) -+int -+__libc_getutid_r (const struct utmp *id, struct utmp *buffer, -+ struct utmp **result) - { -- assert (file_fd >= 0); -- -- if (file_offset == -1l) -+ if (!maybe_setutent ()) - { - *result = NULL; - return -1; -@@ -294,7 +278,7 @@ getutid_r_file (const struct utmp *id, struct utmp *buffer, - /* We don't have to distinguish whether we can lock the file or - whether there is no entry. */ - bool lock_failed = false; -- if (internal_getut_r (id, &last_entry, &lock_failed) < 0) -+ if (internal_getut_r (id, &lock_failed) < 0) - { - *result = NULL; - return -1; -@@ -306,69 +290,65 @@ getutid_r_file (const struct utmp *id, struct utmp *buffer, - return 0; - } - -- - /* For implementing this function we don't use the getutent_r function - because we can avoid the reposition on every new entry this way. */ --static int --getutline_r_file (const struct utmp *line, struct utmp *buffer, -- struct utmp **result) -+int -+__libc_getutline_r (const struct utmp *line, struct utmp *buffer, -+ struct utmp **result) - { -- assert (file_fd >= 0); -- -- if (file_offset == -1l) -+ if (!maybe_setutent ()) - { - *result = NULL; - return -1; - } - -- LOCK_FILE (file_fd, F_RDLCK) -+ if (try_file_lock (file_fd, F_RDLCK)) - { - *result = NULL; -- LOCKING_FAILED (); -+ return -1; - } - - while (1) - { -- /* Read the next entry. */ -- if (__read_nocancel (file_fd, &last_entry, sizeof (struct utmp)) -- != sizeof (struct utmp)) -+ ssize_t nbytes = read_last_entry (); -+ if (nbytes < 0) -+ { -+ file_unlock (file_fd); -+ *result = NULL; -+ return -1; -+ } -+ if (nbytes == 0) - { -+ /* End of file reached. */ -+ file_unlock (file_fd); - __set_errno (ESRCH); -- file_offset = -1l; - *result = NULL; -- goto unlock_return; -+ return -1; - } -- file_offset += sizeof (struct utmp); - - /* Stop if we found a user or login entry. */ -- if ( --#if _HAVE_UT_TYPE - 0 -- (last_entry.ut_type == USER_PROCESS -+ if ((last_entry.ut_type == USER_PROCESS - || last_entry.ut_type == LOGIN_PROCESS) -- && --#endif -- !strncmp (line->ut_line, last_entry.ut_line, sizeof line->ut_line)) -+ && (strncmp (line->ut_line, last_entry.ut_line, sizeof line->ut_line) -+ == 0)) - break; - } - -+ file_unlock (file_fd); - memcpy (buffer, &last_entry, sizeof (struct utmp)); - *result = buffer; - --unlock_return: -- UNLOCK_FILE (file_fd); -- -- return ((*result == NULL) ? -1 : 0); -+ return 0; - } - - --static struct utmp * --pututline_file (const struct utmp *data) -+struct utmp * -+__libc_pututline (const struct utmp *data) - { -- struct utmp buffer; -- struct utmp *pbuf; -- int found; -+ if (!maybe_setutent ()) -+ return NULL; - -- assert (file_fd >= 0); -+ struct utmp *pbuf; - - if (! file_writable) - { -@@ -380,8 +360,7 @@ pututline_file (const struct utmp *data) - if (new_fd == -1) - return NULL; - -- if (__lseek64 (new_fd, __lseek64 (file_fd, 0, SEEK_CUR), SEEK_SET) == -1 -- || __dup2 (new_fd, file_fd) < 0) -+ if (__dup2 (new_fd, file_fd) < 0) - { - __close_nocancel_nostatus (new_fd); - return NULL; -@@ -390,95 +369,96 @@ pututline_file (const struct utmp *data) - file_writable = true; - } - -+ /* Exclude other writers before validating the cache. */ -+ if (try_file_lock (file_fd, F_WRLCK)) -+ return NULL; -+ - /* Find the correct place to insert the data. */ -- if (file_offset > 0 -- && ( --#if _HAVE_UT_TYPE - 0 -- (last_entry.ut_type == data->ut_type -- && (last_entry.ut_type == RUN_LVL -- || last_entry.ut_type == BOOT_TIME -- || last_entry.ut_type == OLD_TIME -- || last_entry.ut_type == NEW_TIME)) -- || --#endif -- __utmp_equal (&last_entry, data))) -- found = 1; -- else -+ bool found = false; -+ if (matches_last_entry (data)) - { -- bool lock_failed = false; -- found = internal_getut_r (data, &buffer, &lock_failed); -- -- if (__builtin_expect (lock_failed, false)) -+ /* Read back the entry under the write lock. */ -+ file_offset -= sizeof (last_entry); -+ ssize_t nbytes = read_last_entry (); -+ if (nbytes < 0) - { -- __set_errno (EAGAIN); -+ file_unlock (file_fd); - return NULL; - } -- } - -- LOCK_FILE (file_fd, F_WRLCK) -- { -- pbuf = NULL; -- LOCKING_FAILED (); -+ if (nbytes == 0) -+ /* End of file reached. */ -+ found = false; -+ else -+ found = matches_last_entry (data); - } - -- if (found < 0) -+ if (!found) -+ /* Search forward for the entry. */ -+ found = internal_getut_nolock (data) >= 0; -+ -+ off64_t write_offset; -+ if (!found) - { - /* We append the next entry. */ -- file_offset = __lseek64 (file_fd, 0, SEEK_END); -- if (file_offset % sizeof (struct utmp) != 0) -- { -- file_offset -= file_offset % sizeof (struct utmp); -- __ftruncate64 (file_fd, file_offset); -- -- if (__lseek64 (file_fd, 0, SEEK_END) < 0) -- { -- pbuf = NULL; -- goto unlock_return; -- } -- } -+ write_offset = __lseek64 (file_fd, 0, SEEK_END); -+ -+ /* Round down to the next multiple of the entry size. This -+ ensures any partially-written record is overwritten by the -+ new record. */ -+ write_offset = (write_offset / sizeof (struct utmp) -+ * sizeof (struct utmp)); - } - else -+ /* Overwrite last_entry. */ -+ write_offset = file_offset - sizeof (struct utmp); -+ -+ /* Write the new data. */ -+ ssize_t nbytes; -+ if (__lseek64 (file_fd, write_offset, SEEK_SET) < 0 -+ || (nbytes = __write_nocancel (file_fd, data, sizeof (struct utmp))) < 0) - { -- /* We replace the just read entry. */ -- file_offset -= sizeof (struct utmp); -- __lseek64 (file_fd, file_offset, SEEK_SET); -+ /* There is no need to recover the file position because all -+ reads use pread64, and any future write is preceded by -+ another seek. */ -+ file_unlock (file_fd); -+ return NULL; - } - -- /* Write the new data. */ -- if (__write_nocancel (file_fd, data, sizeof (struct utmp)) -- != sizeof (struct utmp)) -+ if (nbytes != sizeof (struct utmp)) - { - /* If we appended a new record this is only partially written. - Remove it. */ -- if (found < 0) -- (void) __ftruncate64 (file_fd, file_offset); -- pbuf = NULL; -- } -- else -- { -- file_offset += sizeof (struct utmp); -- pbuf = (struct utmp *) data; -+ if (!found) -+ (void) __ftruncate64 (file_fd, write_offset); -+ file_unlock (file_fd); -+ /* Assume that the write failure was due to missing disk -+ space. */ -+ __set_errno (ENOSPC); -+ return NULL; - } - -- unlock_return: -- UNLOCK_FILE (file_fd); -+ file_unlock (file_fd); -+ file_offset = write_offset + sizeof (struct utmp); -+ pbuf = (struct utmp *) data; - - return pbuf; - } - - --static void --endutent_file (void) -+void -+__libc_endutent (void) - { -- assert (file_fd >= 0); -- -- __close_nocancel_nostatus (file_fd); -- file_fd = -1; -+ if (file_fd >= 0) -+ { -+ __close_nocancel_nostatus (file_fd); -+ file_fd = -1; -+ } - } - - --static int --updwtmp_file (const char *file, const struct utmp *utmp) -+int -+__libc_updwtmp (const char *file, const struct utmp *utmp) - { - int result = -1; - off64_t offset; -@@ -489,8 +469,11 @@ updwtmp_file (const char *file, const struct utmp *utmp) - if (fd < 0) - return -1; - -- LOCK_FILE (fd, F_WRLCK) -- LOCKING_FAILED (); -+ if (try_file_lock (fd, F_WRLCK)) -+ { -+ __close_nocancel_nostatus (fd); -+ return -1; -+ } - - /* Remember original size of log file. */ - offset = __lseek64 (fd, 0, SEEK_END); -@@ -516,7 +499,7 @@ updwtmp_file (const char *file, const struct utmp *utmp) - result = 0; - - unlock_return: -- UNLOCK_FILE (fd); -+ file_unlock (fd); - - /* Close WTMP file. */ - __close_nocancel_nostatus (fd); -diff --git a/login/utmpname.c b/login/utmpname.c -index c3da183d5b..8f94b19caf 100644 ---- a/login/utmpname.c -+++ b/login/utmpname.c -@@ -42,8 +42,7 @@ __utmpname (const char *file) - __libc_lock_lock (__libc_utmp_lock); - - /* Close the old file. */ -- (*__libc_utmp_jump_table->endutent) (); -- __libc_utmp_jump_table = &__libc_utmp_unknown_functions; -+ __libc_endutent (); - - if (strcmp (file, __libc_utmp_file_name) != 0) - { -diff --git a/malloc/Makefile b/malloc/Makefile -index d2fba29953..9698574bba 100644 ---- a/malloc/Makefile -+++ b/malloc/Makefile -@@ -27,7 +27,7 @@ headers := $(dist-headers) obstack.h mcheck.h - tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \ - tst-mcheck tst-mallocfork tst-trim1 \ - tst-malloc-usable tst-realloc tst-reallocarray tst-posix_memalign \ -- tst-pvalloc tst-memalign tst-mallopt \ -+ tst-pvalloc tst-pvalloc-fortify tst-memalign tst-mallopt \ - tst-malloc-backtrace tst-malloc-thread-exit \ - tst-malloc-thread-fail tst-malloc-fork-deadlock \ - tst-mallocfork2 \ -@@ -54,7 +54,7 @@ tests-internal += \ - tst-dynarray-at-fail \ - - ifneq (no,$(have-tunables)) --tests += tst-malloc-usable-tunables -+tests += tst-malloc-usable-tunables tst-mxfast - tests-static += tst-malloc-usable-static-tunables - endif - -@@ -196,6 +196,8 @@ tst-malloc-usable-static-ENV = $(tst-malloc-usable-ENV) - tst-malloc-usable-tunables-ENV = GLIBC_TUNABLES=glibc.malloc.check=3 - tst-malloc-usable-static-tunables-ENV = $(tst-malloc-usable-tunables-ENV) - -+tst-mxfast-ENV = GLIBC_TUNABLES=glibc.malloc.tcache_count=0:glibc.malloc.mxfast=0 -+ - ifeq ($(experimental-malloc),yes) - CPPFLAGS-malloc.c += -DUSE_TCACHE=1 - else -diff --git a/malloc/arena.c b/malloc/arena.c -index 8309c1334c..a32eb403ec 100644 ---- a/malloc/arena.c -+++ b/malloc/arena.c -@@ -236,6 +236,7 @@ TUNABLE_CALLBACK_FNDECL (set_tcache_max, size_t) - TUNABLE_CALLBACK_FNDECL (set_tcache_count, size_t) - TUNABLE_CALLBACK_FNDECL (set_tcache_unsorted_limit, size_t) - #endif -+TUNABLE_CALLBACK_FNDECL (set_mxfast, size_t) - #else - /* Initialization routine. */ - #include <string.h> -@@ -323,6 +324,7 @@ ptmalloc_init (void) - TUNABLE_GET (tcache_unsorted_limit, size_t, - TUNABLE_CALLBACK (set_tcache_unsorted_limit)); - # endif -+ TUNABLE_GET (mxfast, size_t, TUNABLE_CALLBACK (set_mxfast)); - #else - const char *s = NULL; - if (__glibc_likely (_environ != NULL)) -diff --git a/malloc/malloc.c b/malloc/malloc.c -index 00ce48cf58..8c68b21b2b 100644 ---- a/malloc/malloc.c -+++ b/malloc/malloc.c -@@ -1621,7 +1621,7 @@ static INTERNAL_SIZE_T global_max_fast; - - #define set_max_fast(s) \ - global_max_fast = (((s) == 0) \ -- ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK)) -+ ? MIN_CHUNK_SIZE / 2 : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK)) - - static inline INTERNAL_SIZE_T - get_max_fast (void) -@@ -5115,6 +5115,19 @@ do_set_tcache_unsorted_limit (size_t value) - } - #endif - -+static inline int -+__always_inline -+do_set_mxfast (size_t value) -+{ -+ if (value >= 0 && value <= MAX_FAST_SIZE) -+ { -+ LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ()); -+ set_max_fast (value); -+ return 1; -+ } -+ return 0; -+} -+ - int - __libc_mallopt (int param_number, int value) - { -@@ -5134,13 +5147,7 @@ __libc_mallopt (int param_number, int value) - switch (param_number) - { - case M_MXFAST: -- if (value >= 0 && value <= MAX_FAST_SIZE) -- { -- LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ()); -- set_max_fast (value); -- } -- else -- res = 0; -+ do_set_mxfast (value); - break; - - case M_TRIM_THRESHOLD: -@@ -5406,6 +5413,12 @@ __malloc_info (int options, FILE *fp) - - __libc_lock_lock (ar_ptr->mutex); - -+ /* Account for top chunk. The top-most available chunk is -+ treated specially and is never in any bin. See "initial_top" -+ comments. */ -+ avail = chunksize (ar_ptr->top); -+ nblocks = 1; /* Top always exists. */ -+ - for (size_t i = 0; i < NFASTBINS; ++i) - { - mchunkptr p = fastbin (ar_ptr, i); -@@ -5491,7 +5504,7 @@ __malloc_info (int options, FILE *fp) - - for (size_t i = 0; i < nsizes; ++i) - if (sizes[i].count != 0 && i != NFASTBINS) -- fprintf (fp, " \ -+ fprintf (fp, "\ - <size from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n", - sizes[i].from, sizes[i].to, sizes[i].total, sizes[i].count); - -diff --git a/malloc/malloc.h b/malloc/malloc.h -index 70d8282bdc..f62c6c594c 100644 ---- a/malloc/malloc.h -+++ b/malloc/malloc.h -@@ -71,8 +71,7 @@ extern void *valloc (size_t __size) __THROW __attribute_malloc__ - - /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up - __size to nearest pagesize. */ --extern void *pvalloc (size_t __size) __THROW __attribute_malloc__ -- __attribute_alloc_size__ ((1)) __wur; -+extern void *pvalloc (size_t __size) __THROW __attribute_malloc__ __wur; - - /* Underlying allocation function; successive calls should return - contiguous pieces of memory. */ -diff --git a/malloc/tst-mxfast.c b/malloc/tst-mxfast.c -new file mode 100644 -index 0000000000..7a7750bc71 ---- /dev/null -+++ b/malloc/tst-mxfast.c -@@ -0,0 +1,50 @@ -+/* Test that glibc.malloc.mxfast tunable works. -+ Copyright (C) 2019 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+/* This test verifies that setting the glibc.malloc.mxfast tunable to -+ zero results in free'd blocks being returned to the small bins, not -+ the fast bins. */ -+ -+#include <malloc.h> -+#include <support/check.h> -+ -+int -+do_test (void) -+{ -+ struct mallinfo m; -+ char *volatile p1; -+ char *volatile p2; -+ -+ /* Arbitrary value; must be in default fastbin range. */ -+ p1 = malloc (3); -+ /* Something large so that p1 isn't a "top block" */ -+ p2 = malloc (512); -+ free (p1); -+ -+ m = mallinfo (); -+ -+ /* This will fail if there are any blocks in the fastbins. */ -+ TEST_COMPARE (m.smblks, 0); -+ -+ /* To keep gcc happy. */ -+ free (p2); -+ -+ return 0; -+} -+ -+#include <support/test-driver.c> -diff --git a/malloc/tst-pvalloc-fortify.c b/malloc/tst-pvalloc-fortify.c -new file mode 100644 -index 0000000000..391b7fa2f5 ---- /dev/null -+++ b/malloc/tst-pvalloc-fortify.c -@@ -0,0 +1,48 @@ -+/* Test fortify-source allocation size handling in pvalloc (bug 25401). -+ Copyright (C) 2020 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; see the file COPYING.LIB. If -+ not, see <https://www.gnu.org/licenses/>. */ -+ -+#undef _FORTIFY_SOURCE -+#define _FORTIFY_SOURCE 2 -+#include <malloc.h> -+#include <string.h> -+#include <support/check.h> -+#include <support/xunistd.h> -+#include <unistd.h> -+ -+static int -+do_test (void) -+{ -+ /* The test below assumes that pvalloc rounds up the allocation size -+ to at least 8. */ -+ TEST_VERIFY (xsysconf (_SC_PAGESIZE) >= 8); -+ -+ void *p = pvalloc (5); -+ TEST_VERIFY_EXIT (p != NULL); -+ -+ /* This is valid assuming the page size is at least 8 because -+ pvalloc rounds up the allocation size to a multiple of the page -+ size. Due to bug 25041, this used to trigger a compiler -+ warning. */ -+ strcpy (p, "abcdefg"); -+ -+ asm ("" : : "g" (p) : "memory"); /* Optimization barrier. */ -+ TEST_VERIFY (malloc_usable_size (p) >= xsysconf (_SC_PAGESIZE)); -+ return 0; -+} -+ -+#include <support/test-driver.c> -diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h -index f1bd994a10..b1695376dc 100644 ---- a/misc/sys/cdefs.h -+++ b/misc/sys/cdefs.h -@@ -412,14 +412,6 @@ - # define __glibc_has_attribute(attr) 0 - #endif - --#ifdef __has_include --/* Do not use a function-like macro, so that __has_include can inhibit -- macro expansion. */ --# define __glibc_has_include __has_include --#else --# define __glibc_has_include(header) 0 --#endif -- - #if (!defined _Noreturn \ - && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ - && !__GNUC_PREREQ (4,7)) -diff --git a/string/string.h b/string/string.h -index c38eea971f..608ed496b9 100644 ---- a/string/string.h -+++ b/string/string.h -@@ -33,7 +33,8 @@ __BEGIN_DECLS - #include <stddef.h> - - /* Tell the caller that we provide correct C++ prototypes. */ --#if defined __cplusplus && __GNUC_PREREQ (4, 4) -+#if defined __cplusplus && (__GNUC_PREREQ (4, 4) \ -+ || __glibc_clang_prereq (3, 5)) - # define __CORRECT_ISO_CPP_STRING_H_PROTO - #endif - -diff --git a/string/test-strstr.c b/string/test-strstr.c -index df6dbc251e..daed9a2705 100644 ---- a/string/test-strstr.c -+++ b/string/test-strstr.c -@@ -139,16 +139,45 @@ check1 (void) - static void - check2 (void) - { -- const char s1[] = ", enable_static, \0, enable_shared, "; -+ const char s1_stack[] = ", enable_static, \0, enable_shared, "; -+ const size_t s1_byte_count = 18; -+ const char *s2_stack = &(s1_stack[s1_byte_count]); -+ const size_t s2_byte_count = 18; - char *exp_result; -- char *s2 = (void *) buf1 + page_size - 18; -+ const size_t page_size_real = getpagesize (); - -- strcpy (s2, s1); -- exp_result = stupid_strstr (s1, s1 + 18); -+ /* Haystack at end of page. The following page is protected. */ -+ char *s1_page_end = (void *) buf1 + page_size - s1_byte_count; -+ strcpy (s1_page_end, s1_stack); -+ -+ /* Haystack which crosses a page boundary. -+ Note: page_size is at least 2 * getpagesize. See test_init. */ -+ char *s1_page_cross = (void *) buf1 + page_size_real - 8; -+ strcpy (s1_page_cross, s1_stack); -+ -+ /* Needle at end of page. The following page is protected. */ -+ char *s2_page_end = (void *) buf2 + page_size - s2_byte_count; -+ strcpy (s2_page_end, s2_stack); -+ -+ /* Needle which crosses a page boundary. -+ Note: page_size is at least 2 * getpagesize. See test_init. */ -+ char *s2_page_cross = (void *) buf2 + page_size_real - 8; -+ strcpy (s2_page_cross, s2_stack); -+ -+ exp_result = stupid_strstr (s1_stack, s2_stack); - FOR_EACH_IMPL (impl, 0) - { -- check_result (impl, s1, s1 + 18, exp_result); -- check_result (impl, s2, s1 + 18, exp_result); -+ check_result (impl, s1_stack, s2_stack, exp_result); -+ check_result (impl, s1_stack, s2_page_end, exp_result); -+ check_result (impl, s1_stack, s2_page_cross, exp_result); -+ -+ check_result (impl, s1_page_end, s2_stack, exp_result); -+ check_result (impl, s1_page_end, s2_page_end, exp_result); -+ check_result (impl, s1_page_end, s2_page_cross, exp_result); -+ -+ check_result (impl, s1_page_cross, s2_stack, exp_result); -+ check_result (impl, s1_page_cross, s2_page_end, exp_result); -+ check_result (impl, s1_page_cross, s2_page_cross, exp_result); - } - } - -diff --git a/sysdeps/alpha/fpu/libm-test-ulps b/sysdeps/alpha/fpu/libm-test-ulps -index 0f77dd2ed0..89c4527a81 100644 ---- a/sysdeps/alpha/fpu/libm-test-ulps -+++ b/sysdeps/alpha/fpu/libm-test-ulps -@@ -1084,10 +1084,10 @@ ildouble: 1 - ldouble: 1 - - Function: Real part of "cpow_downward": --double: 2 --float: 4 --idouble: 2 --ifloat: 4 -+double: 5 -+float: 8 -+idouble: 5 -+ifloat: 8 - ildouble: 6 - ldouble: 6 - -@@ -1100,10 +1100,10 @@ ildouble: 2 - ldouble: 2 - - Function: Real part of "cpow_towardzero": --double: 2 --float: 4 --idouble: 2 --ifloat: 4 -+double: 5 -+float: 8 -+idouble: 5 -+ifloat: 8 - ildouble: 6 - ldouble: 6 - -diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h -index f3d862651e..724c3e5e71 100644 ---- a/sysdeps/generic/not-cancel.h -+++ b/sysdeps/generic/not-cancel.h -@@ -41,6 +41,8 @@ - (void) __close (fd) - #define __read_nocancel(fd, buf, n) \ - __read (fd, buf, n) -+#define __pread64_nocancel(fd, buf, count, offset) \ -+ __pread64 (fd, buf, count, offset) - #define __write_nocancel(fd, buf, n) \ - __write (fd, buf, n) - #define __writev_nocancel_nostatus(fd, iov, n) \ -diff --git a/sysdeps/generic/utmp-equal.h b/sysdeps/generic/utmp-equal.h -index d077147a7a..d61cbb3300 100644 ---- a/sysdeps/generic/utmp-equal.h -+++ b/sysdeps/generic/utmp-equal.h -@@ -27,26 +27,16 @@ - static int - __utmp_equal (const struct utmp *entry, const struct utmp *match) - { -- return -- ( --#if _HAVE_UT_TYPE - 0 -- (entry->ut_type == INIT_PROCESS -- || entry->ut_type == LOGIN_PROCESS -- || entry->ut_type == USER_PROCESS -- || entry->ut_type == DEAD_PROCESS) -- && -- (match->ut_type == INIT_PROCESS -- || match->ut_type == LOGIN_PROCESS -- || match->ut_type == USER_PROCESS -- || match->ut_type == DEAD_PROCESS) -- && --#endif --#if _HAVE_UT_ID - 0 -- (entry->ut_id[0] && match->ut_id[0] -- ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0 -- : strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0) --#else -- strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0 --#endif -- ); -+ return (entry->ut_type == INIT_PROCESS -+ || entry->ut_type == LOGIN_PROCESS -+ || entry->ut_type == USER_PROCESS -+ || entry->ut_type == DEAD_PROCESS) -+ && (match->ut_type == INIT_PROCESS -+ || match->ut_type == LOGIN_PROCESS -+ || match->ut_type == USER_PROCESS -+ || match->ut_type == DEAD_PROCESS) -+ && (entry->ut_id[0] && match->ut_id[0] -+ ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0 -+ : (strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) -+ == 0)); - } -diff --git a/sysdeps/gnu/bits/utmp.h b/sysdeps/gnu/bits/utmp.h -deleted file mode 100644 -index 7357034cb6..0000000000 ---- a/sysdeps/gnu/bits/utmp.h -+++ /dev/null -@@ -1,126 +0,0 @@ --/* The `struct utmp' type, describing entries in the utmp file. GNU version. -- Copyright (C) 1993-2019 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 -- <http://www.gnu.org/licenses/>. */ -- --#ifndef _UTMP_H --# error "Never include <bits/utmp.h> directly; use <utmp.h> instead." --#endif -- --#include <paths.h> --#include <sys/time.h> --#include <sys/types.h> --#include <bits/wordsize.h> -- -- --#define UT_LINESIZE 32 --#define UT_NAMESIZE 32 --#define UT_HOSTSIZE 256 -- -- --/* The structure describing an entry in the database of -- previous logins. */ --struct lastlog -- { --#if __WORDSIZE_TIME64_COMPAT32 -- int32_t ll_time; --#else -- __time_t ll_time; --#endif -- char ll_line[UT_LINESIZE]; -- char ll_host[UT_HOSTSIZE]; -- }; -- -- --/* The structure describing the status of a terminated process. This -- type is used in `struct utmp' below. */ --struct exit_status -- { -- short int e_termination; /* Process termination status. */ -- short int e_exit; /* Process exit status. */ -- }; -- -- --/* The structure describing an entry in the user accounting database. */ --struct utmp --{ -- short int ut_type; /* Type of login. */ -- pid_t ut_pid; /* Process ID of login process. */ -- char ut_line[UT_LINESIZE] -- __attribute_nonstring__; /* Devicename. */ -- char ut_id[4]; /* Inittab ID. */ -- char ut_user[UT_NAMESIZE] -- __attribute_nonstring__; /* Username. */ -- char ut_host[UT_HOSTSIZE] -- __attribute_nonstring__; /* Hostname for remote login. */ -- struct exit_status ut_exit; /* Exit status of a process marked -- as DEAD_PROCESS. */ --/* The ut_session and ut_tv fields must be the same size when compiled -- 32- and 64-bit. This allows data files and shared memory to be -- shared between 32- and 64-bit applications. */ --#if __WORDSIZE_TIME64_COMPAT32 -- int32_t ut_session; /* Session ID, used for windowing. */ -- struct -- { -- int32_t tv_sec; /* Seconds. */ -- int32_t tv_usec; /* Microseconds. */ -- } ut_tv; /* Time entry was made. */ --#else -- long int ut_session; /* Session ID, used for windowing. */ -- struct timeval ut_tv; /* Time entry was made. */ --#endif -- -- int32_t ut_addr_v6[4]; /* Internet address of remote host. */ -- char __glibc_reserved[20]; /* Reserved for future use. */ --}; -- --/* Backwards compatibility hacks. */ --#define ut_name ut_user --#ifndef _NO_UT_TIME --/* We have a problem here: `ut_time' is also used otherwise. Define -- _NO_UT_TIME if the compiler complains. */ --# define ut_time ut_tv.tv_sec --#endif --#define ut_xtime ut_tv.tv_sec --#define ut_addr ut_addr_v6[0] -- -- --/* Values for the `ut_type' field of a `struct utmp'. */ --#define EMPTY 0 /* No valid user accounting information. */ -- --#define RUN_LVL 1 /* The system's runlevel. */ --#define BOOT_TIME 2 /* Time of system boot. */ --#define NEW_TIME 3 /* Time after system clock changed. */ --#define OLD_TIME 4 /* Time when system clock changed. */ -- --#define INIT_PROCESS 5 /* Process spawned by the init process. */ --#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ --#define USER_PROCESS 7 /* Normal process. */ --#define DEAD_PROCESS 8 /* Terminated process. */ -- --#define ACCOUNTING 9 -- --/* Old Linux name for the EMPTY type. */ --#define UT_UNKNOWN EMPTY -- -- --/* Tell the user that we have a modern system with UT_HOST, UT_PID, -- UT_TYPE, UT_ID and UT_TV fields. */ --#define _HAVE_UT_TYPE 1 --#define _HAVE_UT_PID 1 --#define _HAVE_UT_ID 1 --#define _HAVE_UT_TV 1 --#define _HAVE_UT_HOST 1 -diff --git a/sysdeps/gnu/bits/utmpx.h b/sysdeps/gnu/bits/utmpx.h -index 472a7d57d3..2beadbf587 100644 ---- a/sysdeps/gnu/bits/utmpx.h -+++ b/sysdeps/gnu/bits/utmpx.h -@@ -56,10 +56,14 @@ struct utmpx - { - short int ut_type; /* Type of login. */ - __pid_t ut_pid; /* Process ID of login process. */ -- char ut_line[__UT_LINESIZE]; /* Devicename. */ -- char ut_id[4]; /* Inittab ID. */ -- char ut_user[__UT_NAMESIZE]; /* Username. */ -- char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */ -+ char ut_line[__UT_LINESIZE] -+ __attribute_nonstring__; /* Devicename. */ -+ char ut_id[4] -+ __attribute_nonstring__; /* Inittab ID. */ -+ char ut_user[__UT_NAMESIZE] -+ __attribute_nonstring__; /* Username. */ -+ char ut_host[__UT_HOSTSIZE] -+ __attribute_nonstring__; /* Hostname for remote login. */ - struct __exit_status ut_exit; /* Exit status of a process marked - as DEAD_PROCESS. */ - -diff --git a/sysdeps/hppa/fpu/libm-test-ulps b/sysdeps/hppa/fpu/libm-test-ulps -index d0c4dea001..2c61a7ae91 100644 ---- a/sysdeps/hppa/fpu/libm-test-ulps -+++ b/sysdeps/hppa/fpu/libm-test-ulps -@@ -544,9 +544,9 @@ idouble: 1 - ifloat: 1 - - Function: Imaginary part of "ccos_downward": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Real part of "ccos_towardzero": -@@ -556,9 +556,9 @@ idouble: 1 - ifloat: 2 - - Function: Imaginary part of "ccos_towardzero": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Real part of "ccos_upward": -@@ -588,27 +588,27 @@ idouble: 1 - ifloat: 1 - - Function: Real part of "ccosh_downward": --double: 1 -+double: 2 - float: 3 --idouble: 1 -+idouble: 2 - ifloat: 3 - - Function: Imaginary part of "ccosh_downward": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Real part of "ccosh_towardzero": --double: 1 -+double: 2 - float: 3 --idouble: 1 -+idouble: 2 - ifloat: 3 - - Function: Imaginary part of "ccosh_towardzero": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Real part of "ccosh_upward": -@@ -636,27 +636,27 @@ idouble: 1 - ifloat: 2 - - Function: Real part of "cexp_downward": --double: 1 -+double: 2 - float: 2 --idouble: 1 -+idouble: 2 - ifloat: 2 - - Function: Imaginary part of "cexp_downward": --double: 1 -+double: 3 - float: 3 --idouble: 1 -+idouble: 3 - ifloat: 3 - - Function: Real part of "cexp_towardzero": --double: 1 -+double: 2 - float: 2 --idouble: 1 -+idouble: 2 - ifloat: 2 - - Function: Imaginary part of "cexp_towardzero": --double: 1 -+double: 3 - float: 3 --idouble: 1 -+idouble: 3 - ifloat: 3 - - Function: Real part of "cexp_upward": -@@ -666,9 +666,9 @@ idouble: 1 - ifloat: 2 - - Function: Imaginary part of "cexp_upward": --double: 1 -+double: 3 - float: 2 --idouble: 1 -+idouble: 3 - ifloat: 2 - - Function: Real part of "clog": -@@ -800,21 +800,21 @@ idouble: 1 - ifloat: 1 - - Function: "cosh_downward": --double: 1 -+double: 2 - float: 1 --idouble: 1 -+idouble: 2 - ifloat: 1 - - Function: "cosh_towardzero": --double: 1 -+double: 2 - float: 1 --idouble: 1 -+idouble: 2 - ifloat: 1 - - Function: "cosh_upward": --double: 1 -+double: 2 - float: 2 --idouble: 1 -+idouble: 2 - ifloat: 2 - - Function: Real part of "cpow": -@@ -834,9 +834,9 @@ ildouble: 2 - ldouble: 2 - - Function: Real part of "cpow_downward": --double: 4 -+double: 5 - float: 8 --idouble: 4 -+idouble: 5 - ifloat: 8 - - Function: Imaginary part of "cpow_downward": -@@ -846,9 +846,9 @@ idouble: 2 - ifloat: 2 - - Function: Real part of "cpow_towardzero": --double: 4 -+double: 5 - float: 8 --idouble: 4 -+idouble: 5 - ifloat: 8 - - Function: Imaginary part of "cpow_towardzero": -@@ -876,9 +876,9 @@ idouble: 1 - ifloat: 1 - - Function: Real part of "csin_downward": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Imaginary part of "csin_downward": -@@ -888,9 +888,9 @@ idouble: 1 - ifloat: 2 - - Function: Real part of "csin_towardzero": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Imaginary part of "csin_towardzero": -@@ -930,9 +930,9 @@ idouble: 2 - ifloat: 2 - - Function: Imaginary part of "csinh_downward": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Real part of "csinh_towardzero": -@@ -942,9 +942,9 @@ idouble: 2 - ifloat: 2 - - Function: Imaginary part of "csinh_towardzero": --double: 2 -+double: 3 - float: 3 --idouble: 2 -+idouble: 3 - ifloat: 3 - - Function: Real part of "csinh_upward": -@@ -1172,15 +1172,15 @@ ildouble: 6 - ldouble: 6 - - Function: "exp10_downward": --double: 2 -+double: 3 - float: 1 --idouble: 2 -+idouble: 3 - ifloat: 1 - - Function: "exp10_towardzero": --double: 2 -+double: 3 - float: 1 --idouble: 2 -+idouble: 3 - ifloat: 1 - - Function: "exp10_upward": -diff --git a/sysdeps/s390/dl-procinfo.c b/sysdeps/s390/dl-procinfo.c -index 44c9901800..1307ec41de 100644 ---- a/sysdeps/s390/dl-procinfo.c -+++ b/sysdeps/s390/dl-procinfo.c -@@ -63,11 +63,11 @@ PROCINFO_CLASS const char _dl_s390_cap_flags[19][9] - #if !defined PROCINFO_DECL && defined SHARED - ._dl_s390_platforms - #else --PROCINFO_CLASS const char _dl_s390_platforms[9][7] -+PROCINFO_CLASS const char _dl_s390_platforms[10][7] - #endif - #ifndef PROCINFO_DECL - = { -- "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14" -+ "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14", "z15" - } - #endif - #if !defined SHARED || defined PROCINFO_DECL -diff --git a/sysdeps/s390/dl-procinfo.h b/sysdeps/s390/dl-procinfo.h -index 3b1f6a642b..689e961ced 100644 ---- a/sysdeps/s390/dl-procinfo.h -+++ b/sysdeps/s390/dl-procinfo.h -@@ -23,7 +23,7 @@ - - #define _DL_HWCAP_COUNT 19 - --#define _DL_PLATFORMS_COUNT 9 -+#define _DL_PLATFORMS_COUNT 10 - - /* The kernel provides up to 32 capability bits with elf_hwcap. */ - #define _DL_FIRST_PLATFORM 32 -diff --git a/sysdeps/s390/strstr-arch13.S b/sysdeps/s390/strstr-arch13.S -index 929b026adf..faa969849e 100644 ---- a/sysdeps/s390/strstr-arch13.S -+++ b/sysdeps/s390/strstr-arch13.S -@@ -164,7 +164,7 @@ ENTRY(STRSTR_ARCH13) - vfenezb %v19,%v18,%v18 /* Search zero in loaded needle bytes. */ - veclb %v19,%v21 /* Zero index <= max loaded byte index? */ - jle .Lneedle_loaded /* -> v18 contains full needle. */ -- vl %v16,0(%r3) /* Load needle beyond page boundary. */ -+ vl %v18,0(%r3) /* Load needle beyond page boundary. */ - vfenezb %v19,%v18,%v18 - j .Lneedle_loaded - END(STRSTR_ARCH13) -diff --git a/sysdeps/unix/alpha/getegid.S b/sysdeps/unix/alpha/getegid.S -deleted file mode 100644 -index 167009d17a..0000000000 ---- a/sysdeps/unix/alpha/getegid.S -+++ /dev/null -@@ -1,26 +0,0 @@ --/* Copyright (C) 1991-2019 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 -- <http://www.gnu.org/licenses/>. */ -- --#include <sysdep.h> -- -- --PSEUDO (__getegid, getxgid, 0) -- MOVE (r1, r0) -- ret --PSEUDO_END (__getegid) -- --weak_alias (__getegid, getegid) -diff --git a/sysdeps/unix/alpha/geteuid.S b/sysdeps/unix/alpha/geteuid.S -deleted file mode 100644 -index 39413779f7..0000000000 ---- a/sysdeps/unix/alpha/geteuid.S -+++ /dev/null -@@ -1,26 +0,0 @@ --/* Copyright (C) 1991-2019 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 -- <http://www.gnu.org/licenses/>. */ -- --#include <sysdep.h> -- -- --PSEUDO (__geteuid, getxuid, 0) -- MOVE (r1, r0) -- ret --PSEUDO_END (__geteuid) -- --weak_alias (__geteuid, geteuid) -diff --git a/sysdeps/unix/alpha/getppid.S b/sysdeps/unix/alpha/getppid.S -deleted file mode 100644 -index 4d291181bd..0000000000 ---- a/sysdeps/unix/alpha/getppid.S -+++ /dev/null -@@ -1,26 +0,0 @@ --/* Copyright (C) 1991-2019 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 -- <http://www.gnu.org/licenses/>. */ -- --#include <sysdep.h> -- -- --PSEUDO (__getppid, getxpid, 0) -- MOVE (r1, r0) -- ret --PSEUDO_END (__getppid) -- --weak_alias (__getppid, getppid) -diff --git a/sysdeps/unix/getlogin_r.c b/sysdeps/unix/getlogin_r.c -index 6c564d3b59..88971a9931 100644 ---- a/sysdeps/unix/getlogin_r.c -+++ b/sysdeps/unix/getlogin_r.c -@@ -64,8 +64,8 @@ __getlogin_r (char *name, size_t name_len) - held so that our search is thread-safe. */ - - __libc_lock_lock (__libc_utmp_lock); -- (*__libc_utmp_jump_table->setutent) (); -- result = (*__libc_utmp_jump_table->getutline_r) (&line, &buffer, &ut); -+ __libc_setutent (); -+ result = __libc_getutline_r (&line, &buffer, &ut); - if (result < 0) - { - if (errno == ESRCH) -@@ -74,8 +74,7 @@ __getlogin_r (char *name, size_t name_len) - else - result = errno; - } -- (*__libc_utmp_jump_table->endutent) (); -- __libc_utmp_jump_table = &__libc_utmp_unknown_functions; -+ __libc_endutent (); - __libc_lock_unlock (__libc_utmp_lock); - - if (result == 0) -diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile -index 1ab6bcbfc8..a7980a60f6 100644 ---- a/sysdeps/unix/sysv/linux/Makefile -+++ b/sysdeps/unix/sysv/linux/Makefile -@@ -212,8 +212,8 @@ sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \ - close_nocancel fcntl_nocancel nanosleep_nocancel \ - open_nocancel open64_nocancel \ - openat_nocancel openat64_nocancel \ -- pause_nocancel read_nocancel waitpid_nocancel \ -- write_nocancel statx_cp -+ pause_nocancel read_nocancel pread64_nocancel \ -+ waitpid_nocancel write_nocancel statx_cp - - sysdep_headers += bits/fcntl-linux.h - -diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions -index 1ca102a9e2..d385085c61 100644 ---- a/sysdeps/unix/sysv/linux/Versions -+++ b/sysdeps/unix/sysv/linux/Versions -@@ -182,6 +182,7 @@ libc { - __syscall_rt_sigqueueinfo; - __open_nocancel; - __read_nocancel; -+ __pread64_nocancel; - __close_nocancel; - __sigtimedwait; - # functions used by nscd -diff --git a/sysdeps/unix/sysv/linux/alpha/getegid.S b/sysdeps/unix/sysv/linux/alpha/getegid.S -new file mode 100644 -index 0000000000..167009d17a ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/alpha/getegid.S -@@ -0,0 +1,26 @@ -+/* Copyright (C) 1991-2019 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <sysdep.h> -+ -+ -+PSEUDO (__getegid, getxgid, 0) -+ MOVE (r1, r0) -+ ret -+PSEUDO_END (__getegid) -+ -+weak_alias (__getegid, getegid) -diff --git a/sysdeps/unix/sysv/linux/alpha/geteuid.S b/sysdeps/unix/sysv/linux/alpha/geteuid.S -new file mode 100644 -index 0000000000..39413779f7 ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/alpha/geteuid.S -@@ -0,0 +1,26 @@ -+/* Copyright (C) 1991-2019 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <sysdep.h> -+ -+ -+PSEUDO (__geteuid, getxuid, 0) -+ MOVE (r1, r0) -+ ret -+PSEUDO_END (__geteuid) -+ -+weak_alias (__geteuid, geteuid) -diff --git a/sysdeps/unix/sysv/linux/alpha/getppid.S b/sysdeps/unix/sysv/linux/alpha/getppid.S -new file mode 100644 -index 0000000000..4d291181bd ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/alpha/getppid.S -@@ -0,0 +1,26 @@ -+/* Copyright (C) 1991-2019 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <sysdep.h> -+ -+ -+PSEUDO (__getppid, getxpid, 0) -+ MOVE (r1, r0) -+ ret -+PSEUDO_END (__getppid) -+ -+weak_alias (__getppid, getppid) -diff --git a/sysdeps/unix/sysv/linux/bits/statx.h b/sysdeps/unix/sysv/linux/bits/statx.h -index 206878723f..aaccfdc2dc 100644 ---- a/sysdeps/unix/sysv/linux/bits/statx.h -+++ b/sysdeps/unix/sysv/linux/bits/statx.h -@@ -26,11 +26,13 @@ - - /* Use "" to work around incorrect macro expansion of the - __has_include argument (GCC PR 80005). */ --#if __glibc_has_include ("linux/stat.h") --# include "linux/stat.h" --# ifdef STATX_TYPE --# define __statx_timestamp_defined 1 --# define __statx_defined 1 -+#ifdef __has_include -+# if __has_include ("linux/stat.h") -+# include "linux/stat.h" -+# ifdef STATX_TYPE -+# define __statx_timestamp_defined 1 -+# define __statx_defined 1 -+# endif - # endif - #endif - -diff --git a/sysdeps/unix/sysv/linux/hppa/clone.S b/sysdeps/unix/sysv/linux/hppa/clone.S -index 79fa4f6147..1c0325e199 100644 ---- a/sysdeps/unix/sysv/linux/hppa/clone.S -+++ b/sysdeps/unix/sysv/linux/hppa/clone.S -@@ -73,13 +73,18 @@ ENTRY(__clone) - #endif - - /* Sanity check arguments. */ -- comib,=,n 0, %arg0, .LerrorSanity /* no NULL function pointers */ -- comib,=,n 0, %arg1, .LerrorSanity /* no NULL stack pointers */ -+ comib,=,n 0,%arg0,.LerrorSanity /* no NULL function pointers */ -+ comib,=,n 0,%arg1,.LerrorSanity /* no NULL stack pointers */ -+ -+ /* Ensure stack argument is 8-byte aligned. */ -+ ldo 7(%r25),%r25 -+ depi 0,31,3,%r25 - - /* Save the function pointer, arg, and flags on the new stack. */ - stwm %r26, 64(%r25) - stw %r23, -60(%r25) - stw %r24, -56(%r25) -+ - /* Clone arguments are (int flags, void * child_stack) */ - copy %r24, %r26 /* flags are first */ - /* User stack pointer is in the correct register already */ -diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linux/mips/Makefile -index 8217f42e75..03044e7365 100644 ---- a/sysdeps/unix/sysv/linux/mips/Makefile -+++ b/sysdeps/unix/sysv/linux/mips/Makefile -@@ -63,14 +63,25 @@ sysdep-dl-routines += dl-static - - sysdep_routines += dl-vdso - endif -- --# Supporting non-executable stacks on MIPS requires changes to both --# the Linux kernel and glibc. See --# <https://sourceware.org/ml/libc-alpha/2016-01/msg00567.html> and --# <https://sourceware.org/ml/libc-alpha/2016-01/msg00719.html>. -+# If the compiler doesn't use GNU.stack note, -+# this test is expected to fail. -+ifneq ($(mips-has-gnustack),yes) - test-xfail-check-execstack = yes - endif -+endif - - ifeq ($(subdir),stdlib) - gen-as-const-headers += ucontext_i.sym - endif -+ -+ifeq ($(mips-force-execstack),yes) -+CFLAGS-.o += -Wa,-execstack -+CFLAGS-.os += -Wa,-execstack -+CFLAGS-.op += -Wa,-execstack -+CFLAGS-.oS += -Wa,-execstack -+ -+ASFLAGS-.o += -Wa,-execstack -+ASFLAGS-.os += -Wa,-execstack -+ASFLAGS-.op += -Wa,-execstack -+ASFLAGS-.oS += -Wa,-execstack -+endif -diff --git a/sysdeps/unix/sysv/linux/mips/configure b/sysdeps/unix/sysv/linux/mips/configure -index 1ee7f41a36..25f98e0c7b 100644 ---- a/sysdeps/unix/sysv/linux/mips/configure -+++ b/sysdeps/unix/sysv/linux/mips/configure -@@ -475,3 +475,44 @@ if test -z "$arch_minimum_kernel"; then - arch_minimum_kernel=4.5.0 - fi - fi -+ -+# Check if we are supposed to run on kernels older than 4.8.0. If so, -+# force executable stack to avoid potential runtime problems with fpu -+# emulation. -+# NOTE: The check below assumes that in absence of user-provided minumum_kernel -+# we will default to arch_minimum_kernel which is currently less than 4.8.0 for -+# all known configurations. If this changes, the check must be updated. -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler must use executable stack" >&5 -+$as_echo_n "checking whether the compiler must use executable stack... " >&6; } -+if ${libc_cv_mips_force_execstack+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ libc_cv_mips_force_execstack=no -+ if test $libc_mips_float = hard; then -+ if test -n "$minimum_kernel"; then -+ -+ min_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`)) -+ -+ if test $min_version -lt 264192; then -+ libc_cv_mips_force_execstack=yes -+ fi -+ else -+ libc_cv_mips_force_execstack=yes -+ fi -+ fi -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mips_force_execstack" >&5 -+$as_echo "$libc_cv_mips_force_execstack" >&6; } -+ -+libc_mips_has_gnustack=$libc_cv_as_noexecstack -+ -+if test $libc_cv_mips_force_execstack = yes; then -+ libc_mips_has_gnustack=no -+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: forcing executable stack for pre-4.8.0 Linux kernels" >&5 -+$as_echo "$as_me: WARNING: forcing executable stack for pre-4.8.0 Linux kernels" >&2;} -+fi -+ -+config_vars="$config_vars -+mips-force-execstack = ${libc_cv_mips_force_execstack}" -+config_vars="$config_vars -+mips-has-gnustack = ${libc_mips_has_gnustack}" -diff --git a/sysdeps/unix/sysv/linux/mips/configure.ac b/sysdeps/unix/sysv/linux/mips/configure.ac -index 9147aa4582..3db1b32b08 100644 ---- a/sysdeps/unix/sysv/linux/mips/configure.ac -+++ b/sysdeps/unix/sysv/linux/mips/configure.ac -@@ -134,3 +134,35 @@ if test -z "$arch_minimum_kernel"; then - arch_minimum_kernel=4.5.0 - fi - fi -+ -+# Check if we are supposed to run on kernels older than 4.8.0. If so, -+# force executable stack to avoid potential runtime problems with fpu -+# emulation. -+# NOTE: The check below assumes that in absence of user-provided minumum_kernel -+# we will default to arch_minimum_kernel which is currently less than 4.8.0 for -+# all known configurations. If this changes, the check must be updated. -+AC_CACHE_CHECK([whether the compiler must use executable stack], -+ libc_cv_mips_force_execstack, [dnl -+libc_cv_mips_force_execstack=no -+ if test $libc_mips_float = hard; then -+ if test -n "$minimum_kernel"; then -+ changequote(,) -+ min_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`)) -+ changequote([,]) -+ if test $min_version -lt 264192; then -+ libc_cv_mips_force_execstack=yes -+ fi -+ else -+ libc_cv_mips_force_execstack=yes -+ fi -+ fi]) -+ -+libc_mips_has_gnustack=$libc_cv_as_noexecstack -+ -+if test $libc_cv_mips_force_execstack = yes; then -+ libc_mips_has_gnustack=no -+ AC_MSG_WARN([forcing executable stack for pre-4.8.0 Linux kernels]) -+fi -+ -+LIBC_CONFIG_VAR([mips-force-execstack],[${libc_cv_mips_force_execstack}]) -+LIBC_CONFIG_VAR([mips-has-gnustack],[${libc_mips_has_gnustack}]) -diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h -index 16cc31cba5..bf7d80125a 100644 ---- a/sysdeps/unix/sysv/linux/not-cancel.h -+++ b/sysdeps/unix/sysv/linux/not-cancel.h -@@ -43,6 +43,9 @@ __typeof (openat64) __openat64_nocancel; - /* Non cancellable read syscall. */ - __typeof (__read) __read_nocancel; - -+/* Non cancellable pread syscall (LFS version). */ -+__typeof (__pread64) __pread64_nocancel; -+ - /* Uncancelable write. */ - __typeof (__write) __write_nocancel; - -@@ -84,6 +87,7 @@ hidden_proto (__open64_nocancel) - hidden_proto (__openat_nocancel) - hidden_proto (__openat64_nocancel) - hidden_proto (__read_nocancel) -+hidden_proto (__pread64_nocancel) - hidden_proto (__write_nocancel) - hidden_proto (__close_nocancel) - hidden_proto (__waitpid_nocancel) -diff --git a/sysdeps/unix/sysv/linux/pread64_nocancel.c b/sysdeps/unix/sysv/linux/pread64_nocancel.c -new file mode 100644 -index 0000000000..dab61260e5 ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/pread64_nocancel.c -@@ -0,0 +1,32 @@ -+/* Linux pread64() syscall implementation -- non-cancellable. -+ Copyright (C) 2019 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <unistd.h> -+#include <sysdep-cancel.h> -+#include <not-cancel.h> -+ -+#ifndef __NR_pread64 -+# define __NR_pread64 __NR_pread -+#endif -+ -+ssize_t -+__pread64_nocancel (int fd, void *buf, size_t count, off64_t offset) -+{ -+ return INLINE_SYSCALL_CALL (pread64, fd, buf, count, SYSCALL_LL64_PRW (offset)); -+} -+hidden_def (__pread64_nocancel) -diff --git a/sysdeps/unix/sysv/linux/riscv/vfork.S b/sysdeps/unix/sysv/linux/riscv/vfork.S -index 67373f181b..dc173d6b47 100644 ---- a/sysdeps/unix/sysv/linux/riscv/vfork.S -+++ b/sysdeps/unix/sysv/linux/riscv/vfork.S -@@ -21,9 +21,12 @@ - #include <sys/asm.h> - #include <sysdep.h> - #define __ASSEMBLY__ --#include <linux/sched.h> - #include <asm/signal.h> - -+#define CLONE_VM 0x00000100 /* Set if VM shared between processes. */ -+#define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to -+ wake it up on mm_release. */ -+ - .text - LEAF (__libc_vfork) - -diff --git a/sysdeps/unix/sysv/linux/s390/bits/utmp.h b/sysdeps/unix/sysv/linux/s390/bits/utmp.h -index 862115c6f8..0569c3b784 100644 ---- a/sysdeps/unix/sysv/linux/s390/bits/utmp.h -+++ b/sysdeps/unix/sysv/linux/s390/bits/utmp.h -@@ -61,7 +61,8 @@ struct utmp - pid_t ut_pid; /* Process ID of login process. */ - char ut_line[UT_LINESIZE] - __attribute_nonstring__; /* Devicename. */ -- char ut_id[4]; /* Inittab ID. */ -+ char ut_id[4] -+ __attribute_nonstring__; /* Inittab ID. */ - char ut_user[UT_NAMESIZE] - __attribute_nonstring__; /* Username. */ - char ut_host[UT_HOSTSIZE] -diff --git a/sysdeps/unix/sysv/linux/s390/bits/utmpx.h b/sysdeps/unix/sysv/linux/s390/bits/utmpx.h -index ea3e860a2d..737d9dca05 100644 ---- a/sysdeps/unix/sysv/linux/s390/bits/utmpx.h -+++ b/sysdeps/unix/sysv/linux/s390/bits/utmpx.h -@@ -56,10 +56,14 @@ struct utmpx - { - short int ut_type; /* Type of login. */ - __pid_t ut_pid; /* Process ID of login process. */ -- char ut_line[__UT_LINESIZE]; /* Devicename. */ -- char ut_id[4]; /* Inittab ID. */ -- char ut_user[__UT_NAMESIZE]; /* Username. */ -- char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */ -+ char ut_line[__UT_LINESIZE] -+ __attribute_nonstring__; /* Devicename. */ -+ char ut_id[4] -+ __attribute_nonstring__; /* Inittab ID. */ -+ char ut_user[__UT_NAMESIZE] -+ __attribute_nonstring__; /* Username. */ -+ char ut_host[__UT_HOSTSIZE] -+ __attribute_nonstring__; /* Hostname for remote login. */ - struct __exit_status ut_exit; /* Exit status of a process marked - as DEAD_PROCESS. */ - -diff --git a/sysdeps/unix/sysv/linux/test-errno-linux.c b/sysdeps/unix/sysv/linux/test-errno-linux.c -index cb979d44bd..aaa9eadc0a 100644 ---- a/sysdeps/unix/sysv/linux/test-errno-linux.c -+++ b/sysdeps/unix/sysv/linux/test-errno-linux.c -@@ -160,8 +160,9 @@ do_test (void) - fails |= test_wrp (EINVAL, poll, &pollfd, -1, 0); - /* quotactl returns ENOSYS for kernels not configured with - CONFIG_QUOTA, and may return EPERM if called within certain types -- of containers. */ -- fails |= test_wrp2 (LIST (ENODEV, ENOSYS, EPERM), -+ of containers. Linux 5.4 added additional argument validation -+ and can return EINVAL. */ -+ fails |= test_wrp2 (LIST (ENODEV, ENOSYS, EPERM, EINVAL), - quotactl, Q_GETINFO, NULL, -1, (caddr_t) &dqblk); - fails |= test_wrp (EINVAL, sched_getparam, -1, &sch_param); - fails |= test_wrp (EINVAL, sched_getscheduler, -1); -diff --git a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h -index 975cbe2950..df2cdfdb6b 100644 ---- a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h -+++ b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h -@@ -31,7 +31,8 @@ - environment variable, LD_PREFER_MAP_32BIT_EXEC. */ - #define EXTRA_LD_ENVVARS \ - case 21: \ -- if (memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0) \ -+ if (!__libc_enable_secure \ -+ && memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0) \ - GLRO(dl_x86_cpu_features).feature[index_arch_Prefer_MAP_32BIT_EXEC] \ - |= bit_arch_Prefer_MAP_32BIT_EXEC; \ - break; -diff --git a/time/Makefile b/time/Makefile -index a428f55245..63b8d735ea 100644 ---- a/time/Makefile -+++ b/time/Makefile -@@ -57,6 +57,8 @@ include ../gen-locales.mk - - $(objpfx)tst-ftime_l.out: $(gen-locales) - $(objpfx)tst-strptime.out: $(gen-locales) -+$(objpfx)tst-strftime2.out: $(gen-locales) -+$(objpfx)tst-strftime3.out: $(gen-locales) - endif - - tz-cflags = -DTZDIR='"$(zonedir)"' \ diff --git a/debian/patches/hurd-i386/git-ONSTACK.diff b/debian/patches/hurd-i386/git-ONSTACK.diff deleted file mode 100644 index 85b7dfb5..00000000 --- a/debian/patches/hurd-i386/git-ONSTACK.diff +++ /dev/null @@ -1,109 +0,0 @@ -From: Samuel Thibault <samuel.thibault@ens-lyon.org> -Subject: [PATCH] Fix SS_ONSTACK support - -* sysdeps/mach/hurd/i386/sigreturn.c (__sigreturn2): New function, -unlocks SS and returns to the saved PC. -(__sigreturn): Do not unlock SS, and "return" into __sigreturn2 on the -thread stack instead of the saved PC. - ---- - sysdeps/mach/hurd/i386/sigreturn.c | 68 +++++++++++++++++++++++--------------- - 1 file changed, 42 insertions(+), 26 deletions(-) - -diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c -index 83c0246..204bd47 100644 ---- a/sysdeps/mach/hurd/i386/sigreturn.c -+++ b/sysdeps/mach/hurd/i386/sigreturn.c -@@ -24,6 +24,36 @@ register int *sp asm ("%esp"); - #include <stdlib.h> - #include <string.h> - -+/* This is run on the thread stack after restoring it, to be able to -+ unlock SS off sigstack. */ -+static void -+__sigreturn2 (int *usp) -+{ -+ struct hurd_sigstate *ss = _hurd_self_sigstate (); -+ __spin_unlock (&ss->lock); -+ -+ sp = usp; -+#define A(line) asm volatile (#line) -+ /* The members in the sigcontext are arranged in this order -+ so we can pop them easily. */ -+ -+ /* Pop the segment registers (except %cs and %ss, done last). */ -+ A (popl %gs); -+ A (popl %fs); -+ A (popl %es); -+ A (popl %ds); -+ /* Pop the general registers. */ -+ A (popa); -+ /* Pop the processor flags. */ -+ A (popf); -+ /* Return to the saved PC. */ -+ A (ret); -+ -+ /* Firewall. */ -+ A (hlt); -+#undef A -+} -+ - int - __sigreturn (struct sigcontext *scp) - { -@@ -67,13 +97,7 @@ __sigreturn (struct sigcontext *scp) - } - - if (scp->sc_onstack) -- { -- ss->sigaltstack.ss_flags &= ~SS_ONSTACK; -- /* XXX cannot unlock until off sigstack */ -- abort (); -- } -- else -- __spin_unlock (&ss->lock); -+ ss->sigaltstack.ss_flags &= ~SS_ONSTACK; - - /* Destroy the MiG reply port used by the signal handler, and restore the - reply port in use by the thread when interrupted. */ -@@ -108,27 +132,19 @@ __sigreturn (struct sigcontext *scp) - *--usp = scp->sc_efl; - memcpy (usp -= 12, &scp->sc_i386_thread_state, 12 * sizeof (int)); - -- sp = usp; -- --#define A(line) asm volatile (#line) -- /* The members in the sigcontext are arranged in this order -- so we can pop them easily. */ -- -- /* Pop the segment registers (except %cs and %ss, done last). */ -- A (popl %gs); -- A (popl %fs); -- A (popl %es); -- A (popl %ds); -- /* Pop the general registers. */ -- A (popa); -- /* Pop the processor flags. */ -- A (popf); -- /* Return to the saved PC. */ -- A (ret); -+ /* Pass usp to __sigreturn2 so it can unwind itself easily. */ -+ *(usp-1) = (int) usp; -+ --usp; -+ /* Bogus return address for __sigreturn2 */ -+ *--usp = 0; -+ *--usp = (int) __sigreturn2; - -+ /* Restore thread stack */ -+ sp = usp; -+ /* Return into __sigreturn2. */ -+ asm volatile ("ret"); - /* Firewall. */ -- A (hlt); --#undef A -+ asm volatile ("hlt"); - } - - /* NOTREACHED */ --- -tg: (ab44f81..) t/ONSTACK (depends on: t/tls-threadvar t/hurdsig-global-dispositions) diff --git a/debian/patches/hurd-i386/git-altstack-RPC.diff b/debian/patches/hurd-i386/git-altstack-RPC.diff deleted file mode 100644 index fa123b46..00000000 --- a/debian/patches/hurd-i386/git-altstack-RPC.diff +++ /dev/null @@ -1,56 +0,0 @@ -commit e46efff89550a8e693a3362976f85070762c5cb8 -Author: Samuel Thibault <samuel.thibault@ens-lyon.org> -Date: Wed Dec 11 00:23:00 2019 +0100 - - hurd: Fix using altstack while in an RPC call to be aborted - - * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Always check - for interrupted code being with esp pointing at mach_msg arguments, even - when using an altstack. If we need to abort the RPC we will need - this. - -diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c -index a6928a607b6..0c5d5a194c1 100644 ---- a/sysdeps/mach/hurd/i386/trampoline.c -+++ b/sysdeps/mach/hurd/i386/trampoline.c -@@ -74,12 +74,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, - interrupted RPC frame. */ - state->basic.esp = state->basic.uesp; - -- if ((ss->actions[signo].sa_flags & SA_ONSTACK) -- && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK))) -- { -- sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size; -- ss->sigaltstack.ss_flags |= SS_ONSTACK; -- } - /* This code has intimate knowledge of the special mach_msg system call - done in intr-msg.c; that code does (see intr-msg.h): - movl %esp, %ecx -@@ -91,13 +85,20 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, - We must check for the window during which %esp points at the - mach_msg arguments. The space below until %ecx is used by - the _hurd_intr_rpc_mach_msg frame, and must not be clobbered. */ -- else if (state->basic.eip >= (int) &_hurd_intr_rpc_msg_cx_sp -- && state->basic.eip < (int) &_hurd_intr_rpc_msg_sp_restored) -- /* The SP now points at the mach_msg args, but there is more stack -- space used below it. The real SP is saved in %ecx; we must push the -- new frame below there, and restore that value as the SP on -- sigreturn. */ -- sigsp = (char *) (state->basic.uesp = state->basic.ecx); -+ if (state->basic.eip >= (int) &_hurd_intr_rpc_msg_cx_sp -+ && state->basic.eip < (int) &_hurd_intr_rpc_msg_sp_restored) -+ /* The SP now points at the mach_msg args, but there is more stack -+ space used below it. The real SP is saved in %ecx; we must push the -+ new frame below there (if not on the altstack), and restore that value as -+ the SP on sigreturn. */ -+ state->basic.uesp = state->basic.ecx; -+ -+ if ((ss->actions[signo].sa_flags & SA_ONSTACK) -+ && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK))) -+ { -+ sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size; -+ ss->sigaltstack.ss_flags |= SS_ONSTACK; -+ } - else - sigsp = (char *) state->basic.uesp; - diff --git a/debian/patches/hurd-i386/git-context_functions.diff b/debian/patches/hurd-i386/git-context_functions.diff deleted file mode 100644 index ad38f9df..00000000 --- a/debian/patches/hurd-i386/git-context_functions.diff +++ /dev/null @@ -1,474 +0,0 @@ -committed for glibc 2.31 - -Subject: [PATCH] getcontext, makecontext, setcontext, swapcontext - -From: Thomas Schwinge <thomas@codesourcery.com> - -Adapted from the Linux x86 functions. - -Not thoroughly tested, but manual testing as well as glibc tests look fine, and -manual -lpthread testing also looks fine (within the given bounds for a new -stack to be used with makecontext). - ---- - sysdeps/mach/hurd/i386/Makefile | 5 + - sysdeps/mach/hurd/i386/getcontext.S | 74 +++++++++++++++ - sysdeps/mach/hurd/i386/makecontext-helper.c | 69 ++++++++++++++ - sysdeps/mach/hurd/i386/makecontext.S | 130 ++++++++++++++++++++++++++++ - sysdeps/mach/hurd/i386/setcontext.S | 92 +++++++++++++++++++ - sysdeps/mach/hurd/i386/swapcontext.S | 110 +++++++++++++++++++++++ - sysdeps/mach/hurd/i386/ucontext_i.sym | 29 ++++++ - 7 files changed, 509 insertions(+) - ---- a/sysdeps/mach/hurd/i386/Makefile -+++ b/sysdeps/mach/hurd/i386/Makefile -@@ -102,3 +102,7 @@ - # callbacks whose parameters don't permit to get the context parameters. - check-execstack-xfail += ld.so libc.so libpthread.so - endif -+ -+ifeq ($(subdir),stdlib) -+gen-as-const-headers += ucontext_i.sym -+endif ---- /dev/null -+++ b/sysdeps/mach/hurd/i386/getcontext.S -@@ -0,0 +1,74 @@ -+/* Save current context. -+ Copyright (C) 2001-2015 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. -+ -+ 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <sysdep.h> -+ -+#include "ucontext_i.h" -+ -+ -+ENTRY(__getcontext) -+ /* Load address of the context data structure. */ -+ movl 4(%esp), %eax -+ -+ /* Return value of getcontext. EAX is the only register whose -+ value is not preserved. */ -+ movl $0, oEAX(%eax) -+ -+ /* Save the 32-bit register values and the return address. */ -+ movl %ecx, oECX(%eax) -+ movl %edx, oEDX(%eax) -+ movl %edi, oEDI(%eax) -+ movl %esi, oESI(%eax) -+ movl %ebp, oEBP(%eax) -+ movl (%esp), %ecx -+ movl %ecx, oEIP(%eax) -+ leal 4(%esp), %ecx /* Exclude the return address. */ -+ movl %ecx, oESP(%eax) -+ movl %ebx, oEBX(%eax) -+ -+ /* Save the FS segment register. We don't touch the GS register -+ since it is used for threads. */ -+ xorl %edx, %edx -+ movw %fs, %dx -+ movl %edx, oFS(%eax) -+ -+ leal oFPREGS(%eax), %ecx -+ /* Save the floating-point context. */ -+ fnstenv (%ecx) -+ /* And load it right back since the processor changes the mask. -+ Intel thought this opcode to be used in interrupt handlers which -+ would block all exceptions. */ -+ fldenv (%ecx) -+ -+ /* Save the current signal mask. */ -+ subl $12, %esp -+ cfi_adjust_cfa_offset (12) -+ leal oSIGMASK(%eax), %eax -+ movl %eax, 8(%esp) -+ movl $0, 4(%esp) -+ movl $SIG_BLOCK, (%esp) -+ call JUMPTARGET (__sigprocmask) -+ addl $12, %esp -+ cfi_adjust_cfa_offset (-12) -+ /* Propagate %eax (and errno, in case). */ -+ -+ ret -+PSEUDO_END(__getcontext) -+ -+weak_alias (__getcontext, getcontext) ---- /dev/null -+++ b/sysdeps/mach/hurd/i386/makecontext.S -@@ -0,0 +1,122 @@ -+/* Create new context. -+ Copyright (C) 2001-2015 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. -+ -+ 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <sysdep.h> -+ -+#include "ucontext_i.h" -+ -+ -+ENTRY(__makecontext) -+ movl 4(%esp), %eax -+ -+ /* Load the address of the function we are supposed to run. */ -+ movl 8(%esp), %ecx -+ -+ /* Compute the address of the stack. The information comes from -+ to us_stack element. */ -+ movl oSS_SP(%eax), %edx -+ movl %ecx, oEIP(%eax) -+ addl oSS_SIZE(%eax), %edx -+ -+ /* Remember the number of parameters for the exit handler since -+ it has to remove them. We store the number in the EBX register -+ which the function we will call must preserve. */ -+ movl 12(%esp), %ecx -+ movl %ecx, oEBX(%eax) -+ -+ /* Make room on the new stack for the parameters. -+ Room for the arguments, return address (== L(exitcode)) and -+ oLINK pointer is needed. One of the pointer sizes is subtracted -+ after aligning the stack. */ -+ negl %ecx -+ leal -4(%edx,%ecx,4), %edx -+ negl %ecx -+ -+ /* Align the stack. */ -+ andl $0xfffffff0, %edx -+ subl $4, %edx -+ -+ /* Store the future stack pointer. */ -+ movl %edx, oESP(%eax) -+ -+ /* Put the next context on the new stack (from the uc_link -+ element). */ -+ movl oLINK(%eax), %eax -+ movl %eax, 4(%edx,%ecx,4) -+ -+ /* Copy all the parameters. */ -+ jecxz 2f -+1: movl 12(%esp,%ecx,4), %eax -+ movl %eax, (%edx,%ecx,4) -+ decl %ecx -+ jnz 1b -+2: -+ -+ /* If the function we call returns we must continue with the -+ context which is given in the uc_link element. To do this -+ set the return address for the function the user provides -+ to a little bit of helper code which does the magic (see -+ below). */ -+#ifdef PIC -+ call 1f -+ cfi_adjust_cfa_offset (4) -+1: popl %ecx -+ cfi_adjust_cfa_offset (-4) -+ addl $L(exitcode)-1b, %ecx -+ movl %ecx, (%edx) -+#else -+ movl $L(exitcode), (%edx) -+#endif -+ /* 'makecontext' returns no value. */ -+ ret -+ -+ /* This is the helper code which gets called if a function which -+ is registered with 'makecontext' returns. In this case we -+ have to install the context listed in the uc_link element of -+ the context 'makecontext' manipulated at the time of the -+ 'makecontext' call. If the pointer is NULL the process must -+ terminate. */ -+ cfi_endproc -+L(exitcode): -+ /* This removes the parameters passed to the function given to -+ 'makecontext' from the stack. EBX contains the number of -+ parameters (see above). */ -+ leal (%esp,%ebx,4), %esp -+ -+#ifdef PIC -+ call 1f -+1: popl %ebx -+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx -+#endif -+ cmpl $0, (%esp) /* Check the next context. */ -+ je 2f /* If it is zero exit. */ -+ -+ call JUMPTARGET(__setcontext) -+ /* If this returns (which can happen if the syscall fails) we'll -+ exit the program with the return error value (-1). */ -+ -+ movl %eax, (%esp) -+2: call HIDDEN_JUMPTARGET(exit) -+ /* The 'exit' call should never return. In case it does cause -+ the process to terminate. */ -+ hlt -+ cfi_startproc -+END(__makecontext) -+ -+weak_alias (__makecontext, makecontext) ---- /dev/null -+++ b/sysdeps/mach/hurd/i386/setcontext.S -@@ -0,0 +1,92 @@ -+/* Install given context. -+ Copyright (C) 2001-2015 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. -+ -+ 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <sysdep.h> -+ -+#include "ucontext_i.h" -+ -+ -+ENTRY(__setcontext) -+ /* Load address of the context data structure. */ -+ movl 4(%esp), %eax -+ -+ /* Get the current signal mask. */ -+ subl $12, %esp -+ cfi_adjust_cfa_offset (12) -+ movl $0, 8(%esp) -+ leal oSIGMASK(%eax), %eax -+ movl %eax, 4(%esp) -+ movl $SIG_SETMASK, (%esp) -+ call JUMPTARGET (__sigprocmask) -+ addl $12, %esp -+ cfi_adjust_cfa_offset (-12) -+ testl %eax, %eax -+ jne L(pseudo_end) -+ -+ /* EAX was modified, reload it. */ -+ movl 4(%esp), %eax -+ -+ /* Restore the floating-point context. Not the registers, only the -+ rest. */ -+ leal oFPREGS(%eax), %ecx -+ fldenv (%ecx) -+ -+ /* Restore the FS segment register. We don't touch the GS register -+ since it is used for threads. */ -+ movl oFS(%eax), %ecx -+ movw %cx, %fs -+ -+ /* Fetch the address to return to. */ -+ movl oEIP(%eax), %ecx -+ -+ /* Load the new stack pointer. */ -+ cfi_def_cfa (eax, 0) -+ cfi_offset (edi, oEDI) -+ cfi_offset (esi, oESI) -+ cfi_offset (ebp, oEBP) -+ cfi_offset (ebx, oEBX) -+ cfi_offset (edx, oEDX) -+ cfi_offset (ecx, oECX) -+ movl oESP(%eax), %esp -+ -+ /* Push the return address on the new stack so we can return there. */ -+ pushl %ecx -+ -+ /* Load the values of all the 32-bit registers (except ESP). -+ Since we are loading from EAX, it must be last. */ -+ movl oEDI(%eax), %edi -+ movl oESI(%eax), %esi -+ movl oEBP(%eax), %ebp -+ movl oEBX(%eax), %ebx -+ movl oEDX(%eax), %edx -+ movl oECX(%eax), %ecx -+ movl oEAX(%eax), %eax -+ -+ /* End FDE here, we fall into another context. */ -+ cfi_endproc -+ cfi_startproc -+ -+ /* The following 'ret' will pop the address of the code and jump -+ to it. */ -+ -+L(pseudo_end): -+ ret -+PSEUDO_END(__setcontext) -+ -+weak_alias (__setcontext, setcontext) ---- /dev/null -+++ b/sysdeps/mach/hurd/i386/swapcontext.S -@@ -0,0 +1,110 @@ -+/* Save current context and install the given one. -+ Copyright (C) 2001-2015 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. -+ -+ 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 -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <sysdep.h> -+ -+#include "ucontext_i.h" -+ -+ -+ENTRY(__swapcontext) -+ /* Load address of the context data structure we save in. */ -+ movl 4(%esp), %eax -+ -+ /* Return value of swapcontext. EAX is the only register whose -+ value is not preserved. */ -+ movl $0, oEAX(%eax) -+ -+ /* Save the 32-bit register values and the return address. */ -+ movl %ecx, oECX(%eax) -+ movl %edx, oEDX(%eax) -+ movl %edi, oEDI(%eax) -+ movl %esi, oESI(%eax) -+ movl %ebp, oEBP(%eax) -+ movl (%esp), %ecx -+ movl %ecx, oEIP(%eax) -+ leal 4(%esp), %ecx -+ movl %ecx, oESP(%eax) -+ movl %ebx, oEBX(%eax) -+ -+ /* Save the FS segment register. */ -+ xorl %edx, %edx -+ movw %fs, %dx -+ movl %edx, oFS(%eax) -+ -+ leal oFPREGS(%eax), %ecx -+ /* Save the floating-point context. */ -+ fnstenv (%ecx) -+ -+ /* Load address of the context data structure we have to load. */ -+ movl 8(%esp), %ecx -+ -+ /* Save the current signal mask and install the new one. */ -+ subl $12, %esp -+ cfi_adjust_cfa_offset (12) -+ leal oSIGMASK(%eax), %eax -+ movl %eax, 8(%esp) -+ leal oSIGMASK(%ecx), %eax -+ movl %eax, 4(%esp) -+ movl $SIG_SETMASK, (%esp) -+ call JUMPTARGET (__sigprocmask) -+ addl $12, %esp -+ cfi_adjust_cfa_offset (-12) -+ testl %eax, %eax -+ jne L(pseudo_end) -+ -+ /* EAX was modified, reload it. */ -+ movl 8(%esp), %eax -+ -+ /* Restore the floating-point context. Not the registers, only the -+ rest. */ -+ leal oFPREGS(%eax), %ecx -+ fldenv (%ecx) -+ -+ /* Restore the FS segment register. We don't touch the GS register -+ since it is used for threads. */ -+ movl oFS(%eax), %edx -+ movw %dx, %fs -+ -+ /* Fetch the address to return to. */ -+ movl oEIP(%eax), %ecx -+ -+ /* Load the new stack pointer. */ -+ movl oESP(%eax), %esp -+ -+ /* Push the return address on the new stack so we can return there. */ -+ pushl %ecx -+ -+ /* Load the values of all the 32-bit registers (except ESP). -+ Since we are loading from EAX, it must be last. */ -+ movl oEDI(%eax), %edi -+ movl oESI(%eax), %esi -+ movl oEBP(%eax), %ebp -+ movl oEBX(%eax), %ebx -+ movl oEDX(%eax), %edx -+ movl oECX(%eax), %ecx -+ movl oEAX(%eax), %eax -+ -+ /* The following 'ret' will pop the address of the code and jump -+ to it. */ -+ -+L(pseudo_end): -+ ret -+PSEUDO_END(__swapcontext) -+ -+weak_alias (__swapcontext, swapcontext) ---- /dev/null -+++ b/sysdeps/mach/hurd/i386/ucontext_i.sym -@@ -0,0 +1,29 @@ -+#include <stddef.h> -+#include <signal.h> -+#include <sys/ucontext.h> -+ -+-- -+ -+SIG_BLOCK -+SIG_SETMASK -+ -+#define ucontext(member) offsetof (ucontext_t, member) -+#define mcontext(member) ucontext (uc_mcontext.member) -+#define mreg(reg) mcontext (gregs[REG_##reg]) -+ -+oLINK ucontext (uc_link) -+oSS_SP ucontext (uc_stack.ss_sp) -+oSS_SIZE ucontext (uc_stack.ss_size) -+oGS mreg (GS) -+oFS mreg (FS) -+oEDI mreg (EDI) -+oESI mreg (ESI) -+oEBP mreg (EBP) -+oESP mreg (ESP) -+oEBX mreg (EBX) -+oEDX mreg (EDX) -+oECX mreg (ECX) -+oEAX mreg (EAX) -+oEIP mreg (EIP) -+oFPREGS mcontext (fpregs) -+oSIGMASK ucontext (uc_sigmask) diff --git a/debian/patches/hurd-i386/git-errno_location.diff b/debian/patches/hurd-i386/git-errno_location.diff deleted file mode 100644 index e21d9e89..00000000 --- a/debian/patches/hurd-i386/git-errno_location.diff +++ /dev/null @@ -1,100 +0,0 @@ -commit 25c084e0a7b5e8d604d0f86b55f343acadf7af5d -Author: Samuel Thibault <samuel.thibault@ens-lyon.org> -Date: Sat Jan 4 19:37:53 2020 +0100 - - htl: Add __errno_location and __h_errno_location - - As explained on - https://sourceware.org/ml/libc-alpha/2020-01/msg00049.html - the presence of __errno_location in libpthread.so on GNU/Linux makes - libpthread getting linked in for libstdc++. This aligns on that behavior, to - avoid issues that only GNU/Hurd would get. - -diff --git a/htl/Makefile b/htl/Makefile -index 3b5c10635d..b7e84b4b95 100644 ---- a/htl/Makefile -+++ b/htl/Makefile -@@ -135,6 +135,7 @@ libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \ - shm-directory \ - \ - cthreads-compat \ -+ herrno \ - $(SYSDEPS) - - libpthread-static-only-routines = pt-atfork -diff --git a/htl/Versions b/htl/Versions -index c5a616da10..1c306acf5c 100644 ---- a/htl/Versions -+++ b/htl/Versions -@@ -29,6 +29,7 @@ libc { - libpthread { - GLIBC_2.2.6 { - _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile; -+ __errno_location; __h_errno_location; - } - GLIBC_2.12 { - __pthread_errorcheck_mutexattr; __pthread_recursive_mutexattr; -diff --git a/htl/herrno.c b/htl/herrno.c -new file mode 100644 -index 0000000000..66174a03e9 ---- /dev/null -+++ b/htl/herrno.c -@@ -0,0 +1,34 @@ -+/* Copyright (C) 1996-2020 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+#include <features.h> -+#include <netdb.h> -+#undef h_errno -+ -+#include <tls.h> -+ -+/* We need to have the error status variable of the resolver -+ accessible in the libc. */ -+extern __thread int __h_errno; -+ -+ -+/* When threaded, h_errno may be a per-thread variable. */ -+int * -+__h_errno_location (void) -+{ -+ return &__h_errno; -+} -diff --git a/sysdeps/htl/Makefile b/sysdeps/htl/Makefile -index 12bb54ebf4..ef156f1315 100644 ---- a/sysdeps/htl/Makefile -+++ b/sysdeps/htl/Makefile -@@ -1,3 +1,7 @@ -+ifeq ($(subdir),htl) -+libpthread-sysdep_routines += errno-loc -+endif -+ - ifeq ($(subdir),rt) - librt-sysdep_routines += timer_routines - endif -diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist -index 4c7d06d073..0ede90859c 100644 ---- a/sysdeps/mach/hurd/i386/libpthread.abilist -+++ b/sysdeps/mach/hurd/i386/libpthread.abilist -@@ -145,5 +145,7 @@ GLIBC_2.12 sem_wait F - GLIBC_2.2.6 _IO_flockfile F - GLIBC_2.2.6 _IO_ftrylockfile F - GLIBC_2.2.6 _IO_funlockfile F -+GLIBC_2.2.6 __errno_location F -+GLIBC_2.2.6 __h_errno_location F - GLIBC_2.21 pthread_hurd_cond_timedwait_np F - GLIBC_2.21 pthread_hurd_cond_wait_np F diff --git a/debian/patches/hurd-i386/git-getrandom.diff b/debian/patches/hurd-i386/git-getrandom.diff deleted file mode 100644 index 170e67d8..00000000 --- a/debian/patches/hurd-i386/git-getrandom.diff +++ /dev/null @@ -1,367 +0,0 @@ -commit c1f25758c353fcb16076512aba62746bff2e0d2d -Author: Samuel Thibault <samuel.thibault@ens-lyon.org> -Date: Fri Dec 13 03:23:14 2019 +0100 - - hurd: Implement __close_nocancel_nostatus - - * sysdeps/mach/hurd/not-cancel.h: New file. - -commit fe75ee0ca65536352fcdaebfbf39aac9bee271f0 -Author: Andrew Eggenberger <andrew.eggenberger@gmail.com> -Date: Tue Oct 29 23:19:32 2019 -0500 - - hurd: add getrandom and getentropy implementations - - * sysdeps/mach/hurd/getentropy.c: New file. - * sysdeps/mach/hurd/getrandom.c: Likewise. - -commit 186e119bbd4a10895429ffe405ae96dc5c5634b8 (HEAD -> master, origin-rw/master) -Author: Samuel Thibault <samuel.thibault@ens-lyon.org> -Date: Fri Dec 13 03:32:21 2019 +0100 - - hurd: Fix __close_nocancel_nostatus availability - - Not only libc/rtld use __close_nocancel_nostatus. - - * sysdeps/mach/hurd/Makefile [$(subdir) == io] (sysdep_routines): Add - close_nocancel_nostatus. - * sysdeps/mach/hurd/Versions (libc): Add __close_nocancel_nostatus to - GLIBC_PRIVATE. - * sysdeps/mach/hurd/not-cancel.h (__close_nocancel_nostatus): Declare - function instead of defining inline. - [IS_IN (libc) || IS_IN (rtld)] (__close_nocancel_nostatus): Make - function hidden. - * sysdeps/mach/hurd/close_nocancel_nostatus.c: New file. - -commit 8eaf34eda256ba3647ed6e7ed5c7c9aa19955d17 -Author: Samuel Thibault <samuel.thibault@ens-lyon.org> -Date: Fri Dec 13 10:10:59 2019 +0100 - - hurd: Fix local PLT - - * include/sys/random.h (__getrandom): Add hidden prototype. - * stdlib/getrandom.c (getrandom): Rename to hidden definition __getrandom. - Add weak alias. - * sysdeps/mach/hurd/getrandom.c (getrandom): Likewise. - * sysdeps/unix/sysv/linux/getrandom.c (getrandom): Likewise. - * sysdeps/mach/hurd/getentropy.c (getentropy): Use __getrandom instead of - getrandom. - -commit a45244ce127763872ff0b5743fb4ac8299ee9b28 -Author: James Clarke <jrtc27@jrtc27.com> -Date: Tue Dec 17 18:29:29 2019 +0000 - - hurd: Make getrandom honour GRND_NONBLOCK - - * sysdeps/mach/hurd/getrandom.c (__getrandom): Open the random source - with O_NONBLOCK when the GRND_NONBLOCK flag is provided. - Message-Id: <20191217182929.90989-1-jrtc27@jrtc27.com> - ---- - include/sys/random.h | 11 ++++ - stdlib/getrandom.c | 6 +- - sysdeps/mach/hurd/Makefile | 2 - sysdeps/mach/hurd/Versions | 1 - sysdeps/mach/hurd/close_nocancel_nostatus.c | 30 +++++++++++++ - sysdeps/mach/hurd/getentropy.c | 64 ++++++++++++++++++++++++++++ - sysdeps/mach/hurd/getrandom.c | 50 +++++++++++++++++++++ - sysdeps/mach/hurd/not-cancel.h | 62 +++++++++++++++++++++++++++ - sysdeps/unix/sysv/linux/getrandom.c | 6 +- - 9 files changed, 227 insertions(+), 5 deletions(-) - ---- /dev/null -+++ b/sysdeps/mach/hurd/not-cancel.h -@@ -0,0 +1,62 @@ -+/* Uncancelable versions of cancelable interfaces. Hurd version. -+ Copyright (C) 2003-2019 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2003. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+#ifndef NOT_CANCEL_H -+# define NOT_CANCEL_H -+ -+#include <fcntl.h> -+#include <unistd.h> -+#include <sys/wait.h> -+#include <time.h> -+#include <sys/uio.h> -+#include <hurd.h> -+#include <hurd/fd.h> -+ -+/* For now we have none. Map the name to the normal functions. */ -+#define __open_nocancel(...) \ -+ __open (__VA_ARGS__) -+#define __open64_nocancel(...) \ -+ __open64 (__VA_ARGS__) -+#define __openat_nocancel(...) \ -+ __openat (__VA_ARGS__) -+#define __openat64_nocancel(...) \ -+ __openat64 (__VA_ARGS__) -+#define __close_nocancel(fd) \ -+ __close (fd) -+ -+void __close_nocancel_nostatus (int fd); -+ -+#define __read_nocancel(fd, buf, n) \ -+ __read (fd, buf, n) -+#define __pread64_nocancel(fd, buf, count, offset) \ -+ __pread64 (fd, buf, count, offset) -+#define __write_nocancel(fd, buf, n) \ -+ __write (fd, buf, n) -+#define __writev_nocancel_nostatus(fd, iov, n) \ -+ (void) __writev (fd, iov, n) -+# define __waitpid_nocancel(pid, stat_loc, options) \ -+ __waitpid (pid, stat_loc, options) -+#define __fcntl64_nocancel(fd, cmd, ...) \ -+ __fcntl64 (fd, cmd, __VA_ARGS__) -+ -+#if IS_IN (libc) || IS_IN (rtld) -+hidden_proto (__close_nocancel_nostatus) -+#endif -+ -+#endif /* NOT_CANCEL_H */ ---- /dev/null -+++ b/sysdeps/mach/hurd/getentropy.c -@@ -0,0 +1,64 @@ -+/* Implementation of getentropy based on getrandom. -+ Copyright (C) 2016-2019 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+#include <sys/random.h> -+#include <assert.h> -+#include <errno.h> -+#include <unistd.h> -+ -+/* Write LENGTH bytes of randomness starting at BUFFER. Return 0 on -+ success and -1 on failure. */ -+int -+getentropy (void *buffer, size_t length) -+{ -+ /* The interface is documented to return EIO for buffer lengths -+ longer than 256 bytes. */ -+ if (length > 256) -+ { -+ __set_errno (EIO); -+ return -1; -+ } -+ -+ /* Try to fill the buffer completely. Even with the 256 byte limit -+ above, we might still receive an EINTR error (when blocking -+ during boot). */ -+ void *end = buffer + length; -+ while (buffer < end) -+ { -+ /* NB: No cancellation point. */ -+ ssize_t bytes = __getrandom (buffer, end - buffer, 0); -+ if (bytes < 0) -+ { -+ if (errno == EINTR) -+ /* Try again if interrupted by a signal. */ -+ continue; -+ else -+ return -1; -+ } -+ if (bytes == 0) -+ { -+ /* No more bytes available. This should not happen under -+ normal circumstances. */ -+ __set_errno (EIO); -+ return -1; -+ } -+ /* Try again in case of a short read. */ -+ buffer += bytes; -+ } -+ return 0; -+} ---- /dev/null -+++ b/sysdeps/mach/hurd/getrandom.c -@@ -0,0 +1,50 @@ -+/* Hurdish implementation of getrandom -+ Copyright (C) 2016-2019 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+#include <sys/random.h> -+#include <fcntl.h> -+#include <unistd.h> -+#include <not-cancel.h> -+ -+/* Write up to LENGTH bytes of randomness starting at BUFFER. -+ Return the number of bytes written, or -1 on error. */ -+ssize_t -+__getrandom (void *buffer, size_t length, unsigned int flags) -+{ -+ const char *random_source = "/dev/urandom"; -+ int open_flags = O_RDONLY | O_CLOEXEC; -+ size_t amount_read; -+ int fd; -+ -+ if (flags & GRND_RANDOM) -+ random_source = "/dev/random"; -+ -+ if (flags & GRND_NONBLOCK) -+ open_flags |= O_NONBLOCK; -+ -+ fd = __open_nocancel(random_source, open_flags); -+ if (fd == -1) -+ return -1; -+ -+ amount_read = __read_nocancel(fd, buffer, length); -+ __close_nocancel_nostatus(fd); -+ return amount_read; -+} -+ -+libc_hidden_def (__getrandom) -+weak_alias (__getrandom, getrandom) ---- a/sysdeps/mach/hurd/Makefile -+++ b/sysdeps/mach/hurd/Makefile -@@ -196,7 +196,7 @@ sysdep_routines += cthreads - endif - - ifeq (io, $(subdir)) --sysdep_routines += f_setlk -+sysdep_routines += f_setlk close_nocancel_nostatus - endif - - ifeq ($(subdir),sunrpc) ---- a/sysdeps/mach/hurd/Versions -+++ b/sysdeps/mach/hurd/Versions -@@ -13,6 +13,7 @@ libc { - __libc_lock_self0; - - _dl_init_first; -+ __close_nocancel_nostatus; - } - } - ---- /dev/null -+++ b/sysdeps/mach/hurd/close_nocancel_nostatus.c -@@ -0,0 +1,30 @@ -+/* Copyright (C) 1991-2019 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+#include <errno.h> -+#include <unistd.h> -+#include <hurd.h> -+#include <hurd/fd.h> -+#include <not-cancel.h> -+ -+/* Close the file descriptor FD. */ -+void -+__close_nocancel_nostatus (int fd) -+{ -+ HURD_FD_USE (fd, _hurd_fd_close (descriptor)); -+} -+libc_hidden_def (__close_nocancel_nostatus) ---- a/include/sys/random.h -+++ b/include/sys/random.h -@@ -1,1 +1,11 @@ -+#ifndef _SYS_RANDOM_H - #include <stdlib/sys/random.h> -+ -+# ifndef _ISOMAC -+ -+extern ssize_t __getrandom (void *__buffer, size_t __length, -+ unsigned int __flags) __wur; -+libc_hidden_proto (__getrandom) -+ -+# endif /* !_ISOMAC */ -+#endif ---- a/stdlib/getrandom.c -+++ b/stdlib/getrandom.c -@@ -22,10 +22,12 @@ - /* Write up to LENGTH bytes of randomness starting at BUFFER. - Return the number of bytes written, or -1 on error. */ - ssize_t --getrandom (void *buffer, size_t length, unsigned int flags) -+__getrandom (void *buffer, size_t length, unsigned int flags) - { - __set_errno (ENOSYS); - return -1; - } -- - stub_warning (getrandom) -+ -+libc_hidden_def (__getrandom) -+weak_alias (__getrandom, getrandom) ---- a/sysdeps/unix/sysv/linux/getrandom.c -+++ b/sysdeps/unix/sysv/linux/getrandom.c -@@ -25,7 +25,7 @@ - /* Write up to LENGTH bytes of randomness starting at BUFFER. - Return the number of bytes written, or -1 on error. */ - ssize_t --getrandom (void *buffer, size_t length, unsigned int flags) -+__getrandom (void *buffer, size_t length, unsigned int flags) - { - return SYSCALL_CANCEL (getrandom, buffer, length, flags); - } -@@ -33,7 +33,7 @@ getrandom (void *buffer, size_t length, - /* Always provide a definition, even if the kernel headers lack the - system call number. */ - ssize_t --getrandom (void *buffer, size_t length, unsigned int flags) -+__getrandom (void *buffer, size_t length, unsigned int flags) - { - /* Ideally, we would add a cancellation point here, but we currently - cannot do so inside libc. */ -@@ -41,3 +41,5 @@ getrandom (void *buffer, size_t length, - return -1; - } - #endif -+libc_hidden_def (__getrandom) -+weak_alias (__getrandom, getrandom) diff --git a/debian/patches/hurd-i386/git-hurd_sigstate-PLT.diff b/debian/patches/hurd-i386/git-hurd_sigstate-PLT.diff deleted file mode 100644 index 0da53064..00000000 --- a/debian/patches/hurd-i386/git-hurd_sigstate-PLT.diff +++ /dev/null @@ -1,55 +0,0 @@ -committed for glibc 2.31 - -Index: glibc-2.28/sysdeps/hurd/include/hurd/signal.h -=================================================================== ---- glibc-2.28.orig/sysdeps/hurd/include/hurd/signal.h -+++ glibc-2.28/sysdeps/hurd/include/hurd/signal.h -@@ -11,6 +11,11 @@ libc_hidden_proto (_hurd_exception2signa - libc_hidden_proto (_hurd_intr_rpc_mach_msg) - libc_hidden_proto (_hurd_thread_sigstate) - libc_hidden_proto (_hurd_raise_signal) -+libc_hidden_proto (_hurd_sigstate_set_global_rcv) -+libc_hidden_proto (_hurd_sigstate_lock) -+libc_hidden_proto (_hurd_sigstate_pending) -+libc_hidden_proto (_hurd_sigstate_unlock) -+libc_hidden_proto (_hurd_sigstate_delete) - #endif - #ifdef _HURD_SIGNAL_H_HIDDEN_DEF - libc_hidden_def (_hurd_self_sigstate) -Index: glibc-2.28/hurd/hurdsig.c -=================================================================== ---- glibc-2.28.orig/hurd/hurdsig.c -+++ glibc-2.28/hurd/hurdsig.c -@@ -171,6 +171,7 @@ _hurd_sigstate_delete (thread_t th - free (ss); - } - } -+libc_hidden_def (_hurd_sigstate_delete) - - /* Make SS a global receiver, with pthread signal semantics. */ - void -@@ -188,6 +189,7 @@ _hurd_sigstate_set_global_rcv (str - assert (ss->thread != MACH_PORT_NULL); - ss->actions[0].sa_handler = SIG_IGN; - } -+libc_hidden_def (_hurd_sigstate_set_global_rcv) - - /* Check whether SS is a global receiver. */ - static int -@@ -214,6 +216,8 @@ _hurd_sigstate_unlock (struct hurd_sigs - if (sigstate_is_global_rcv (ss)) - __spin_unlock (&_hurd_global_sigstate->lock); - } -+libc_hidden_def (_hurd_sigstate_lock) -+libc_hidden_def (_hurd_sigstate_unlock) - - /* Retreive a thread's full set of pending signals, including the global - ones if appropriate. SS must be locked. */ -@@ -250,6 +254,7 @@ _hurd_sigstate_pending (const stru - __sigorset (&pending, &pending, &_hurd_global_sigstate->pending); - return pending; - } -+libc_hidden_def (_hurd_sigstate_pending) - - /* Clear a pending signal and return the associated detailed - signal information. SS must be locked, and must have signal SIGNO diff --git a/debian/patches/hurd-i386/git-hurdsig-boot-fix.diff b/debian/patches/hurd-i386/git-hurdsig-boot-fix.diff deleted file mode 100644 index 6a5886f7..00000000 --- a/debian/patches/hurd-i386/git-hurdsig-boot-fix.diff +++ /dev/null @@ -1,23 +0,0 @@ -Committed for glibc 2.31 - -2012-09-05 Richard Braun <rbraun@sceen.net> - - * hurd/hurdsig.c (sigstate_is_global_rcv): Do not return true - if _HURD_GLOBAL_SIGSTATE is null. - ---- - hurd/hurdsig.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/hurd/hurdsig.c -+++ b/hurd/hurdsig.c -@@ -161,7 +161,8 @@ _hurd_sigstate_set_global_rcv (struct hu - static int - sigstate_is_global_rcv (const struct hurd_sigstate *ss) - { -- return ss->actions[0].sa_handler == SIG_IGN; -+ return (_hurd_global_sigstate != NULL) -+ && (ss->actions[0].sa_handler == SIG_IGN); - } - - /* Lock/unlock a hurd_sigstate structure. If the accessors below require diff --git a/debian/patches/hurd-i386/git-hurdsig-fixes-2.diff b/debian/patches/hurd-i386/git-hurdsig-fixes-2.diff deleted file mode 100644 index 1e794321..00000000 --- a/debian/patches/hurd-i386/git-hurdsig-fixes-2.diff +++ /dev/null @@ -1,53 +0,0 @@ -Committed for glibc 2.31 - -From: Jeremie Koenig <jk@jk.fr.eu.org> -Subject: [PATCH] Small signal fixes - - 22e7268 Hurd signals: fix sigwait for pending signals - da8bf5e Hurd signals: clear the pending mask in fork and spawn - 8e87205 Hurd signals: don't drop blocked ignored signals - ---- - hurd/hurdsig.c | 4 +--- - sysdeps/mach/hurd/fork.c | 4 +++- - sysdeps/mach/hurd/spawni.c | 2 +- - 3 files changed, 5 insertions(+), 5 deletions(-) - ---- a/hurd/hurdsig.c -+++ b/hurd/hurdsig.c -@@ -904,9 +904,7 @@ - } - - /* Handle receipt of a blocked signal, or any signal while stopped. */ -- if (act != ignore /* Signals ignored now are forgotten now. */ -- && __sigismember (&blocked, signo) -- || (signo != SIGKILL && _hurd_stopped)) -+ if (__sigismember (&blocked, signo) || (signo != SIGKILL && _hurd_stopped)) - { - mark_pending (); - act = ignore; ---- a/sysdeps/mach/hurd/fork.c -+++ b/sysdeps/mach/hurd/fork.c -@@ -684,8 +684,10 @@ - err = __USEPORT (PROC, __proc_getpids (port, &_hurd_pid, &_hurd_ppid, - &_hurd_orphaned)); - -- /* Forking clears the trace flag. */ -+ /* Forking clears the trace flag and pending masks. */ - __sigemptyset (&_hurdsig_traced); -+ __sigemptyset (&_hurd_global_sigstate->pending); -+ __sigemptyset (&ss->pending); - - /* Release malloc locks. */ - _hurd_malloc_fork_child (); ---- a/sysdeps/mach/hurd/spawni.c -+++ b/sysdeps/mach/hurd/spawni.c -@@ -239,7 +239,7 @@ - - _hurd_sigstate_lock (ss); - ints[INIT_SIGMASK] = ss->blocked; -- ints[INIT_SIGPENDING] = _hurd_sigstate_pending (ss); /* XXX really? */ -+ ints[INIT_SIGPENDING] = 0; - ints[INIT_SIGIGN] = 0; - /* Unless we were asked to reset all handlers to SIG_DFL, - pass down the set of signals that were set to SIG_IGN. */ diff --git a/debian/patches/hurd-i386/git-hurdsig-fixes.diff b/debian/patches/hurd-i386/git-hurdsig-fixes.diff deleted file mode 100644 index 8f27f366..00000000 --- a/debian/patches/hurd-i386/git-hurdsig-fixes.diff +++ /dev/null @@ -1,366 +0,0 @@ -Committed for glibc 2.31 - -From: Jeremie Koenig <jk@jk.fr.eu.org> -Subject: [PATCH] Signal code refactoring. - -These patches should not change the current -behavior, although they do fix a few minor bugs which were made -apparent in the process. They are unchanged from my previous post -earlier this month. - - 34f5960 _hurd_internal_post_signal: Split into more functions - 420eec9 _hurd_internal_post_signal: Scope variables more restrictively - 1f5accd _hurd_internal_post_signal: Split out inner functions - 1bb0a1d Hurd signals: refactor check_pending_signals - 1764465 Hurd signals: reindent - 28473d2 Hurd signals: make sigsuspend POSIX-conformant. - 26d091a Hurd signals: fix uninitialized value. - ---- - hurd/hurdsig.c | 274 +++++++++++++++++++++++++++++++++------------------------ - 1 file changed, 161 insertions(+), 113 deletions(-) - ---- a/hurd/hurdsig.c -+++ b/hurd/hurdsig.c -@@ -445,6 +445,30 @@ abort_all_rpcs (int signo, struct machin - } - } - -+/* Wake up any sigsuspend call that is blocking SS->thread. SS must be -+ locked. */ -+static void -+wake_sigsuspend (struct hurd_sigstate *ss) -+{ -+ error_t err; -+ mach_msg_header_t msg; -+ -+ if (ss->suspended == MACH_PORT_NULL) -+ return; -+ -+ /* There is a sigsuspend waiting. Tell it to wake up. */ -+ msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0); -+ msg.msgh_remote_port = ss->suspended; -+ msg.msgh_local_port = MACH_PORT_NULL; -+ /* These values do not matter. */ -+ msg.msgh_id = 8675309; /* Jenny, Jenny. */ -+ ss->suspended = MACH_PORT_NULL; -+ err = __mach_msg (&msg, MACH_SEND_MSG, sizeof msg, 0, -+ MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, -+ MACH_PORT_NULL); -+ assert_perror (err); -+} -+ - struct hurd_signal_preemptor *_hurdsig_preemptors = 0; - sigset_t _hurdsig_preempted_set; - -@@ -455,35 +479,18 @@ weak_alias (_hurdsig_preemptors, _hurdsi - #define STOPSIGS (sigmask (SIGTTIN) | sigmask (SIGTTOU) \ - | sigmask (SIGSTOP) | sigmask (SIGTSTP)) - --/* Deliver a signal. SS is not locked. */ --void --_hurd_internal_post_signal (struct hurd_sigstate *ss, -- int signo, struct hurd_signal_detail *detail, -- mach_port_t reply_port, -- mach_msg_type_name_t reply_port_type, -- int untraced) -+/* Actual delivery of a single signal. Called with SS unlocked. When -+ the signal is delivered, return 1 with SS locked. If the signal is -+ being traced, return 0 with SS unlocked. */ -+static int -+post_signal (struct hurd_sigstate *ss, -+ int signo, struct hurd_signal_detail *detail, -+ int untraced, void (*reply) (void)) - { -- error_t err; - struct machine_thread_all_state thread_state; - enum { stop, ignore, core, term, handle } act; -- sighandler_t handler; -- sigset_t pending; - int ss_suspended; - -- /* Reply to this sig_post message. */ -- __typeof (__msg_sig_post_reply) *reply_rpc -- = (untraced ? __msg_sig_post_untraced_reply : __msg_sig_post_reply); -- void reply (void) -- { -- error_t err; -- if (reply_port == MACH_PORT_NULL) -- return; -- err = (*reply_rpc) (reply_port, reply_port_type, 0); -- reply_port = MACH_PORT_NULL; -- if (err != MACH_SEND_INVALID_DEST) /* Ignore dead reply port. */ -- assert_perror (err); -- } -- - /* Mark the signal as pending. */ - void mark_pending (void) - { -@@ -547,19 +554,23 @@ _hurd_internal_post_signal (struct hurd_ - ss_suspended = 1; - } - -+ error_t err; -+ sighandler_t handler; -+ - if (signo == 0) - { - if (untraced) -- /* This is PTRACE_CONTINUE. */ -- resume (); -+ { -+ /* This is PTRACE_CONTINUE. */ -+ act = ignore; -+ resume (); -+ } - - /* This call is just to check for pending signals. */ - __spin_lock (&ss->lock); -- goto check_pending_signals; -+ return 1; - } - -- post_signal: -- - thread_state.set = 0; /* We know nothing. */ - - __spin_lock (&ss->lock); -@@ -622,7 +633,7 @@ _hurd_internal_post_signal (struct hurd_ - suspend (); - __spin_unlock (&ss->lock); - reply (); -- return; -+ return 0; - } - - handler = ss->actions[signo].sa_handler; -@@ -866,7 +877,7 @@ _hurd_internal_post_signal (struct hurd_ - as a unit. */ - crit ? 0 : signo, 1, - &thread_state, &state_changed, -- &reply) -+ reply) - != MACH_PORT_NULL); - - if (crit) -@@ -953,6 +964,9 @@ _hurd_internal_post_signal (struct hurd_ - && signo != SIGILL && signo != SIGTRAP) - ss->actions[signo].sa_handler = SIG_DFL; - -+ /* Any sigsuspend call must return after the handler does. */ -+ wake_sigsuspend (ss); -+ - /* Start the thread running the handler (or possibly waiting for an - RPC reply before running the handler). */ - err = __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR, -@@ -966,95 +980,129 @@ _hurd_internal_post_signal (struct hurd_ - } - } - -- /* The signal has either been ignored or is now being handled. We can -- consider it delivered and reply to the killer. */ -- reply (); -+ return 1; -+} - -- /* We get here unless the signal was fatal. We still hold SS->lock. -- Check for pending signals, and loop to post them. */ -- { -- /* Return nonzero if SS has any signals pending we should worry about. -- We don't worry about any pending signals if we are stopped, nor if -- SS is in a critical section. We are guaranteed to get a sig_post -- message before any of them become deliverable: either the SIGCONT -- signal, or a sig_post with SIGNO==0 as an explicit poll when the -- thread finishes its critical section. */ -- inline int signals_pending (void) -- { -- if (_hurd_stopped || __spin_lock_locked (&ss->critical_section_lock)) -- return 0; -- return pending = ss->pending & ~ss->blocked; -- } -+/* Return the set of pending signals in SS which should be delivered. */ -+static sigset_t -+pending_signals (struct hurd_sigstate *ss) -+{ -+ /* We don't worry about any pending signals if we are stopped, nor if -+ SS is in a critical section. We are guaranteed to get a sig_post -+ message before any of them become deliverable: either the SIGCONT -+ signal, or a sig_post with SIGNO==0 as an explicit poll when the -+ thread finishes its critical section. */ -+ if (_hurd_stopped || __spin_lock_locked (&ss->critical_section_lock)) -+ return 0; - -- check_pending_signals: -- untraced = 0; -+ return ss->pending & ~ss->blocked; -+} - -- if (signals_pending ()) -- { -- for (signo = 1; signo < NSIG; ++signo) -- if (__sigismember (&pending, signo)) -- { -- deliver_pending: -- __sigdelset (&ss->pending, signo); -- *detail = ss->pending_data[signo]; -- __spin_unlock (&ss->lock); -- goto post_signal; -- } -- } -+/* Post the specified pending signals in SS and return 1. If one of -+ them is traced, abort immediately and return 0. SS must be locked on -+ entry and will be unlocked in all cases. */ -+static int -+post_pending (struct hurd_sigstate *ss, sigset_t pending, void (*reply) (void)) -+{ -+ int signo; -+ struct hurd_signal_detail detail; - -- /* No pending signals left undelivered for this thread. -- If we were sent signal 0, we need to check for pending -- signals for all threads. */ -- if (signo == 0) -- { -- __spin_unlock (&ss->lock); -- __mutex_lock (&_hurd_siglock); -- for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) -- { -- __spin_lock (&ss->lock); -- for (signo = 1; signo < NSIG; ++signo) -- if (__sigismember (&ss->pending, signo) -- && (!__sigismember (&ss->blocked, signo) -- /* We "deliver" immediately pending blocked signals whose -- action might be to ignore, so that if ignored they are -- dropped right away. */ -- || ss->actions[signo].sa_handler == SIG_IGN -- || ss->actions[signo].sa_handler == SIG_DFL)) -- { -- __mutex_unlock (&_hurd_siglock); -- goto deliver_pending; -- } -- __spin_unlock (&ss->lock); -- } -- __mutex_unlock (&_hurd_siglock); -- } -- else -+ for (signo = 1; signo < NSIG; ++signo) -+ if (__sigismember (&pending, signo)) - { -- /* No more signals pending; SS->lock is still locked. -- Wake up any sigsuspend call that is blocking SS->thread. */ -- if (ss->suspended != MACH_PORT_NULL) -- { -- /* There is a sigsuspend waiting. Tell it to wake up. */ -- error_t err; -- mach_msg_header_t msg; -- msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0); -- msg.msgh_remote_port = ss->suspended; -- msg.msgh_local_port = MACH_PORT_NULL; -- /* These values do not matter. */ -- msg.msgh_id = 8675309; /* Jenny, Jenny. */ -- ss->suspended = MACH_PORT_NULL; -- err = __mach_msg (&msg, MACH_SEND_MSG, sizeof msg, 0, -- MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, -- MACH_PORT_NULL); -- assert_perror (err); -- } -+ __sigdelset (&ss->pending, signo); -+ detail = ss->pending_data[signo]; - __spin_unlock (&ss->lock); -+ -+ /* Will reacquire the lock, except if the signal is traced. */ -+ if (! post_signal (ss, signo, &detail, 0, reply)) -+ return 0; - } -- } - -- /* All pending signals delivered to all threads. -- Now we can send the reply message even for signal 0. */ -- reply (); -+ /* No more signals pending; SS->lock is still locked. */ -+ __spin_unlock (&ss->lock); -+ -+ return 1; -+} -+ -+/* Post all the pending signals of all threads and return 1. If a traced -+ signal is encountered, abort immediately and return 0. */ -+static int -+post_all_pending_signals (void (*reply) (void)) -+{ -+ struct hurd_sigstate *ss; -+ sigset_t pending = 0; -+ -+ for (;;) -+ { -+ __mutex_lock (&_hurd_siglock); -+ for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) -+ { -+ __spin_lock (&ss->lock); -+ -+ pending = pending_signals (ss); -+ if (pending) -+ /* post_pending() below will unlock SS. */ -+ break; -+ -+ __spin_unlock (&ss->lock); -+ } -+ __mutex_unlock (&_hurd_siglock); -+ -+ if (! pending) -+ return 1; -+ if (! post_pending (ss, pending, reply)) -+ return 0; -+ } -+} -+ -+/* Deliver a signal. SS is not locked. */ -+void -+_hurd_internal_post_signal (struct hurd_sigstate *ss, -+ int signo, struct hurd_signal_detail *detail, -+ mach_port_t reply_port, -+ mach_msg_type_name_t reply_port_type, -+ int untraced) -+{ -+ /* Reply to this sig_post message. */ -+ __typeof (__msg_sig_post_reply) *reply_rpc -+ = (untraced ? __msg_sig_post_untraced_reply : __msg_sig_post_reply); -+ void reply (void) -+ { -+ error_t err; -+ if (reply_port == MACH_PORT_NULL) -+ return; -+ err = (*reply_rpc) (reply_port, reply_port_type, 0); -+ reply_port = MACH_PORT_NULL; -+ if (err != MACH_SEND_INVALID_DEST) /* Ignore dead reply port. */ -+ assert_perror (err); -+ } -+ -+ if (! post_signal (ss, signo, detail, untraced, reply)) -+ return; -+ -+ /* The signal was neither fatal nor traced. We still hold SS->lock. */ -+ if (signo != 0) -+ { -+ /* The signal has either been ignored or is now being handled. We can -+ consider it delivered and reply to the killer. */ -+ reply (); -+ -+ /* Post any pending signals for this thread. */ -+ if (! post_pending (ss, pending_signals (ss), reply)) -+ return; -+ } -+ else -+ { -+ /* We need to check for pending signals for all threads. */ -+ __spin_unlock (&ss->lock); -+ if (! post_all_pending_signals (reply)) -+ return; -+ -+ /* All pending signals delivered to all threads. -+ Now we can send the reply message even for signal 0. */ -+ reply (); -+ } - } - - /* Decide whether REFPORT enables the sender to send us a SIGNO signal. diff --git a/debian/patches/hurd-i386/git-hurdsig-global-dispositions.diff b/debian/patches/hurd-i386/git-hurdsig-global-dispositions.diff deleted file mode 100644 index e00f1046..00000000 --- a/debian/patches/hurd-i386/git-hurdsig-global-dispositions.diff +++ /dev/null @@ -1,1188 +0,0 @@ -Committed for glibc 2.31 - -Subject: [PATCH] Global signal dispositions. - -Although they should not change the -default behaviors of signals for cthread programs, these patches add -new functions which can be used by libpthread to enable -POSIX-conforming behavior of signals on a per-thread basis. - -YYYY-MM-DD Jeremie Koenig <jk@jk.fr.eu.org> - - e407ae3 Hurd signals: implement global signal dispositions - 38eb4b3 Hurd signals: provide a sigstate destructor - 344dfd6 Hurd signals: fix sigwait() for global signals - fb055f2 Hurd signals: fix global untraced signals. - -YYYY-MM-DD Thomas Schwinge <thomas@codesourcery.com> - - * sysdeps/mach/hurd/fork.c (__fork): In the child, reinitialize - the global sigstate's lock. - -This is work in progress. - -This cures an issue that would very rarely cause a deadlock in the child -in fork, tries to unlock ss' critical section lock at the end of fork. -This will typically (always?) be observed in /bin/sh, which is not -surprising as that is the foremost caller of fork. - -To reproduce an intermediate state, add an endless loop if -_hurd_global_sigstate is locked after __proc_dostop (cast through -volatile); that is, while still being in the fork's parent process. - -When that triggers (use the libtool testsuite), the signal thread has -already locked ss (which is _hurd_global_sigstate), and is stuck at -hurdsig.c:685 in post_signal, trying to lock _hurd_siglock (which the -main thread already has locked and keeps locked until after -__task_create). This is the case that ss->thread == MACH_PORT_NULL, that -is, a global signal. In the main thread, between __proc_dostop and -__task_create is the __thread_abort call on the signal thread which would -abort any current kernel operation (but leave ss locked). Later in fork, -in the parent, when _hurd_siglock is unlocked in fork, the parent's -signal thread can proceed and will unlock eventually the global sigstate. -In the client, _hurd_siglock will likewise be unlocked, but the global -sigstate never will be, as the client's signal thread has been configured -to restart execution from _hurd_msgport_receive. Thus, when the child -tries to unlock ss' critical section lock at the end of fork, it will -first lock the global sigstate, will spin trying to lock it, which can -never be successful, and we get our deadlock. - -Options seem to be: - - * Move the locking of _hurd_siglock earlier in post_signal -- but that - may generally impact performance, if this locking isn't generally - needed anyway? - - On the other hand, would it actually make sense to wait here until we - are not any longer in a critical section (which is meant to disable - signal delivery anyway (but not for preempted signals?))? - - * Clear the global sigstate in the fork's child with the rationale that - we're anyway restarting the signal thread from a clean state. This - has now been implemented. - -Why has this problem not been observed before Jérémie's patches? (Or has -it? Perhaps even more rarely?) In _S_msg_sig_post, the signal is now -posted to a *global receiver thread*, whereas previously it was posted to -the *designated signal-receiving thread*. The latter one was in a -critical section in fork, so didn't try to handle the signal until after -leaving the critical section? (Not completely analyzed and verified.) - -Another question is what the signal is that is being received -during/around the time __proc_dostop executes. - ---- - hurd/ctty-input.c | 16 +- - hurd/ctty-output.c | 16 +- - hurd/hurd/signal.h | 38 +++-- - hurd/hurdexec.c | 9 - - hurd/hurdmsg.c | 24 --- - hurd/hurdsig.c | 272 +++++++++++++++++++++++++++--------- - sysdeps/mach/hurd/fork.c | 24 ++- - sysdeps/mach/hurd/i386/sigreturn.c | 10 - - sysdeps/mach/hurd/i386/trampoline.c | 6 - sysdeps/mach/hurd/sigaction.c | 16 +- - sysdeps/mach/hurd/sigpending.c | 6 - sysdeps/mach/hurd/sigprocmask.c | 8 - - sysdeps/mach/hurd/sigsuspend.c | 15 + - sysdeps/mach/hurd/sigwait.c | 21 +- - sysdeps/mach/hurd/spawni.c | 23 +-- - 15 files changed, 348 insertions(+), 156 deletions(-) - ---- a/hurd/ctty-input.c -+++ b/hurd/ctty-input.c -@@ -43,12 +43,15 @@ - else - { - struct hurd_sigstate *ss = _hurd_self_sigstate (); -- __spin_lock (&ss->lock); -+ struct sigaction *actions; -+ -+ _hurd_sigstate_lock (ss); -+ actions = _hurd_sigstate_actions (ss); - if (__sigismember (&ss->blocked, SIGTTIN) -- || ss->actions[SIGTTIN].sa_handler == SIG_IGN) -+ || actions[SIGTTIN].sa_handler == SIG_IGN) - /* We are blocking or ignoring SIGTTIN. Just fail. */ - err = EIO; -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - if (err == EBACKGROUND) - { -@@ -65,10 +68,11 @@ - SIGTTIN or resumed after being stopped. Now this is - still a "system call", so check to see if we should - restart it. */ -- __spin_lock (&ss->lock); -- if (!(ss->actions[SIGTTIN].sa_flags & SA_RESTART)) -+ _hurd_sigstate_lock (ss); -+ actions = _hurd_sigstate_actions (ss); -+ if (!(actions[SIGTTIN].sa_flags & SA_RESTART)) - err = EINTR; -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - } - } - } ---- a/hurd/ctty-output.c -+++ b/hurd/ctty-output.c -@@ -34,16 +34,19 @@ - - do - { -+ struct sigaction *actions; -+ - /* Don't use the ctty io port if we are blocking or ignoring - SIGTTOU. We redo this check at the top of the loop in case - the signal handler changed the state. */ -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); -+ actions = _hurd_sigstate_actions (ss); - if (__sigismember (&ss->blocked, SIGTTOU) -- || ss->actions[SIGTTOU].sa_handler == SIG_IGN) -+ || actions[SIGTTOU].sa_handler == SIG_IGN) - err = EIO; - else - err = 0; -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - if (err) - return (*rpc) (port); -@@ -70,10 +73,11 @@ - SIGTTOU or resumed after being stopped. Now this is - still a "system call", so check to see if we should - restart it. */ -- __spin_lock (&ss->lock); -- if (!(ss->actions[SIGTTOU].sa_flags & SA_RESTART)) -+ _hurd_sigstate_lock (ss); -+ actions = _hurd_sigstate_actions (ss); -+ if (!(actions[SIGTTOU].sa_flags & SA_RESTART)) - err = EINTR; -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - } - } - /* If the last RPC generated a SIGTTOU, loop to try it again. */ ---- a/hurd/hurd/signal.h -+++ b/hurd/hurd/signal.h -@@ -73,7 +73,13 @@ - - sigset_t blocked; /* What signals are blocked. */ - sigset_t pending; /* Pending signals, possibly blocked. */ -+ -+ /* Signal handlers. ACTIONS[0] is used to mark the threads with POSIX -+ semantics: if sa_handler is SIG_IGN instead of SIG_DFL, this thread -+ will receive global signals and use the process-wide action vector -+ instead of this one. */ - struct sigaction actions[_NSIG]; -+ - stack_t sigaltstack; - - /* Chain of thread-local signal preemptors; see <hurd/sigpreempt.h>. -@@ -129,6 +135,26 @@ - by different threads. */ - __attribute__ ((__const__)); - -+/* Process-wide signal state. */ -+ -+extern struct hurd_sigstate *_hurd_global_sigstate; -+ -+/* Mark the given thread as a process-wide signal receiver. */ -+ -+extern void _hurd_sigstate_set_global_rcv (struct hurd_sigstate *ss); -+ -+/* A thread can either use its own action vector and pending signal set -+ or use the global ones, depending on wether it has been marked as a -+ global receiver. The accessors below take that into account. */ -+ -+extern void _hurd_sigstate_lock (struct hurd_sigstate *ss); -+extern struct sigaction *_hurd_sigstate_actions (struct hurd_sigstate *ss); -+extern sigset_t _hurd_sigstate_pending (const struct hurd_sigstate *ss); -+extern void _hurd_sigstate_unlock (struct hurd_sigstate *ss); -+ -+/* Used by libpthread to remove stale sigstate structures. */ -+extern void _hurd_sigstate_delete (thread_t thread); -+ - #ifndef _HURD_SIGNAL_H_EXTERN_INLINE - #define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline - #endif -@@ -154,12 +180,6 @@ - - extern mach_port_t _hurd_msgport; - -- --/* Thread to receive process-global signals. */ -- --extern thread_t _hurd_sigthread; -- -- - /* Resource limit on core file size. Enforced by hurdsig.c. */ - extern int _hurd_core_limit; - -@@ -222,10 +242,10 @@ - /* It was us who acquired the critical section lock. Unlock it. */ - struct hurd_sigstate *ss = (struct hurd_sigstate *) our_lock; - sigset_t pending; -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - __spin_unlock (&ss->critical_section_lock); -- pending = ss->pending & ~ss->blocked; -- __spin_unlock (&ss->lock); -+ pending = _hurd_sigstate_pending(ss) & ~ss->blocked; -+ _hurd_sigstate_unlock (ss); - if (! __sigisemptyset (&pending)) - /* There are unblocked signals pending, which weren't - delivered because we were in the critical section. ---- a/hurd/hurdexec.c -+++ b/hurd/hurdexec.c -@@ -125,12 +125,13 @@ - - __spin_lock (&ss->critical_section_lock); - -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); -+ struct sigaction *actions = _hurd_sigstate_actions (ss); - ints[INIT_SIGMASK] = ss->blocked; -- ints[INIT_SIGPENDING] = ss->pending; -+ ints[INIT_SIGPENDING] = _hurd_sigstate_pending (ss); - ints[INIT_SIGIGN] = 0; - for (i = 1; i < NSIG; ++i) -- if (ss->actions[i].sa_handler == SIG_IGN) -+ if (actions[i].sa_handler == SIG_IGN) - ints[INIT_SIGIGN] |= __sigmask (i); - - /* We hold the sigstate lock until the exec has failed so that no signal -@@ -141,7 +142,7 @@ - critical section flag avoids anything we call trying to acquire the - sigstate lock. */ - -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - /* Pack up the descriptor table to give the new program. */ - __mutex_lock (&_hurd_dtable_lock); ---- a/hurd/hurdmsg.c -+++ b/hurd/hurdmsg.c -@@ -121,17 +121,9 @@ - case INIT_UMASK: - *value = _hurd_umask; - return 0; -- case INIT_SIGMASK: -- { -- struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); -- __spin_lock (&ss->lock); -- *value = ss->blocked; -- __spin_unlock (&ss->lock); -- return 0; -- } - case INIT_SIGPENDING: - { -- struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); -+ struct hurd_sigstate *ss = _hurd_global_sigstate; - __spin_lock (&ss->lock); - *value = ss->pending; - __spin_unlock (&ss->lock); -@@ -139,7 +131,7 @@ - } - case INIT_SIGIGN: - { -- struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); -+ struct hurd_sigstate *ss = _hurd_global_sigstate; - sigset_t ign; - int sig; - __spin_lock (&ss->lock); -@@ -207,17 +199,9 @@ - return 0; - - /* These are pretty odd things to do. But you asked for it. */ -- case INIT_SIGMASK: -- { -- struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); -- __spin_lock (&ss->lock); -- ss->blocked = value; -- __spin_unlock (&ss->lock); -- return 0; -- } - case INIT_SIGPENDING: - { -- struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); -+ struct hurd_sigstate *ss = _hurd_global_sigstate; - __spin_lock (&ss->lock); - ss->pending = value; - __spin_unlock (&ss->lock); -@@ -225,7 +209,7 @@ - } - case INIT_SIGIGN: - { -- struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); -+ struct hurd_sigstate *ss = _hurd_global_sigstate; - int sig; - const sigset_t ign = value; - __spin_lock (&ss->lock); ---- a/hurd/hurdsig.c -+++ b/hurd/hurdsig.c -@@ -46,9 +46,6 @@ - /* Thread listening on it. */ - thread_t _hurd_msgport_thread; - --/* Thread which receives task-global signals. */ --thread_t _hurd_sigthread; -- - /* These are set up by _hurdsig_init. */ - unsigned long int __hurd_sigthread_stack_base; - unsigned long int __hurd_sigthread_stack_end; -@@ -56,6 +53,9 @@ - /* Linked-list of per-thread signal state. */ - struct hurd_sigstate *_hurd_sigstates; - -+/* Sigstate for the task-global signals. */ -+struct hurd_sigstate *_hurd_global_sigstate; -+ - /* Timeout for RPC's after interrupt_operation. */ - mach_msg_timeout_t _hurd_interrupted_rpc_timeout = 60000; - -@@ -84,7 +84,7 @@ - { - ss = malloc (sizeof (*ss)); - if (ss == NULL) -- __libc_fatal ("hurd: Can't allocate thread sigstate\n"); -+ __libc_fatal ("hurd: Can't allocate sigstate\n"); - ss->thread = thread; - __spin_lock_init (&ss->lock); - -@@ -97,16 +97,19 @@ - ss->intr_port = MACH_PORT_NULL; - ss->context = NULL; - -- /* Initialize the sigaction vector from the default signal receiving -- thread's state, and its from the system defaults. */ -- if (thread == _hurd_sigthread) -- default_sigaction (ss->actions); -+ if (thread == MACH_PORT_NULL) -+ { -+ /* Process-wide sigstate, use the system defaults. */ -+ default_sigaction (ss->actions); -+ -+ /* The global sigstate is not added to the _hurd_sigstates list. -+ It is created with _hurd_thread_sigstate (MACH_PORT_NULL) -+ but should be accessed through _hurd_global_sigstate. */ -+ } - else - { -- struct hurd_sigstate *s; -- for (s = _hurd_sigstates; s != NULL; s = s->next) -- if (s->thread == _hurd_sigthread) -- break; -+ /* Use the global actions as a default for new threads. */ -+ struct hurd_sigstate *s = _hurd_global_sigstate; - if (s) - { - __spin_lock (&s->lock); -@@ -115,15 +118,109 @@ - } - else - default_sigaction (ss->actions); -- } - -- ss->next = _hurd_sigstates; -- _hurd_sigstates = ss; -+ ss->next = _hurd_sigstates; -+ _hurd_sigstates = ss; -+ } - } - __mutex_unlock (&_hurd_siglock); - return ss; - } - libc_hidden_def (_hurd_thread_sigstate) -+ -+/* Destroy a sigstate structure. Called by libpthread just before the -+ * corresponding thread is terminated (the kernel thread port must remain valid -+ * until this function is called.) */ -+void -+_hurd_sigstate_delete (thread_t thread) -+{ -+ struct hurd_sigstate **ssp, *ss; -+ -+ __mutex_lock (&_hurd_siglock); -+ for (ssp = &_hurd_sigstates; *ssp; ssp = &(*ssp)->next) -+ if ((*ssp)->thread == thread) -+ break; -+ -+ ss = *ssp; -+ if (ss) -+ *ssp = ss->next; -+ -+ __mutex_unlock (&_hurd_siglock); -+ if (ss) -+ free (ss); -+} -+ -+/* Make SS a global receiver, with pthread signal semantics. */ -+void -+_hurd_sigstate_set_global_rcv (struct hurd_sigstate *ss) -+{ -+ assert (ss->thread != MACH_PORT_NULL); -+ ss->actions[0].sa_handler = SIG_IGN; -+} -+ -+/* Check whether SS is a global receiver. */ -+static int -+sigstate_is_global_rcv (const struct hurd_sigstate *ss) -+{ -+ return ss->actions[0].sa_handler == SIG_IGN; -+} -+ -+/* Lock/unlock a hurd_sigstate structure. If the accessors below require -+ it, the global sigstate will be locked as well. */ -+void -+_hurd_sigstate_lock (struct hurd_sigstate *ss) -+{ -+ if (sigstate_is_global_rcv (ss)) -+ __spin_lock (&_hurd_global_sigstate->lock); -+ __spin_lock (&ss->lock); -+} -+void -+_hurd_sigstate_unlock (struct hurd_sigstate *ss) -+{ -+ __spin_unlock (&ss->lock); -+ if (sigstate_is_global_rcv (ss)) -+ __spin_unlock (&_hurd_global_sigstate->lock); -+} -+ -+/* Retreive a thread's full set of pending signals, including the global -+ ones if appropriate. SS must be locked. */ -+sigset_t -+_hurd_sigstate_pending (const struct hurd_sigstate *ss) -+{ -+ sigset_t pending = ss->pending; -+ if (sigstate_is_global_rcv (ss)) -+ __sigorset (&pending, &pending, &_hurd_global_sigstate->pending); -+ return pending; -+} -+ -+/* Clear a pending signal and return the associated detailed -+ signal information. SS must be locked, and must have signal SIGNO -+ pending, either directly or through the global sigstate. */ -+static struct hurd_signal_detail -+sigstate_clear_pending (struct hurd_sigstate *ss, int signo) -+{ -+ if (sigstate_is_global_rcv (ss) -+ && __sigismember (&_hurd_global_sigstate->pending, signo)) -+ { -+ __sigdelset (&_hurd_global_sigstate->pending, signo); -+ return _hurd_global_sigstate->pending_data[signo]; -+ } -+ -+ assert (__sigismember (&ss->pending, signo)); -+ __sigdelset (&ss->pending, signo); -+ return ss->pending_data[signo]; -+} -+ -+/* Retreive a thread's action vector. SS must be locked. */ -+struct sigaction * -+_hurd_sigstate_actions (struct hurd_sigstate *ss) -+{ -+ if (sigstate_is_global_rcv (ss)) -+ return _hurd_global_sigstate->actions; -+ else -+ return ss->actions; -+} -+ - - /* Signal delivery itself is on this page. */ - -@@ -218,6 +315,8 @@ - abort_thread (struct hurd_sigstate *ss, struct machine_thread_all_state *state, - void (*reply) (void)) - { -+ assert (ss->thread != MACH_PORT_NULL); -+ - if (!(state->set & THREAD_ABORTED)) - { - error_t err = __thread_abort (ss->thread); -@@ -364,7 +463,7 @@ - call above will retry their RPCs unless we clear SS->intr_port. - So we clear it for the thread taking a signal when SA_RESTART is - clear, so that its call returns EINTR. */ -- if (! signo || !(ss->actions[signo].sa_flags & SA_RESTART)) -+ if (! signo || !(_hurd_sigstate_actions (ss) [signo].sa_flags & SA_RESTART)) - ss->intr_port = MACH_PORT_NULL; - } - -@@ -487,9 +586,11 @@ - | sigmask (SIGSTOP) | sigmask (SIGTSTP)) - - /* Actual delivery of a single signal. Called with SS unlocked. When -- the signal is delivered, return 1 with SS locked. If the signal is -- being traced, return 0 with SS unlocked. */ --static int -+ the signal is delivered, return SS, locked (or, if SS was originally -+ _hurd_global_sigstate, the sigstate of the actual thread the signal -+ was delivered to). If the signal is being traced, return NULL with -+ SS unlocked. */ -+static struct hurd_sigstate * - post_signal (struct hurd_sigstate *ss, - int signo, struct hurd_signal_detail *detail, - int untraced, void (*reply) (void)) -@@ -542,8 +643,12 @@ - assert_perror (err); - for (i = 0; i < nthreads; ++i) - { -- if (threads[i] != _hurd_msgport_thread -- && (act != handle || threads[i] != ss->thread)) -+ if (act == handle && threads[i] == ss->thread) -+ { -+ /* The thread that will run the handler is kept suspended. */ -+ ss_suspended = 1; -+ } -+ else if (threads[i] != _hurd_msgport_thread) - { - err = __thread_resume (threads[i]); - assert_perror (err); -@@ -556,9 +661,6 @@ - (vm_address_t) threads, - nthreads * sizeof *threads); - _hurd_stopped = 0; -- if (act == handle) -- /* The thread that will run the handler is already suspended. */ -- ss_suspended = 1; - } - - error_t err; -@@ -574,13 +676,43 @@ - } - - /* This call is just to check for pending signals. */ -- __spin_lock (&ss->lock); -- return 1; -+ _hurd_sigstate_lock (ss); -+ return ss; - } - - thread_state.set = 0; /* We know nothing. */ - -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); -+ -+ /* If this is a global signal, try to find a thread ready to accept -+ it right away. This is especially important for untraced signals, -+ since going through the global pending mask would de-untrace them. */ -+ if (ss->thread == MACH_PORT_NULL) -+ { -+ struct hurd_sigstate *rss; -+ -+ __mutex_lock (&_hurd_siglock); -+ for (rss = _hurd_sigstates; rss != NULL; rss = rss->next) -+ { -+ if (! sigstate_is_global_rcv (rss)) -+ continue; -+ -+ /* The global sigstate is already locked. */ -+ __spin_lock (&rss->lock); -+ if (! __sigismember (&rss->blocked, signo)) -+ { -+ ss = rss; -+ break; -+ } -+ __spin_unlock (&rss->lock); -+ } -+ __mutex_unlock (&_hurd_siglock); -+ } -+ -+ /* We want the preemptors to be able to update the blocking mask -+ without affecting the delivery of this signal, so we save the -+ current value to test against later. */ -+ sigset_t blocked = ss->blocked; - - /* Check for a preempted signal. Preempted signals can arrive during - critical sections. */ -@@ -638,12 +770,12 @@ - mark_pending (); - else - suspend (); -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - reply (); -- return 0; -+ return NULL; - } - -- handler = ss->actions[signo].sa_handler; -+ handler = _hurd_sigstate_actions (ss) [signo].sa_handler; - - if (handler == SIG_DFL) - /* Figure out the default action for this signal. */ -@@ -737,7 +869,7 @@ - - /* Handle receipt of a blocked signal, or any signal while stopped. */ - if (act != ignore /* Signals ignored now are forgotten now. */ -- && __sigismember (&ss->blocked, signo) -+ && __sigismember (&blocked, signo) - || (signo != SIGKILL && _hurd_stopped)) - { - mark_pending (); -@@ -773,6 +905,7 @@ - now's the time to set it going. */ - if (ss_suspended) - { -+ assert (ss->thread != MACH_PORT_NULL); - err = __thread_resume (ss->thread); - assert_perror (err); - ss_suspended = 0; -@@ -817,6 +950,8 @@ - struct sigcontext *scp, ocontext; - int wait_for_reply, state_changed; - -+ assert (ss->thread != MACH_PORT_NULL); -+ - /* Stop the thread and abort its pending RPC operations. */ - if (! ss_suspended) - { -@@ -953,23 +1088,25 @@ - } - } - -+ struct sigaction *action = & _hurd_sigstate_actions (ss) [signo]; -+ - /* Backdoor extra argument to signal handler. */ - scp->sc_error = detail->error; - - /* Block requested signals while running the handler. */ - scp->sc_mask = ss->blocked; -- __sigorset (&ss->blocked, &ss->blocked, &ss->actions[signo].sa_mask); -+ __sigorset (&ss->blocked, &ss->blocked, &action->sa_mask); - - /* Also block SIGNO unless we're asked not to. */ -- if (! (ss->actions[signo].sa_flags & (SA_RESETHAND | SA_NODEFER))) -+ if (! (action->sa_flags & (SA_RESETHAND | SA_NODEFER))) - __sigaddset (&ss->blocked, signo); - - /* Reset to SIG_DFL if requested. SIGILL and SIGTRAP cannot - be automatically reset when delivered; the system silently - enforces this restriction. */ -- if (ss->actions[signo].sa_flags & SA_RESETHAND -+ if (action->sa_flags & SA_RESETHAND - && signo != SIGILL && signo != SIGTRAP) -- ss->actions[signo].sa_handler = SIG_DFL; -+ action->sa_handler = SIG_DFL; - - /* Any sigsuspend call must return after the handler does. */ - wake_sigsuspend (ss); -@@ -987,7 +1124,7 @@ - } - } - -- return 1; -+ return ss; - } - - /* Return the set of pending signals in SS which should be delivered. */ -@@ -1002,7 +1139,7 @@ - if (_hurd_stopped || __spin_lock_locked (&ss->critical_section_lock)) - return 0; - -- return ss->pending & ~ss->blocked; -+ return _hurd_sigstate_pending (ss) & ~ss->blocked; - } - - /* Post the specified pending signals in SS and return 1. If one of -@@ -1014,12 +1151,15 @@ - int signo; - struct hurd_signal_detail detail; - -+ /* Make sure SS corresponds to an actual thread, since we assume it won't -+ change in post_signal. */ -+ assert (ss->thread != MACH_PORT_NULL); -+ - for (signo = 1; signo < NSIG; ++signo) - if (__sigismember (&pending, signo)) - { -- __sigdelset (&ss->pending, signo); -- detail = ss->pending_data[signo]; -- __spin_unlock (&ss->lock); -+ detail = sigstate_clear_pending (ss, signo); -+ _hurd_sigstate_unlock (ss); - - /* Will reacquire the lock, except if the signal is traced. */ - if (! post_signal (ss, signo, &detail, 0, reply)) -@@ -1027,7 +1167,7 @@ - } - - /* No more signals pending; SS->lock is still locked. */ -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - return 1; - } -@@ -1045,14 +1185,14 @@ - __mutex_lock (&_hurd_siglock); - for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) - { -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - - pending = pending_signals (ss); - if (pending) - /* post_pending() below will unlock SS. */ - break; - -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - } - __mutex_unlock (&_hurd_siglock); - -@@ -1085,11 +1225,12 @@ - assert_perror (err); - } - -- if (! post_signal (ss, signo, detail, untraced, reply)) -+ ss = post_signal (ss, signo, detail, untraced, reply); -+ if (! ss) - return; - - /* The signal was neither fatal nor traced. We still hold SS->lock. */ -- if (signo != 0) -+ if (signo != 0 && ss->thread != MACH_PORT_NULL) - { - /* The signal has either been ignored or is now being handled. We can - consider it delivered and reply to the killer. */ -@@ -1101,8 +1242,9 @@ - } - else - { -- /* We need to check for pending signals for all threads. */ -- __spin_unlock (&ss->lock); -+ /* If this was a process-wide signal or a poll request, we need -+ to check for pending signals for all threads. */ -+ _hurd_sigstate_unlock (ss); - if (! post_all_pending_signals (reply)) - return; - -@@ -1228,9 +1370,10 @@ - d.code = sigcode; - d.exc = 0; - -- /* Post the signal to the designated signal-receiving thread. This will -- reply when the signal can be considered delivered. */ -- _hurd_internal_post_signal (_hurd_thread_sigstate (_hurd_sigthread), -+ /* Post the signal to a global receiver thread (or mark it pending in -+ the global sigstate). This will reply when the signal can be -+ considered delivered. */ -+ _hurd_internal_post_signal (_hurd_global_sigstate, - signo, &d, reply_port, reply_port_type, - 0); /* Stop if traced. */ - -@@ -1258,7 +1401,7 @@ - - /* Post the signal to the designated signal-receiving thread. This will - reply when the signal can be considered delivered. */ -- _hurd_internal_post_signal (_hurd_thread_sigstate (_hurd_sigthread), -+ _hurd_internal_post_signal (_hurd_global_sigstate, - signo, &d, reply_port, reply_port_type, - 1); /* Untraced flag. */ - -@@ -1269,8 +1412,8 @@ - - #include <mach/task_special_ports.h> - --/* Initialize the message port and _hurd_sigthread and start the signal -- thread. */ -+/* Initialize the message port, _hurd_global_sigstate, and start the -+ signal thread. */ - - void - _hurdsig_init (const int *intarray, size_t intarraysize) -@@ -1293,27 +1436,34 @@ - MACH_MSG_TYPE_MAKE_SEND); - assert_perror (err); - -+ /* Initialize the global signal state. */ -+ _hurd_global_sigstate = _hurd_thread_sigstate (MACH_PORT_NULL); -+ -+ /* We block all signals, and let actual threads pull them from the -+ pending mask. */ -+ __sigfillset(& _hurd_global_sigstate->blocked); -+ - /* Initialize the main thread's signal state. */ - ss = _hurd_self_sigstate (); - -- /* Copy inherited values from our parent (or pre-exec process state) -- into the signal settings of the main thread. */ -+ /* Mark it as a process-wide signal receiver. Threads in this set use -+ the common action vector in _hurd_global_sigstate. */ -+ _hurd_sigstate_set_global_rcv (ss); -+ -+ /* Copy inherited signal settings from our parent (or pre-exec process -+ state) */ - if (intarraysize > INIT_SIGMASK) - ss->blocked = intarray[INIT_SIGMASK]; - if (intarraysize > INIT_SIGPENDING) -- ss->pending = intarray[INIT_SIGPENDING]; -+ _hurd_global_sigstate->pending = intarray[INIT_SIGPENDING]; - if (intarraysize > INIT_SIGIGN && intarray[INIT_SIGIGN] != 0) - { - int signo; - for (signo = 1; signo < NSIG; ++signo) - if (intarray[INIT_SIGIGN] & __sigmask(signo)) -- ss->actions[signo].sa_handler = SIG_IGN; -+ _hurd_global_sigstate->actions[signo].sa_handler = SIG_IGN; - } - -- /* Set the default thread to receive task-global signals -- to this one, the main (first) user thread. */ -- _hurd_sigthread = ss->thread; -- - /* Start the signal thread listening on the message port. */ - - #pragma weak __cthread_fork ---- a/sysdeps/mach/hurd/fork.c -+++ b/sysdeps/mach/hurd/fork.c -@@ -444,6 +444,7 @@ - thread, - MACH_MSG_TYPE_COPY_SEND))) - LOSE; -+ /* XXX consumed? (_hurd_sigthread is no more) */ - if (thread_refs > 1 - && (err = __mach_port_mod_refs (newtask, ss->thread, - MACH_PORT_RIGHT_SEND, -@@ -608,10 +609,6 @@ - for (i = 0; i < _hurd_nports; ++i) - __spin_unlock (&_hurd_ports[i].lock); - -- /* We are one of the (exactly) two threads in this new task, we -- will take the task-global signals. */ -- _hurd_sigthread = ss->thread; -- - /* Claim our sigstate structure and unchain the rest: the - threads existed in the parent task but don't exist in this - task (the child process). Delay freeing them until later -@@ -631,6 +628,25 @@ - ss->next = NULL; - _hurd_sigstates = ss; - __mutex_unlock (&_hurd_siglock); -+ /* Earlier on, the global sigstate may have been tainted and now needs to -+ be reinitialized. Nobody is interested in its present state anymore: -+ we're not, the signal thread will be restarted, and there are no other -+ threads. -+ -+ We can't simply allocate a fresh global sigstate here, as -+ _hurd_thread_sigstate will call malloc and that will deadlock trying -+ to determine the current thread's sigstate. */ -+#if 0 -+ _hurd_thread_sigstate_init (_hurd_global_sigstate, MACH_PORT_NULL); -+#else -+ /* Only reinitialize the lock -- otherwise we might have to do additional -+ setup as done in hurdsig.c:_hurdsig_init. */ -+ __spin_lock_init (&_hurd_global_sigstate->lock); -+#endif -+ -+ /* We are one of the (exactly) two threads in this new task, we -+ will take the task-global signals. */ -+ _hurd_sigstate_set_global_rcv (ss); - - /* Fetch our new process IDs from the proc server. No need to - refetch our pgrp; it is always inherited from the parent (so ---- a/sysdeps/mach/hurd/i386/sigreturn.c -+++ b/sysdeps/mach/hurd/i386/sigreturn.c -@@ -38,7 +38,7 @@ - __sigreturn2 (int *usp) - { - struct hurd_sigstate *ss = _hurd_self_sigstate (); -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - sp = usp; - #define A(line) asm volatile (#line) -@@ -38,7 +38,7 @@ - } - - ss = _hurd_self_sigstate (); -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - - /* Remove the link on the `active resources' chain added by - _hurd_setup_sighandler. Its purpose was to make sure -@@ -50,19 +50,19 @@ - ss->intr_port = scp->sc_intr_port; - - /* Check for pending signals that were blocked by the old set. */ -- if (ss->pending & ~ss->blocked) -+ if (_hurd_sigstate_pending (ss) & ~ss->blocked) - { - /* There are pending signals that just became unblocked. Wake up the - signal thread to deliver them. But first, squirrel away SCP where - the signal thread will notice it if it runs another handler, and - arrange to have us called over again in the new reality. */ - ss->context = scp; -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); - /* If a pending signal was handled, sig_post never returned. - If it did return, the pending signal didn't run a handler; - proceed as usual. */ -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - ss->context = NULL; - } - ---- a/sysdeps/mach/hurd/i386/trampoline.c -+++ b/sysdeps/mach/hurd/i386/trampoline.c -@@ -74,7 +74,11 @@ - the SP on sigreturn. */ - state->basic.uesp = state->basic.ecx; - -- if ((ss->actions[signo].sa_flags & SA_ONSTACK) -+ /* XXX what if handler != action->handler (for instance, if a signal -+ * preemptor took over) ? */ -+ action = & _hurd_sigstate_actions (ss) [signo]; -+ -+ if ((action->sa_flags & SA_ONSTACK) - && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK))) - { - sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size; ---- a/sysdeps/mach/hurd/sigaction.c -+++ b/sysdeps/mach/hurd/sigaction.c -@@ -46,15 +46,15 @@ - ss = _hurd_self_sigstate (); - - __spin_lock (&ss->critical_section_lock); -- __spin_lock (&ss->lock); -- old = ss->actions[sig]; -+ _hurd_sigstate_lock (ss); -+ old = _hurd_sigstate_actions (ss) [sig]; - if (act != NULL) -- ss->actions[sig] = a; -+ _hurd_sigstate_actions (ss) [sig] = a; - - if (act != NULL && sig == SIGCHLD - && (a.sa_flags & SA_NOCLDSTOP) != (old.sa_flags & SA_NOCLDSTOP)) - { -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - /* Inform the proc server whether or not it should send us SIGCHLD for - stopped children. We do this in a critical section so that no -@@ -62,8 +62,8 @@ - __USEPORT (PROC, - __proc_mod_stopchild (port, !(a.sa_flags & SA_NOCLDSTOP))); - -- __spin_lock (&ss->lock); -- pending = ss->pending & ~ss->blocked; -+ _hurd_sigstate_lock (ss); -+ pending = _hurd_sigstate_pending (ss) & ~ss->blocked; - } - else if (act != NULL && (a.sa_handler == SIG_IGN || a.sa_handler == SIG_DFL)) - /* We are changing to an action that might be to ignore SIG signals. -@@ -72,11 +72,11 @@ - back and then SIG is unblocked, the signal pending now should not - arrive. So wake up the signal thread to check the new state and do - the right thing. */ -- pending = ss->pending & __sigmask (sig); -+ pending = _hurd_sigstate_pending (ss) & __sigmask (sig); - else - pending = 0; - -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - __spin_unlock (&ss->critical_section_lock); - - if (pending) ---- a/sysdeps/mach/hurd/sigpending.c -+++ b/sysdeps/mach/hurd/sigpending.c -@@ -36,9 +36,9 @@ - } - - ss = _hurd_self_sigstate (); -- __spin_lock (&ss->lock); -- pending = ss->pending; -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_lock (ss); -+ pending = _hurd_sigstate_pending (ss); -+ _hurd_sigstate_unlock (ss); - - *set = pending; - return 0; ---- a/sysdeps/mach/hurd/sigprocmask.c -+++ b/sysdeps/mach/hurd/sigprocmask.c -@@ -36,7 +36,7 @@ - - ss = _hurd_self_sigstate (); - -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - - old = ss->blocked; - -@@ -57,7 +57,7 @@ - break; - - default: -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - errno = EINVAL; - return -1; - } -@@ -65,9 +65,9 @@ - ss->blocked &= ~_SIG_CANT_MASK; - } - -- pending = ss->pending & ~ss->blocked; -+ pending = _hurd_sigstate_pending (ss) & ~ss->blocked; - -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - if (oset != NULL) - *oset = old; ---- a/sysdeps/mach/hurd/sigsuspend.c -+++ b/sysdeps/mach/hurd/sigsuspend.c -@@ -40,7 +40,7 @@ - - ss = _hurd_self_sigstate (); - -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - - oldmask = ss->blocked; - if (set != NULL) -@@ -48,11 +48,11 @@ - ss->blocked = newmask & ~_SIG_CANT_MASK; - - /* Notice if any pending signals just became unblocked. */ -- pending = ss->pending & ~ss->blocked; -+ pending = _hurd_sigstate_pending (ss) & ~ss->blocked; - - /* Tell the signal thread to message us when a signal arrives. */ - ss->suspended = wait; -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - if (pending) - /* Tell the signal thread to check for pending signals. */ -@@ -63,10 +63,11 @@ - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); - __mach_port_destroy (__mach_task_self (), wait); - -- __spin_lock (&ss->lock); -- ss->blocked = oldmask; /* Restore the old mask. */ -- pending = ss->pending & ~ss->blocked; /* Again check for pending signals. */ -- __spin_unlock (&ss->lock); -+ /* Restore the old mask and check for pending signals again. */ -+ _hurd_sigstate_lock (ss); -+ ss->blocked = oldmask; -+ pending = _hurd_sigstate_pending(ss) & ~ss->blocked; -+ _hurd_sigstate_unlock (ss); - - if (pending) - /* Tell the signal thread to check for pending signals. */ ---- a/sysdeps/mach/hurd/sigwait.c -+++ b/sysdeps/mach/hurd/sigwait.c -@@ -27,7 +27,7 @@ - __sigwait (const sigset_t *set, int *sig) - { - struct hurd_sigstate *ss; -- sigset_t mask, ready; -+ sigset_t mask, ready, blocked; - int signo = 0; - struct hurd_signal_preemptor preemptor; - jmp_buf buf; -@@ -49,8 +49,8 @@ - /* Make sure this is all kosher */ - assert (__sigismember (&mask, signo)); - -- /* Make sure this signal is unblocked */ -- __sigdelset (&ss->blocked, signo); -+ /* Restore the blocking mask. */ -+ ss->blocked = blocked; - - return pe->handler; - } -@@ -71,10 +71,11 @@ - __sigemptyset (&mask); - - ss = _hurd_self_sigstate (); -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - - /* See if one of these signals is currently pending. */ -- __sigandset (&ready, &ss->pending, &mask); -+ sigset_t pending = _hurd_sigstate_pending (ss); -+ __sigandset (&ready, &pending, &mask); - if (! __sigisemptyset (&ready)) - { - for (signo = 1; signo < NSIG; signo++) -@@ -102,7 +103,11 @@ - preemptor.next = ss->preemptors; - ss->preemptors = &preemptor; - -- __spin_unlock (&ss->lock); -+ /* Unblock the expected signals */ -+ blocked = ss->blocked; -+ ss->blocked &= ~mask; -+ -+ _hurd_sigstate_unlock (ss); - - /* Wait. */ - __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof (msg), wait, -@@ -113,7 +118,7 @@ - { - assert (signo); - -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - - /* Delete our preemptor. */ - assert (ss->preemptors == &preemptor); -@@ -122,7 +127,7 @@ - - - all_done: -- spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - __mach_port_destroy (__mach_task_self (), wait); - *sig = signo; ---- a/sysdeps/mach/hurd/spawni.c -+++ b/sysdeps/mach/hurd/spawni.c -@@ -241,26 +241,29 @@ - - __spin_lock (&ss->critical_section_lock); - -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - ints[INIT_SIGMASK] = ss->blocked; -- ints[INIT_SIGPENDING] = ss->pending; -+ ints[INIT_SIGPENDING] = _hurd_sigstate_pending (ss); /* XXX really? */ - ints[INIT_SIGIGN] = 0; - /* Unless we were asked to reset all handlers to SIG_DFL, - pass down the set of signals that were set to SIG_IGN. */ -- if ((flags & POSIX_SPAWN_SETSIGDEF) == 0) -- for (i = 1; i < NSIG; ++i) -- if (ss->actions[i].sa_handler == SIG_IGN) -- ints[INIT_SIGIGN] |= __sigmask (i); -+ { -+ struct sigaction *actions = _hurd_sigstate_actions (ss); -+ if ((flags & POSIX_SPAWN_SETSIGDEF) == 0) -+ for (i = 1; i < NSIG; ++i) -+ if (actions[i].sa_handler == SIG_IGN) -+ ints[INIT_SIGIGN] |= __sigmask (i); -+ } - -- /* We hold the sigstate lock until the exec has failed so that no signal -- can arrive between when we pack the blocked and ignored signals, and -- when the exec actually happens. A signal handler could change what -+ /* We hold the critical section lock until the exec has failed so that no -+ signal can arrive between when we pack the blocked and ignored signals, -+ and when the exec actually happens. A signal handler could change what - signals are blocked and ignored. Either the change will be reflected - in the exec, or the signal will never be delivered. Setting the - critical section flag avoids anything we call trying to acquire the - sigstate lock. */ - -- __spin_unlock (&ss->lock); -+ _hurd_sigstate_unlock (ss); - - /* Set signal mask. */ - if ((flags & POSIX_SPAWN_SETSIGMASK) != 0) diff --git a/debian/patches/hurd-i386/git-hurdsig-globaldisp-version.diff b/debian/patches/hurd-i386/git-hurdsig-globaldisp-version.diff deleted file mode 100644 index fd16039f..00000000 --- a/debian/patches/hurd-i386/git-hurdsig-globaldisp-version.diff +++ /dev/null @@ -1,40 +0,0 @@ -Committed for glibc 2.31 - -jkoenig's work on signals - ---- - hurd/Versions | 8 ++++++++ - sysdeps/mach/hurd/i386/libc.abilist | 4 +++++ - 3 files changed, 78 insertions(+), 5 deletions(-) - ---- a/hurd/Versions -+++ b/hurd/Versions -@@ -136,6 +136,14 @@ - # "quasi-internal" functions - _hurd_port_move; - } -+ GLIBC_2.21 { -+ # functions used by libpthread and <hurd/signal.h> -+ _hurd_sigstate_set_global_rcv; -+ _hurd_sigstate_lock; -+ _hurd_sigstate_pending; -+ _hurd_sigstate_unlock; -+ _hurd_sigstate_delete; -+ } - - HURD_CTHREADS_0.3 { - # weak refs to libthreads functions that libc calls iff libthreads in use ---- a/sysdeps/mach/hurd/i386/libc.abilist -+++ b/sysdeps/mach/hurd/i386/libc.abilist -@@ -1940,6 +1946,11 @@ - GLIBC_2.2.6 xprt_unregister F - GLIBC_2.21 __mach_host_self_ D 0x4 - GLIBC_2.21 __pthread_get_cleanup_stack F -+GLIBC_2.21 _hurd_sigstate_delete F -+GLIBC_2.21 _hurd_sigstate_lock F -+GLIBC_2.21 _hurd_sigstate_pending F -+GLIBC_2.21 _hurd_sigstate_set_global_rcv F -+GLIBC_2.21 _hurd_sigstate_unlock F - GLIBC_2.21 pthread_attr_destroy F - GLIBC_2.21 pthread_attr_getdetachstate F - GLIBC_2.21 pthread_attr_getinheritsched F diff --git a/debian/patches/hurd-i386/git-io_select_timeout.diff b/debian/patches/hurd-i386/git-io_select_timeout.diff deleted file mode 100644 index a9c3cca9..00000000 --- a/debian/patches/hurd-i386/git-io_select_timeout.diff +++ /dev/null @@ -1,289 +0,0 @@ -From: Richard Braun <rbraun@sceen.net> -Subject: Fix timeout handling in _hurd_select - -Rely on servers to implement timeouts, so that very short values (including -0) don't make mach_msg return before valid replies can be received. The -purpose of this scheme is to guarantee a full client-server round-trip, -whatever the timeout value. - -This change depends on the new io_select_timeout RPC being implemented by -servers. - -* hurd/Makefile (user-interfaces): Add io_reply and io_request. -* hurd/hurdselect.c: Include <sys/time.h>, <hurd/io_request.h> and <limits.h>. -(_hurd_select): Replace the call to __io_select with either __io_select_request -or __io_select_timeout_request, depending on the timeout. Count the number of -ready descriptors (replies for which at least one type bit is set). Implement -the timeout locally when there is no file descriptor. - -TODO: see XXX - ---- - hurd/Makefile | 3 +- - hurd/hurdselect.c | 116 +++++++++++++++++++++++++++++++++++------------------ - 2 files changed, 79 insertions(+), 40 deletions(-) - ---- a/hurd/Makefile -+++ b/hurd/Makefile -@@ -37,7 +37,8 @@ user-interfaces := $(addprefix hurd/,\ - process process_request \ - msg msg_reply msg_request \ - exec exec_startup crash interrupt \ -- fs fsys io term tioctl socket ifsock \ -+ fs fsys io io_reply io_request \ -+ term tioctl socket ifsock \ - login password pfinet pci \ - ) - server-interfaces := hurd/msg faultexc ---- a/hurd/hurdselect.c -+++ b/hurd/hurdselect.c -@@ -16,14 +16,17 @@ - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -+#include <sys/time.h> - #include <sys/types.h> - #include <sys/poll.h> - #include <hurd.h> - #include <hurd/fd.h> -+#include <hurd/io_request.h> - #include <stdlib.h> - #include <string.h> - #include <assert.h> - #include <stdint.h> -+#include <limits.h> - - /* All user select types. */ - #define SELECT_ALL (SELECT_READ | SELECT_WRITE | SELECT_URG) -@@ -44,11 +47,13 @@ _hurd_select (int nfds, - { - int i; - mach_port_t portset; -- int got; -+ int got, ready; - error_t err; - fd_set rfds, wfds, xfds; - int firstfd, lastfd; -- mach_msg_timeout_t to = 0; -+ mach_msg_id_t reply_msgid; -+ mach_msg_timeout_t to; -+ struct timespec ts; - struct - { - struct hurd_userlink ulink; -@@ -73,16 +78,39 @@ _hurd_select (int nfds, - return -1; - } - -- if (timeout != NULL) -+#define IO_SELECT_REPLY_MSGID (21012 + 100) /* XXX */ -+#define IO_SELECT_TIMEOUT_REPLY_MSGID (21031 + 100) /* XXX */ -+ -+ if (timeout == NULL) -+ reply_msgid = IO_SELECT_REPLY_MSGID; -+ else - { -- if (timeout->tv_sec < 0 || timeout->tv_nsec < 0) -+ struct timeval now; -+ -+ if (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || -+ timeout->tv_nsec >= 1000000000) - { - errno = EINVAL; - return -1; - } - -- to = (timeout->tv_sec * 1000 -- + (timeout->tv_nsec + 999999) / 1000000); -+ err = __gettimeofday(&now, NULL); -+ if (err) -+ return -1; -+ -+ ts.tv_sec = now.tv_sec + timeout->tv_sec; -+ ts.tv_nsec = now.tv_usec * 1000 + timeout->tv_nsec; -+ -+ if (ts.tv_nsec >= 1000000000) -+ { -+ ts.tv_sec++; -+ ts.tv_nsec -= 1000000000; -+ } -+ -+ if (ts.tv_sec < 0) -+ ts.tv_sec = LONG_MAX; /* XXX */ -+ -+ reply_msgid = IO_SELECT_TIMEOUT_REPLY_MSGID; - } - - if (sigmask && __sigprocmask (SIG_SETMASK, sigmask, &oset)) -@@ -236,12 +264,13 @@ _hurd_select (int nfds, - { - int type = d[i].type; - d[i].reply_port = __mach_reply_port (); -- err = __io_select (d[i].io_port, d[i].reply_port, 0, &type); -- switch (err) -+ if (timeout == NULL) -+ err = __io_select_request (d[i].io_port, d[i].reply_port, type); -+ else -+ err = __io_select_timeout_request (d[i].io_port, d[i].reply_port, -+ ts, type); -+ if (!err) - { -- case MACH_RCV_TIMED_OUT: -- /* No immediate response. This is normal. */ -- err = 0; - if (firstfd == lastfd) - /* When there's a single descriptor, we don't need a - portset, so just pretend we have one, but really -@@ -262,32 +291,24 @@ _hurd_select (int nfds, - __mach_port_move_member (__mach_task_self (), - d[i].reply_port, portset); - } -- break; -- -- default: -- /* No other error should happen. Callers of select -+ } -+ else -+ { -+ /* No error should happen. Callers of select - don't expect to see errors, so we simulate - readiness of the erring object and the next call - hopefully will get the error again. */ -- type = SELECT_ALL; -- /* FALLTHROUGH */ -- -- case 0: -- /* We got an answer. */ -- if ((type & SELECT_ALL) == 0) -- /* Bogus answer; treat like an error, as a fake positive. */ -- type = SELECT_ALL; -- -- /* This port is already ready already. */ -- d[i].type &= type; - d[i].type |= SELECT_RETURNED; - ++got; -- break; - } - _hurd_port_free (&d[i].cell->port, &d[i].ulink, d[i].io_port); - } - } - -+ /* GOT is the number of replies (or errors), while READY is the number of -+ replies with at least one type bit set. */ -+ ready = 0; -+ - /* Now wait for reply messages. */ - if (!err && got == 0) - { -@@ -329,22 +350,35 @@ _hurd_select (int nfds, - } success; - #endif - } msg; -- mach_msg_option_t options = (timeout == NULL ? 0 : MACH_RCV_TIMEOUT); -+ mach_msg_option_t options; - error_t msgerr; -+ -+ /* We rely on servers to implement the timeout, but when there are none, -+ do it on the client side. */ -+ if (timeout != NULL && firstfd == -1) -+ { -+ options = MACH_RCV_TIMEOUT; -+ to = timeout->tv_sec * 1000 + (timeout->tv_nsec + 999999) / 1000000; -+ } -+ else -+ { -+ options = 0; -+ to = MACH_MSG_TIMEOUT_NONE; -+ } -+ - while ((msgerr = __mach_msg (&msg.head, - MACH_RCV_MSG | MACH_RCV_INTERRUPT | options, - 0, sizeof msg, portset, to, - MACH_PORT_NULL)) == MACH_MSG_SUCCESS) - { - /* We got a message. Decode it. */ --#define IO_SELECT_REPLY_MSGID (21012 + 100) /* XXX */ - #ifdef MACH_MSG_TYPE_BIT - const union typeword inttype = - { type: - { MACH_MSG_TYPE_INTEGER_T, sizeof (integer_t) * 8, 1, 1, 0, 0 } - }; - #endif -- if (msg.head.msgh_id == IO_SELECT_REPLY_MSGID -+ if (msg.head.msgh_id == reply_msgid - && msg.head.msgh_size >= sizeof msg.error - && !(msg.head.msgh_bits & MACH_MSGH_BITS_COMPLEX) - #ifdef MACH_MSG_TYPE_BIT -@@ -362,12 +396,13 @@ _hurd_select (int nfds, - err = EINTR; - goto poll; - } -+ /* Keep in mind msg.success.result can be 0 if a timeout -+ occurred. */ - if (msg.error.err -- || msg.head.msgh_size != sizeof msg.success - #ifdef MACH_MSG_TYPE_BIT - || msg.success.result_type.word != inttype.word - #endif -- || (msg.success.result & SELECT_ALL) == 0) -+ || msg.head.msgh_size != sizeof msg.success) - { - /* Error or bogus reply. Simulate readiness. */ - __mach_msg_destroy (&msg.head); -@@ -384,6 +419,9 @@ _hurd_select (int nfds, - && d[i].reply_port == msg.head.msgh_local_port) - { - d[i].type &= msg.success.result; -+ if (d[i].type) -+ ++ready; -+ - d[i].type |= SELECT_RETURNED; - ++got; - } -@@ -415,7 +453,7 @@ _hurd_select (int nfds, - /* Interruption on our side (e.g. signal reception). */ - err = EINTR; - -- if (got) -+ if (ready) - /* At least one descriptor is known to be ready now, so we will - return success. */ - err = 0; -@@ -459,9 +497,9 @@ _hurd_select (int nfds, - } - else - { -- /* Below we recalculate GOT to include an increment for each operation -+ /* Below we recalculate READY to include an increment for each operation - allowed on each fd. */ -- got = 0; -+ ready = 0; - - /* Set the user bitarrays. We only ever have to clear bits, as all - desired ones are initially set. */ -@@ -474,15 +512,15 @@ _hurd_select (int nfds, - type = 0; - - if (type & SELECT_READ) -- got++; -+ ready++; - else if (readfds) - FD_CLR (i, readfds); - if (type & SELECT_WRITE) -- got++; -+ ready++; - else if (writefds) - FD_CLR (i, writefds); - if (type & SELECT_URG) -- got++; -+ ready++; - else if (exceptfds) - FD_CLR (i, exceptfds); - } -@@ -491,5 +529,5 @@ _hurd_select (int nfds, - if (sigmask && __sigprocmask (SIG_SETMASK, &oset, NULL)) - return -1; - -- return got; -+ return ready; - } diff --git a/debian/patches/hurd-i386/git-libpthread_sigs.diff b/debian/patches/hurd-i386/git-libpthread_sigs.diff deleted file mode 100644 index b0312efd..00000000 --- a/debian/patches/hurd-i386/git-libpthread_sigs.diff +++ /dev/null @@ -1,101 +0,0 @@ -Committed for glibc 2.31 - -From: Samuel Thibault <samuel.thibault@ens-lyon.org> -Subject: Enable global signal distribution in htl - -* sysdeps/mach/hurd/htl/pt-sigstate-init.c (__pthread_sigstate_init): -Call _hurd_sigstate_set_global_rcv(). -* sysdeps/mach/hurd/htl/pt-sigstate-destroy.c -(__pthread_sigstate_destroy): Call _hurd_sigstate_delete(). -* sysdeps/mach/hurd/htl/pt-sigstate.c: Include <hurd/msg.h> -(__pthread_sigstate): Use _hurd_sigstate_lock()/_hurd_sigstate_unlock() -and _hurd_sigstate_pending(). Call __msg_sig_post() to wake up thread -with pending signals. -* sysdeps/mach/hurd/Makefile (LDLIBS-pthread.so): Add -$(objdir)/hurd/libhurduser.so. - - ---- - sysdeps/mach/hurd/Makefile | 2 ++ - sysdeps/mach/hurd/htl/pt-sigstate-destroy.c | 1 + - sysdeps/mach/hurd/htl/pt-sigstate-init.c | 2 +- - sysdeps/mach/hurd/htl/pt-sigstate.c | 12 ++++++++++-- - 4 files changed, 14 insertions(+), 3 deletions(-) - -diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile -index 3a853a6cd9..8a865a0e1f 100644 ---- a/sysdeps/mach/hurd/Makefile -+++ b/sysdeps/mach/hurd/Makefile -@@ -206,4 +206,6 @@ ifeq ($(subdir),nis) - CFLAGS-ypclnt.c += -DUSE_BINDINGDIR=1 - endif - -+LDLIBS-pthread.so += $(objdir)/hurd/libhurduser.so -+ - endif # in-Makerules -diff --git a/sysdeps/mach/hurd/htl/pt-sigstate-destroy.c b/sysdeps/mach/hurd/htl/pt-sigstate-destroy.c -index e7154a371d..229a415487 100644 ---- a/sysdeps/mach/hurd/htl/pt-sigstate-destroy.c -+++ b/sysdeps/mach/hurd/htl/pt-sigstate-destroy.c -@@ -23,4 +23,5 @@ - void - __pthread_sigstate_destroy (struct __pthread *thread) - { -+ _hurd_sigstate_delete (thread->kernel_thread); - } -diff --git a/sysdeps/mach/hurd/htl/pt-sigstate-init.c b/sysdeps/mach/hurd/htl/pt-sigstate-init.c -index 70832f9576..507fb8ade2 100644 ---- a/sysdeps/mach/hurd/htl/pt-sigstate-init.c -+++ b/sysdeps/mach/hurd/htl/pt-sigstate-init.c -@@ -35,7 +35,7 @@ __pthread_sigstate_init (struct __pthread *thread) - if (do_init_global) - { - struct hurd_sigstate *ss = _hurd_thread_sigstate (thread->kernel_thread); -- (void) ss; -+ _hurd_sigstate_set_global_rcv (ss); - } - else if (__pthread_num_threads >= 2) - do_init_global = 1; -diff --git a/sysdeps/mach/hurd/htl/pt-sigstate.c b/sysdeps/mach/hurd/htl/pt-sigstate.c -index f7050ec0df..2ddceb229e 100644 ---- a/sysdeps/mach/hurd/htl/pt-sigstate.c -+++ b/sysdeps/mach/hurd/htl/pt-sigstate.c -@@ -20,6 +20,7 @@ - #include <assert.h> - #include <signal.h> - #include <hurd/signal.h> -+#include <hurd/msg.h> - - #include <pt-internal.h> - -@@ -29,11 +30,12 @@ __pthread_sigstate (struct __pthread *thread, int how, - { - error_t err = 0; - struct hurd_sigstate *ss; -+ sigset_t pending; - - ss = _hurd_thread_sigstate (thread->kernel_thread); - assert (ss); - -- __spin_lock (&ss->lock); -+ _hurd_sigstate_lock (ss); - - if (oset != NULL) - *oset = ss->blocked; -@@ -64,7 +66,13 @@ __pthread_sigstate (struct __pthread *thread, int how, - if (!err && clear_pending) - __sigemptyset (&ss->pending); - -- __spin_unlock (&ss->lock); -+ pending = _hurd_sigstate_pending (ss) & ~ss->blocked; -+ _hurd_sigstate_unlock (ss); -+ -+ if (!err && pending) -+ /* Send a message to the signal thread so it -+ will wake up and check for pending signals. */ -+ __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); - - return err; - } --- -tg: (0bfe57e3de..) t/libpthread_sigs (depends on: baseline t/hurdsig-SA_SIGINFO t/hurdsig-boot-fix t/hurdsig-fixes t/hurdsig-fixes-2 t/hurdsig-global-dispositions t/hurdsig-global-dispositions-versions) diff --git a/debian/patches/hurd-i386/git-poll_errors_fixes.diff b/debian/patches/hurd-i386/git-poll_errors_fixes.diff deleted file mode 100644 index 8dcbb788..00000000 --- a/debian/patches/hurd-i386/git-poll_errors_fixes.diff +++ /dev/null @@ -1,297 +0,0 @@ -From: Samuel Thibault <samuel.thibault@ens-lyon.org> -Subject: Fix poll and select POSIX compliancy details about errors - -This fixes the following: - -- On error, poll must not return without polling, including EBADF, and instead -report POLLHUP/POLLERR/POLLNVAL -- Select must report EBADF if some set contains an invalid FD. - -The idea is to move error management to after all select calls, in the -poll/select final treatment. The error is instead recorded in a new `error' -field, and a new SELECT_ERROR bit set. - -Thanks Svante Signell for the initial version of the patch. - -* hurd/hurdselect.c (SELECT_ERROR): New macro. -(_hurd_select): -- Add `error' field to `d' structures array. -- If a poll descriptor is bogus, set EBADF, but continue with a zero timeout. -- Go through the whole fd_set, not only until _hurd_dtablesize. Return EBADF -there is any bit set above _hurd_dtablesize. -- Do not request io_select on bogus descriptors (SELECT_ERROR). -- On io_select request error, record the error. -- On io_select bogus reply, use EIO error code. -- On io_select bogus or error reply, record the error. -- Do not destroy reply port for bogus FDs. -- On error, make poll set POLLHUP in the EPIPE case, POLLNVAL in the EBADF -case, or else POLLERR. -- On error, make select simulated readiness. - - ---- - hurd/hurdselect.c | 149 +++++++++++++++++++++++++++++++++++++++--------------- - 1 file changed, 108 insertions(+), 41 deletions(-) - -diff --git a/hurd/hurdselect.c b/hurd/hurdselect.c -index 70780dd..dcda71b 100644 ---- a/hurd/hurdselect.c -+++ b/hurd/hurdselect.c -@@ -34,6 +34,7 @@ - /* Used to record that a particular select rpc returned. Must be distinct - from SELECT_ALL (which better not have the high bit set). */ - #define SELECT_RETURNED ((SELECT_ALL << 1) & ~SELECT_ALL) -+#define SELECT_ERROR (SELECT_RETURNED << 1) - - /* Check the first NFDS descriptors either in POLLFDS (if nonnnull) or in - each of READFDS, WRITEFDS, EXCEPTFDS that is nonnull. If TIMEOUT is not -@@ -61,6 +62,7 @@ _hurd_select (int nfds, - mach_port_t io_port; - int type; - mach_port_t reply_port; -+ int error; - } d[nfds]; - sigset_t oset; - -@@ -118,6 +120,7 @@ _hurd_select (int nfds, - - if (pollfds) - { -+ int error = 0; - /* Collect interesting descriptors from the user's `pollfd' array. - We do a first pass that reads the user's array before taking - any locks. The second pass then only touches our own stack, -@@ -151,28 +154,47 @@ _hurd_select (int nfds, - if (fd < _hurd_dtablesize) - { - d[i].cell = _hurd_dtable[fd]; -- d[i].io_port = _hurd_port_get (&d[i].cell->port, &d[i].ulink); -- if (d[i].io_port != MACH_PORT_NULL) -- continue; -+ if (d[i].cell != NULL) -+ { -+ d[i].io_port = _hurd_port_get (&d[i].cell->port, -+ &d[i].ulink); -+ if (d[i].io_port != MACH_PORT_NULL) -+ continue; -+ } - } - -- /* If one descriptor is bogus, we fail completely. */ -- while (i-- > 0) -- if (d[i].type != 0) -- _hurd_port_free (&d[i].cell->port, -- &d[i].ulink, d[i].io_port); -- break; -+ /* Bogus descriptor, make it EBADF already. */ -+ d[i].error = EBADF; -+ d[i].type = SELECT_ERROR; -+ error = 1; - } - - __mutex_unlock (&_hurd_dtable_lock); - HURD_CRITICAL_END; - -- if (i < nfds) -+ if (error) - { -- if (sigmask) -- __sigprocmask (SIG_SETMASK, &oset, NULL); -- errno = EBADF; -- return -1; -+ /* Set timeout to 0. */ -+ struct timeval now; -+ err = __gettimeofday(&now, NULL); -+ if (err) -+ { -+ /* Really bad luck. */ -+ err = errno; -+ HURD_CRITICAL_BEGIN; -+ __mutex_lock (&_hurd_dtable_lock); -+ while (i-- > 0) -+ if (d[i].type & ~SELECT_ERROR != 0) -+ _hurd_port_free (&d[i].cell->port, &d[i].ulink, -+ d[i].io_port); -+ __mutex_unlock (&_hurd_dtable_lock); -+ HURD_CRITICAL_END; -+ errno = err; -+ return -1; -+ } -+ ts.tv_sec = now.tv_sec; -+ ts.tv_nsec = now.tv_usec * 1000; -+ reply_msgid = IO_SELECT_TIMEOUT_REPLY_MSGID; - } - - lastfd = i - 1; -@@ -199,9 +221,6 @@ _hurd_select (int nfds, - HURD_CRITICAL_BEGIN; - __mutex_lock (&_hurd_dtable_lock); - -- if (nfds > _hurd_dtablesize) -- nfds = _hurd_dtablesize; -- - /* Collect the ports for interesting FDs. */ - firstfd = lastfd = -1; - for (i = 0; i < nfds; ++i) -@@ -216,9 +235,15 @@ _hurd_select (int nfds, - d[i].type = type; - if (type) - { -- d[i].cell = _hurd_dtable[i]; -- d[i].io_port = _hurd_port_get (&d[i].cell->port, &d[i].ulink); -- if (d[i].io_port == MACH_PORT_NULL) -+ if (i < _hurd_dtablesize) -+ { -+ d[i].cell = _hurd_dtable[i]; -+ if (d[i].cell != NULL) -+ d[i].io_port = _hurd_port_get (&d[i].cell->port, -+ &d[i].ulink); -+ } -+ if (i >= _hurd_dtablesize || d[i].cell == NULL || -+ d[i].io_port == MACH_PORT_NULL) - { - /* If one descriptor is bogus, we fail completely. */ - while (i-- > 0) -@@ -243,6 +268,9 @@ _hurd_select (int nfds, - errno = EBADF; - return -1; - } -+ -+ if (nfds > _hurd_dtablesize) -+ nfds = _hurd_dtablesize; - } - - -@@ -260,7 +288,9 @@ _hurd_select (int nfds, - portset = MACH_PORT_NULL; - - for (i = firstfd; i <= lastfd; ++i) -- if (d[i].type) -+ if (!(d[i].type & ~SELECT_ERROR)) -+ d[i].reply_port = MACH_PORT_NULL; -+ else - { - int type = d[i].type; - d[i].reply_port = __mach_reply_port (); -@@ -294,11 +324,10 @@ _hurd_select (int nfds, - } - else - { -- /* No error should happen. Callers of select -- don't expect to see errors, so we simulate -- readiness of the erring object and the next call -- hopefully will get the error again. */ -- d[i].type |= SELECT_RETURNED; -+ /* No error should happen, but record it for later -+ processing. */ -+ d[i].error = err; -+ d[i].type |= SELECT_ERROR; - ++got; - } - _hurd_port_free (&d[i].cell->port, &d[i].ulink, d[i].io_port); -@@ -404,9 +433,10 @@ _hurd_select (int nfds, - #endif - || msg.head.msgh_size != sizeof msg.success) - { -- /* Error or bogus reply. Simulate readiness. */ -+ /* Error or bogus reply. */ -+ if (!msg.error.err) -+ msg.error.err = EIO; - __mach_msg_destroy (&msg.head); -- msg.success.result = SELECT_ALL; - } - - /* Look up the respondent's reply port and record its -@@ -418,9 +448,18 @@ _hurd_select (int nfds, - if (d[i].type - && d[i].reply_port == msg.head.msgh_local_port) - { -- d[i].type &= msg.success.result; -- if (d[i].type) -- ++ready; -+ if (msg.error.err) -+ { -+ d[i].error = msg.error.err; -+ d[i].type = SELECT_ERROR; -+ ++ready; -+ } -+ else -+ { -+ d[i].type &= msg.success.result; -+ if (d[i].type) -+ ++ready; -+ } - - d[i].type |= SELECT_RETURNED; - ++got; -@@ -454,7 +493,7 @@ _hurd_select (int nfds, - - if (firstfd != -1) - for (i = firstfd; i <= lastfd; ++i) -- if (d[i].type) -+ if (d[i].reply_port != MACH_PORT_NULL) - __mach_port_destroy (__mach_task_self (), d[i].reply_port); - if (firstfd == -1 || (firstfd != lastfd && portset != MACH_PORT_NULL)) - /* Destroy PORTSET, but only if it's not actually the reply port for a -@@ -476,15 +515,29 @@ _hurd_select (int nfds, - int type = d[i].type; - int_fast16_t revents = 0; - -- if (type & SELECT_RETURNED) -- { -- if (type & SELECT_READ) -- revents |= POLLIN; -- if (type & SELECT_WRITE) -- revents |= POLLOUT; -- if (type & SELECT_URG) -- revents |= POLLPRI; -- } -+ if (type & SELECT_ERROR) -+ switch (d[i].error) -+ { -+ case EPIPE: -+ revents = POLLHUP; -+ break; -+ case EBADF: -+ revents = POLLNVAL; -+ break; -+ default: -+ revents = POLLERR; -+ break; -+ } -+ else -+ if (type & SELECT_RETURNED) -+ { -+ if (type & SELECT_READ) -+ revents |= POLLIN; -+ if (type & SELECT_WRITE) -+ revents |= POLLOUT; -+ if (type & SELECT_URG) -+ revents |= POLLPRI; -+ } - - pollfds[i].revents = revents; - } -@@ -504,6 +557,20 @@ _hurd_select (int nfds, - if ((type & SELECT_RETURNED) == 0) - type = 0; - -+ /* Callers of select don't expect to see errors, so we simulate -+ readiness of the erring object and the next call hopefully -+ will get the error again. */ -+ if (type & SELECT_ERROR) -+ { -+ type = 0; -+ if (readfds != NULL && FD_ISSET (i, readfds)) -+ type |= SELECT_READ; -+ if (writefds != NULL && FD_ISSET (i, writefds)) -+ type |= SELECT_WRITE; -+ if (exceptfds != NULL && FD_ISSET (i, exceptfds)) -+ type |= SELECT_URG; -+ } -+ - if (type & SELECT_READ) - ready++; - else if (readfds) --- -tg: (de946c7..) t/poll_errors_fixes (depends on: t/io_select_timeout) diff --git a/debian/patches/hurd-i386/git-remap_getcwd.diff b/debian/patches/hurd-i386/git-remap_getcwd.diff deleted file mode 100644 index f9a6fa86..00000000 --- a/debian/patches/hurd-i386/git-remap_getcwd.diff +++ /dev/null @@ -1,46 +0,0 @@ -From: Samuel Thibault <samuel.thibault@ens-lyon.org> -Subject: [PATCH] Allow unknown root directory. - -To be efficient, the remap translator simply returns ports from the underlying -filesystem, and thus the root directory found through browsing '..' is the -underlying root, not the remap root. This should not be a reason for getcwd to -fail. - -* sysdeps/mach/hurd/getcwd.c (_hurd_canonicalize_directory_name_internal): Do -not remove the heading slash if we got an unknown root directory. -(__getcwd): Do not fail with EGRATUITOUS if we got an unknown root directory. - -Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> - ---- - sysdeps/mach/hurd/getcwd.c | 12 ------------ - 1 file changed, 12 deletions(-) - ---- a/sysdeps/mach/hurd/getcwd.c -+++ b/sysdeps/mach/hurd/getcwd.c -@@ -266,11 +266,6 @@ - So the root is our current directory. */ - *--file_namep = '/'; - -- if (thisid != rootid) -- /* We did not get to our root directory. The returned name should -- not begin with a slash. */ -- ++file_namep; -- - memmove (file_name, file_namep, file_name + size - file_namep); - cleanup (); - return file_name; -@@ -309,13 +304,6 @@ - __USEPORT (CWDIR, - __hurd_canonicalize_directory_name_internal (port, - buf, size)); -- if (cwd && cwd[0] != '/') -- { -- /* `cwd' is an unknown root directory. */ -- if (buf == NULL) -- free (cwd); -- return __hurd_fail (EGRATUITOUS), NULL; -- } - return cwd; - } - weak_alias (__getcwd, getcwd) diff --git a/debian/patches/hurd-i386/git-rlock.diff b/debian/patches/hurd-i386/git-rlock.diff deleted file mode 100644 index 31b110ff..00000000 --- a/debian/patches/hurd-i386/git-rlock.diff +++ /dev/null @@ -1,149 +0,0 @@ -commit 0b262ca4c64cd9042576ddb9969607c0ea1187d7 -Author: Svante Signell <svante.signell@gmail.com> -Date: Wed Oct 30 01:23:41 2019 +0100 - - hurd: Support for file record locking - - * sysdeps/mach/hurd/fcntl.c: Add support for file-record-lock RPC - fixing posix file locking using the flock64 version of struct - flock. - -diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c -index 26243682ca..0e3f0adbd9 100644 ---- a/sysdeps/mach/hurd/fcntl.c -+++ b/sysdeps/mach/hurd/fcntl.c -@@ -130,23 +130,75 @@ __libc_fcntl (int fd, int cmd, ...) - case F_SETLKW: - { - struct flock *fl = va_arg (ap, struct flock *); -- int wait = 0; -- va_end (ap); -+ - switch (cmd) - { - case F_GETLK: -- errno = ENOSYS; -- return -1; -- case F_SETLKW: -- wait = 1; -- /* FALLTHROUGH */ -+ cmd = F_GETLK64; -+ break; - case F_SETLK: -- return __f_setlk (fd, fl->l_type, fl->l_whence, -- fl->l_start, fl->l_len, wait); -+ cmd = F_SETLK64; -+ break; -+ case F_SETLKW: -+ cmd = F_SETLKW64; -+ break; - default: - errno = EINVAL; - return -1; - } -+ -+ struct flock64 fl64 = { -+ .l_type = fl->l_type, -+ .l_whence = fl->l_whence, -+ .l_start = fl->l_start, -+ .l_len = fl->l_len, -+ .l_pid = fl->l_pid -+ }; -+ -+ err = HURD_FD_PORT_USE (d, __file_record_lock (port, cmd, &fl64, -+ MACH_PORT_NULL, MACH_MSG_TYPE_MAKE_SEND)); -+ -+ /* XXX: To remove once file_record_lock RPC is settled. */ -+ if (err == EMIG_BAD_ID || err == EOPNOTSUPP) -+ { -+ int wait = 0; -+ va_end (ap); -+ switch (cmd) -+ { -+ case F_GETLK64: -+ errno = ENOSYS; -+ return -1; -+ case F_SETLKW64: -+ wait = 1; -+ /* FALLTHROUGH */ -+ case F_SETLK64: -+ return __f_setlk (fd, fl->l_type, fl->l_whence, -+ fl->l_start, fl->l_len, wait); -+ default: -+ errno = EINVAL; -+ return -1; -+ } -+ } -+ else if (cmd == F_GETLK64) -+ { -+ fl->l_type = fl64.l_type; -+ fl->l_whence = fl64.l_whence; -+ fl->l_start = fl64.l_start; -+ fl->l_len = fl64.l_len; -+ fl->l_pid = fl64.l_pid; -+ -+ if ((sizeof fl->l_start != sizeof fl64.l_start -+ && fl->l_start != fl64.l_start) -+ || (sizeof fl->l_len != sizeof fl64.l_len -+ && fl->l_len != fl64.l_len)) -+ { -+ errno = EOVERFLOW; -+ return -1; -+ } -+ } -+ -+ result = err ? __hurd_dfail (fd, err) : 0; -+ break; - } - - case F_GETLK64: -@@ -154,23 +206,34 @@ __libc_fcntl (int fd, int cmd, ...) - case F_SETLKW64: - { - struct flock64 *fl = va_arg (ap, struct flock64 *); -- int wait = 0; -- va_end (ap); -- switch (cmd) -+ -+ err = HURD_FD_PORT_USE (d, __file_record_lock (port, cmd, fl, -+ MACH_PORT_NULL, MACH_MSG_TYPE_MAKE_SEND)); -+ -+ /* XXX: To remove once file_record_lock RPC is settled. */ -+ if (err == EMIG_BAD_ID || err == EOPNOTSUPP) - { -- case F_GETLK64: -- errno = ENOSYS; -- return -1; -- case F_SETLKW64: -- wait = 1; -- /* FALLTHROUGH */ -- case F_SETLK64: -- return __f_setlk (fd, fl->l_type, fl->l_whence, -- fl->l_start, fl->l_len, wait); -- default: -- errno = EINVAL; -- return -1; -+ int wait = 0; -+ va_end (ap); -+ switch (cmd) -+ { -+ case F_GETLK64: -+ errno = ENOSYS; -+ return -1; -+ case F_SETLKW64: -+ wait = 1; -+ /* FALLTHROUGH */ -+ case F_SETLK64: -+ return __f_setlk (fd, fl->l_type, fl->l_whence, -+ fl->l_start, fl->l_len, wait); -+ default: -+ errno = EINVAL; -+ return -1; -+ } - } -+ -+ result = err ? __hurd_dfail (fd, err) : 0; -+ break; - } - - case F_GETFL: /* Get per-open flags. */ diff --git a/debian/patches/hurd-i386/git-sendmsg-SCM_RIGHTS.diff b/debian/patches/hurd-i386/git-sendmsg-SCM_RIGHTS.diff deleted file mode 100644 index 8fd1802e..00000000 --- a/debian/patches/hurd-i386/git-sendmsg-SCM_RIGHTS.diff +++ /dev/null @@ -1,267 +0,0 @@ -Committed for glibc 2.31 - -From 1b911148009f696717da0b676d6d10af85d5aefb Mon Sep 17 00:00:00 2001 -From: Emilio Pozuelo Monfort <pochu27@gmail.com> -Date: Sat, 17 Jul 2010 22:09:13 +0200 -Subject: [PATCH] Add support to send file descriptors over Unix sockets - ---- - sysdeps/mach/hurd/recvmsg.c | 97 ++++++++++++++++++++++++++++++++++++++++++++- - sysdeps/mach/hurd/sendmsg.c | 73 +++++++++++++++++++++++++++++----- - 2 files changed, 157 insertions(+), 13 deletions(-) - -diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c -index 5d7b1ee..dfd4145 100644 ---- a/sysdeps/mach/hurd/recvmsg.c -+++ b/sysdeps/mach/hurd/recvmsg.c -@@ -32,13 +32,34 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) - addr_port_t aport; - char *data = NULL; - mach_msg_type_number_t len = 0; -- mach_port_t *ports; -+ mach_port_t *ports, *newports = NULL; - mach_msg_type_number_t nports = 0; -+ struct cmsghdr *cmsg; - char *cdata = NULL; - mach_msg_type_number_t clen = 0; - size_t amount; - char *buf; -- int i; -+ int nfds, *opened_fds = NULL; -+ int i, ii, j; -+ int newfds; -+ -+ error_t reauthenticate (mach_port_t port, mach_port_t *result) -+ { -+ error_t err; -+ mach_port_t ref; -+ ref = __mach_reply_port (); -+ do -+ err = __io_reauthenticate (port, ref, MACH_MSG_TYPE_MAKE_SEND); -+ while (err == EINTR); -+ if (!err) -+ do -+ err = __USEPORT (AUTH, __auth_user_authenticate (port, -+ ref, MACH_MSG_TYPE_MAKE_SEND, -+ result)); -+ while (err == EINTR); -+ __mach_port_destroy (__mach_task_self (), ref); -+ return err; -+ } - - /* Find the total number of bytes to be read. */ - amount = 0; -@@ -135,9 +156,81 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) - message->msg_controllen = clen; - memcpy (message->msg_control, cdata, message->msg_controllen); - -+ if (nports > 0) -+ { -+ newports = __alloca (nports * sizeof (mach_port_t)); -+ opened_fds = __alloca (nports * sizeof (int)); -+ } -+ -+ /* This counts how many ports we processed completely. */ -+ i = 0; -+ /* This counts how many new fds we create. */ -+ newfds = 0; -+ -+ for (cmsg = CMSG_FIRSTHDR (message); -+ cmsg; -+ cmsg = CMSG_NXTHDR (message, cmsg)) -+ { -+ if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) -+ { -+ /* SCM_RIGHTS support. */ -+ /* The fd's flags are passed in the control data. */ -+ int *fds = (int *) CMSG_DATA (cmsg); -+ nfds = (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr))) -+ / sizeof (int); -+ -+ for (j = 0; j < nfds; j++) -+ { -+ err = reauthenticate (ports[i], &newports[newfds]); -+ if (err) -+ goto cleanup; -+ fds[j] = opened_fds[newfds] = _hurd_intern_fd (newports[newfds], -+ fds[j], 0); -+ if (fds[j] == -1) -+ { -+ err = errno; -+ __mach_port_deallocate (__mach_task_self (), newports[newfds]); -+ goto cleanup; -+ } -+ i++; -+ newfds++; -+ } -+ } -+ } -+ -+ for (i = 0; i < nports; i++) -+ __mach_port_deallocate (mach_task_self (), ports[i]); -+ - __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen); - - return (buf - data); -+ -+cleanup: -+ /* Clean up all the file descriptors from port 0 to i-1. */ -+ if (nports > 0) -+ { -+ ii = 0; -+ newfds = 0; -+ for (cmsg = CMSG_FIRSTHDR (message); -+ cmsg; -+ cmsg = CMSG_NXTHDR (message, cmsg)) -+ { -+ if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) -+ { -+ nfds = (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr))) -+ / sizeof (int); -+ for (j = 0; j < nfds && ii < i; j++, ii++, newfds++) -+ { -+ _hurd_fd_close (_hurd_fd_get (opened_fds[newfds])); -+ __mach_port_deallocate (__mach_task_self (), newports[newfds]); -+ __mach_port_deallocate (__mach_task_self (), ports[ii]); -+ } -+ } -+ } -+ } -+ -+ __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen); -+ return __hurd_fail (err); - } - - weak_alias (__libc_recvmsg, recvmsg) -diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c -index 5a93c63..612581c 100644 ---- a/sysdeps/mach/hurd/sendmsg.c -+++ b/sysdeps/mach/hurd/sendmsg.c -@@ -31,6 +31,10 @@ ssize_t - __libc_sendmsg (int fd, const struct msghdr *message, int flags) - { - error_t err = 0; -+ struct cmsghdr *cmsg; -+ mach_port_t *ports = NULL; -+ mach_msg_type_number_t nports = 0; -+ int *fds, nfds; - struct sockaddr_un *addr = message->msg_name; - socklen_t addr_len = message->msg_namelen; - addr_port_t aport = MACH_PORT_NULL; -@@ -43,6 +47,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) - mach_msg_type_number_t len; - mach_msg_type_number_t amount; - int dealloc = 0; -+ int socketrpc = 0; - int i; - - /* Find the total number of bytes to be written. */ -@@ -100,6 +105,48 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) - } - } - -+ /* Allocate enough room for ports. */ -+ cmsg = CMSG_FIRSTHDR (message); -+ for (; cmsg; cmsg = CMSG_NXTHDR (message, cmsg)) -+ if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) -+ nports += (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr))) -+ / sizeof (int); -+ -+ if (nports) -+ ports = __alloca (nports * sizeof (mach_port_t)); -+ -+ nports = 0; -+ for (cmsg = CMSG_FIRSTHDR (message); -+ cmsg; -+ cmsg = CMSG_NXTHDR (message, cmsg)) -+ { -+ if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) -+ { -+ /* SCM_RIGHTS support: send FDs. */ -+ fds = (int *) CMSG_DATA (cmsg); -+ nfds = (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr))) -+ / sizeof (int); -+ -+ for (i = 0; i < nfds; i++) -+ { -+ err = HURD_DPORT_USE -+ (fds[i], -+ ({ -+ err = __io_restrict_auth (port, &ports[nports], -+ 0, 0, 0, 0); -+ if (! err) -+ nports++; -+ /* We pass the flags in the control data. */ -+ fds[i] = descriptor->flags; -+ err; -+ })); -+ -+ if (err) -+ goto out; -+ } -+ } -+ } -+ - if (addr) - { - if (addr->sun_family == AF_LOCAL) -@@ -109,9 +156,8 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) - file_t file = __file_name_lookup (name, 0, 0); - if (file == MACH_PORT_NULL) - { -- if (dealloc) -- __vm_deallocate (__mach_task_self (), data.addr, len); -- return -1; -+ err = errno; -+ goto out; - } - err = __ifsock_getsockaddr (file, &aport); - __mach_port_deallocate (__mach_task_self (), file); -@@ -119,11 +165,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) - /* The file did not grok the ifsock protocol. */ - err = ENOTSOCK; - if (err) -- { -- if (dealloc) -- __vm_deallocate (__mach_task_self (), data.addr, len); -- return __hurd_fail (err); -- } -+ goto out; - } - else - err = EIEIO; -@@ -142,8 +184,9 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) - /* Send the data. */ - err = __socket_send (port, aport, - flags, data.ptr, len, -- NULL, -- MACH_MSG_TYPE_COPY_SEND, 0, -+ ports, -+ MACH_MSG_TYPE_COPY_SEND, -+ nports, - message->msg_control, - message->msg_controllen, - &amount); -@@ -152,11 +195,19 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) - } - err; - })); -+ socketrpc = 1; -+ -+ out: -+ for (i = 0; i < nports; i++) -+ __mach_port_deallocate (__mach_task_self (), ports[i]); - - if (dealloc) - __vm_deallocate (__mach_task_self (), data.addr, len); - -- return err ? __hurd_sockfail (fd, flags, err) : amount; -+ if (socketrpc) -+ return err ? __hurd_sockfail (fd, flags, err) : amount; -+ else -+ return __hurd_fail (err); - } - - weak_alias (__libc_sendmsg, sendmsg) --- -tg: (b4578ba..) t/sendmsg-SCM_RIGHTS (depends on: 64a17f1adde4715bb6607f64decd73b2df9e6852) diff --git a/debian/patches/hurd-i386/git-setitimer.diff b/debian/patches/hurd-i386/git-setitimer.diff deleted file mode 100644 index b66f891f..00000000 --- a/debian/patches/hurd-i386/git-setitimer.diff +++ /dev/null @@ -1,86 +0,0 @@ -From: Richard Braun <rbraun@sceen.net> -Subject: Fix Hurd implementation of setitimer. -Date: Wed Dec 26 16:31:14 2012 +0000 - - The preemptor sigcode doesn't match since the POSIX sigcode SI_TIMER is - used when SIGALRM is sent. In addition, The inline version of - hurd_preempt_signals doesn't update _hurdsig_preempted_set. For these - reasons, the preemptor would be skipped by post_signal. - - * sysdeps/mach/hurd/setitimer.c (setitimer_locked): Fix preemptor setup. - ---- - setitimer.c | 20 ++++++++++++-------- - 1 file changed, 12 insertions(+), 8 deletions(-) - ---- a/sysdeps/mach/hurd/setitimer.c -+++ b/sysdeps/mach/hurd/setitimer.c -@@ -128,7 +128,8 @@ timer_thread (void) - - /* Forward declaration. */ - static int setitimer_locked (const struct itimerval *new, -- struct itimerval *old, void *crit); -+ struct itimerval *old, void *crit, -+ int hurd_siglocked); - - static sighandler_t - restart_itimer (struct hurd_signal_preemptor *preemptor, -@@ -142,7 +143,7 @@ restart_itimer (struct hurd_signal_preem - /* Either reload or disable the itimer. */ - __spin_lock (&_hurd_itimer_lock); - it.it_value = it.it_interval = _hurd_itimerval.it_interval; -- setitimer_locked (&it, NULL, NULL); -+ setitimer_locked (&it, NULL, NULL, 1); - - /* Continue with normal delivery (or hold, etc.) of SIGALRM. */ - return SIG_ERR; -@@ -154,7 +155,7 @@ restart_itimer (struct hurd_signal_preem - - static int - setitimer_locked (const struct itimerval *new, struct itimerval *old, -- void *crit) -+ void *crit, int hurd_siglocked) - { - struct itimerval newval; - struct timeval now, remaining, elapsed; -@@ -192,16 +193,19 @@ setitimer_locked (const struct itimerval - run `restart_itimer' each time a SIGALRM would arrive. */ - static struct hurd_signal_preemptor preemptor = - { -- __sigmask (SIGALRM), 0, 0, -+ __sigmask (SIGALRM), SI_TIMER, SI_TIMER, - &restart_itimer, - }; -- __mutex_lock (&_hurd_siglock); -+ if (!hurd_siglocked) -+ __mutex_lock (&_hurd_siglock); - if (! preemptor.next && _hurdsig_preemptors != &preemptor) - { - preemptor.next = _hurdsig_preemptors; - _hurdsig_preemptors = &preemptor; -+ _hurdsig_preempted_set |= preemptor.signals; - } -- __mutex_unlock (&_hurd_siglock); -+ if (!hurd_siglocked) -+ __mutex_unlock (&_hurd_siglock); - - if (_hurd_itimer_port == MACH_PORT_NULL) - { -@@ -349,7 +353,7 @@ __setitimer (enum __itimer_which which, - - crit = _hurd_critical_section_lock (); - __spin_lock (&_hurd_itimer_lock); -- return setitimer_locked (new, old, crit); -+ return setitimer_locked (new, old, crit, 0); - } - - static void -@@ -364,7 +368,7 @@ fork_itimer (void) - it = _hurd_itimerval; - it.it_value = it.it_interval; - -- setitimer_locked (&it, NULL, NULL); -+ setitimer_locked (&it, NULL, NULL, 0); - - (void) &fork_itimer; /* Avoid gcc optimizing out the function. */ - } diff --git a/debian/patches/hurd-i386/git-single-select-timeout.diff b/debian/patches/hurd-i386/git-single-select-timeout.diff deleted file mode 100644 index 60d755e7..00000000 --- a/debian/patches/hurd-i386/git-single-select-timeout.diff +++ /dev/null @@ -1,35 +0,0 @@ -commit fffcbbb0b5ff8864086f7b58fdbb8aa4c71943d0 -Author: Richard Braun <rbraun@sceen.net> -Date: Mon Dec 17 09:57:41 2012 +0000 - - Fix _hurd_select for single fd sets - - The function attempts to optimize this case by performing one IPC system call - with the timeout included among the parameters, but in the absence of a reply, - it will call mach_msg again with the same timeout later, effectively doubling - the total timeout of the select/poll call. - - Remove this optimization for the time being. - - * hurd/hurdselect.c (_hurd_select): Always call __io_select with no timeout. - ---- - hurdselect.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/hurd/hurdselect.c b/hurd/hurdselect.c -index 21ba5f4..a02c7be 100644 ---- a/hurd/hurdselect.c -+++ b/hurd/hurdselect.c -@@ -236,10 +236,7 @@ _hurd_select (int nfds, - { - int type = d[i].type; - d[i].reply_port = __mach_reply_port (); -- err = __io_select (d[i].io_port, d[i].reply_port, -- /* Poll only if there's a single descriptor. */ -- (firstfd == lastfd) ? to : 0, -- &type); -+ err = __io_select (d[i].io_port, d[i].reply_port, 0, &type); - switch (err) - { - case MACH_RCV_TIMED_OUT: diff --git a/debian/patches/hurd-i386/local-enable-ldconfig.diff b/debian/patches/hurd-i386/local-enable-ldconfig.diff index abb0a620..44348e0e 100644 --- a/debian/patches/hurd-i386/local-enable-ldconfig.diff +++ b/debian/patches/hurd-i386/local-enable-ldconfig.diff @@ -25,7 +25,7 @@ +++ b/sysdeps/mach/hurd/configure.ac @@ -30,3 +30,5 @@ dnl ifunc does not work yet for static binaries - dnl http://www.gnu.org/software/hurd/open_issues/ifunc.html + dnl https://www.gnu.org/software/hurd/open_issues/ifunc.html libc_cv_ld_gnu_indirect_function=no + +use_ldconfig=yes diff --git a/debian/patches/hurd-i386/local-exec_filename.diff b/debian/patches/hurd-i386/local-exec_filename.diff index a0ebeccb..6a844ba6 100644 --- a/debian/patches/hurd-i386/local-exec_filename.diff +++ b/debian/patches/hurd-i386/local-exec_filename.diff @@ -3,10 +3,10 @@ Keep compatibility with experimental implementation --- hurd/Makefile | 4 ++-- hurd/Versions | 4 ++++ - hurd/hurdexec.c | 32 ++++++++++++++++++++++++++++++++ + hurd/hurdexec.c | 29 +++++++++++++++++++++++++++++ sysdeps/mach/hurd/i386/libc.abilist | 1 + sysdeps/mach/hurd/spawni.c | 13 +++++++++++++ - 5 files changed, 52 insertions(+), 2 deletions(-) + 5 files changed, 49 insertions(+), 2 deletions(-) --- a/hurd/Makefile +++ b/hurd/Makefile @@ -103,7 +103,7 @@ Keep compatibility with experimental implementation #include <assert.h> #include <argz.h> #include "spawn_int.h" -@@ -658,6 +659,18 @@ +@@ -770,6 +771,18 @@ dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize, ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports, ints, INIT_INT_MAX, @@ -124,11 +124,11 @@ Keep compatibility with experimental implementation /* Fallback for backwards compatibility. This can just be removed --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist -@@ -1978,6 +1978,7 @@ +@@ -1947,6 +1947,7 @@ GLIBC_2.2.6 xprt_unregister F GLIBC_2.21 __mach_host_self_ D 0x4 GLIBC_2.21 __pthread_get_cleanup_stack F +GLIBC_2.21 _hurd_exec_file_name F - GLIBC_2.21 _hurd_sigstate_delete F - GLIBC_2.21 _hurd_sigstate_lock F - GLIBC_2.21 _hurd_sigstate_pending F + GLIBC_2.21 mach_print F + GLIBC_2.21 pthread_attr_destroy F + GLIBC_2.21 pthread_attr_getdetachstate F diff --git a/debian/patches/hurd-i386/local-mach_print.diff b/debian/patches/hurd-i386/local-mach_print.diff index aa0a48bd..e9276e42 100644 --- a/debian/patches/hurd-i386/local-mach_print.diff +++ b/debian/patches/hurd-i386/local-mach_print.diff @@ -1,6 +1,6 @@ --- a/mach/Versions +++ b/mach/Versions -@@ -56,6 +56,7 @@ +@@ -57,6 +57,7 @@ } GLIBC_2.21 { __mach_host_self_; @@ -8,14 +8,12 @@ } HURD_CTHREADS_0.3 { -Index: glibc-2.27/sysdeps/mach/hurd/i386/libc.abilist -=================================================================== ---- glibc-2.27.orig/sysdeps/mach/hurd/i386/libc.abilist -+++ glibc-2.27/sysdeps/mach/hurd/i386/libc.abilist -@@ -1995,6 +1995,7 @@ GLIBC_2.21 _hurd_sigstate_lock F - GLIBC_2.21 _hurd_sigstate_pending F - GLIBC_2.21 _hurd_sigstate_set_global_rcv F - GLIBC_2.21 _hurd_sigstate_unlock F +--- a/sysdeps/mach/hurd/i386/libc.abilist ++++ b/sysdeps/mach/hurd/i386/libc.abilist +@@ -1947,6 +1947,7 @@ + GLIBC_2.2.6 xprt_unregister F + GLIBC_2.21 __mach_host_self_ D 0x4 + GLIBC_2.21 __pthread_get_cleanup_stack F +GLIBC_2.21 mach_print F GLIBC_2.21 pthread_attr_destroy F GLIBC_2.21 pthread_attr_getdetachstate F diff --git a/debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff b/debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff index ba932b20..0a697724 100644 --- a/debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff +++ b/debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff @@ -7,21 +7,20 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. --- hurd/hurd/signal.h | 5 + - hurd/hurd/sigpreempt.h | 4 hurd/hurdfault.c | 2 hurd/hurdinit.c | 2 - hurd/hurdsig.c | 2 - sysdeps/mach/hurd/bits/sigaction.h | 81 +++++++++++++++++++ + hurd/hurdsig.c | 6 - + sysdeps/mach/hurd/bits/sigaction.h | 86 +++++++++++++++++++++ sysdeps/mach/hurd/i386/bits/sigcontext.h | 4 - sysdeps/mach/hurd/i386/exc2signal.c | 123 ++++++++++++++++++------------ - sysdeps/mach/hurd/i386/trampoline.c | 126 ++++++++++++++++++++++++++++--- + sysdeps/mach/hurd/i386/exc2signal.c | 123 +++++++++++++++++++----------- + sysdeps/mach/hurd/i386/trampoline.c | 125 ++++++++++++++++++++++++++++--- sysdeps/mach/hurd/kill.c | 2 sysdeps/mach/hurd/setitimer.c | 2 - 11 files changed, 289 insertions(+), 64 deletions(-) + 10 files changed, 293 insertions(+), 64 deletions(-) --- a/hurd/hurd/signal.h +++ b/hurd/hurd/signal.h -@@ -285,6 +285,11 @@ +@@ -290,6 +290,11 @@ extern void _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo); @@ -46,7 +45,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. --- a/hurd/hurdinit.c +++ b/hurd/hurdinit.c -@@ -175,7 +175,7 @@ +@@ -177,7 +177,7 @@ /* This process is "traced", meaning it should stop on signals or exec. We are all set up now to handle signals. Stop ourselves, to inform our parent (presumably a debugger) that the exec has completed. */ @@ -57,7 +56,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. #include <shlib-compat.h> --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c -@@ -767,7 +767,7 @@ +@@ -730,7 +730,7 @@ { /* PE cannot be null. */ do { @@ -66,7 +65,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. { if (pe->preemptor) { -@@ -1366,7 +1366,7 @@ _S_msg_sig_post (mach_port_t me, +@@ -1374,7 +1374,7 @@ if (err = signal_allowed (signo, refport)) return err; @@ -75,7 +74,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. d.exc = 0; /* Post the signal to a global receiver thread (or mark it pending in -@@ -1395,7 +1395,7 @@ _S_msg_sig_post_untraced (mach_port_t me, +@@ -1403,7 +1403,7 @@ if (err = signal_allowed (signo, refport)) return err; @@ -462,13 +461,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. struct sigcontext * _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, int signo, struct hurd_signal_detail *detail, -@@ -37,20 +90,44 @@ - void firewall (void); - extern const void _hurd_intr_rpc_msg_cx_sp; - extern const void _hurd_intr_rpc_msg_sp_restored; -+ const struct sigaction *action; - void *volatile sigsp; - struct sigcontext *scp; +@@ -43,15 +96,38 @@ struct { int signo; @@ -509,7 +502,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. if (ss->context) { /* We have a previous sigcontext that sigreturn was about -@@ -74,9 +151,13 @@ +@@ -94,9 +170,13 @@ the SP on sigreturn. */ state->basic.uesp = state->basic.ecx; @@ -525,7 +518,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. if ((action->sa_flags & SA_ONSTACK) && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK))) -@@ -138,15 +219,9 @@ +@@ -140,15 +220,9 @@ = &stackframe->link.thread.next; ss->active_resources = &stackframe->link; @@ -542,7 +535,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0; /* struct sigcontext is laid out so that starting at sc_gs mimics a -@@ -160,6 +235,35 @@ +@@ -162,6 +236,35 @@ &state->fpu, &scp->sc_i386_float_state, sizeof (state->fpu)); @@ -591,7 +584,7 @@ Subject: [PATCH] implement SA_SIGINFO signal handlers. frobnication of the task. */ --- a/sysdeps/mach/hurd/setitimer.c +++ b/sysdeps/mach/hurd/setitimer.c -@@ -103,7 +103,7 @@ +@@ -105,7 +105,7 @@ __msg_sig_post_request (_hurd_msgport, _hurd_itimer_port, MACH_MSG_TYPE_MAKE_SEND_ONCE, diff --git a/debian/patches/hurd-i386/tg-thread-cancel.diff b/debian/patches/hurd-i386/tg-thread-cancel.diff index f1f9cef0..a0c15c77 100644 --- a/debian/patches/hurd-i386/tg-thread-cancel.diff +++ b/debian/patches/hurd-i386/tg-thread-cancel.diff @@ -31,29 +31,25 @@ http://lists.gnu.org/archive/html/bug-hurd/2014-05/msg00025.html * sysdeps/mach/hurd/spawni.c (__spawni): Likewise. --- - hurd/hurdexec.c | 1 - - hurd/thread-cancel.c | 2 -- - sysdeps/mach/hurd/jmp-unwind.c | 3 +-- - sysdeps/mach/hurd/spawni.c | 1 - + hurd/hurdexec.c | 1 - + hurd/thread-cancel.c | 2 -- + sysdeps/mach/hurd/jmp-unwind.c | 3 +-- + sysdeps/mach/hurd/spawni.c | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) -diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c -index 0ced7f3..1de90c0 100644 --- a/hurd/hurdexec.c +++ b/hurd/hurdexec.c -@@ -104,7 +104,6 @@ _hurd_exec (task_t task, file_t file, +@@ -123,7 +123,6 @@ ss = _hurd_self_sigstate (); - assert (! __spin_lock_locked (&ss->critical_section_lock)); __spin_lock (&ss->critical_section_lock); - __spin_lock (&ss->lock); -diff --git a/hurd/thread-cancel.c b/hurd/thread-cancel.c -index c7f88ee..eaf3d9e 100644 + _hurd_sigstate_lock (ss); --- a/hurd/thread-cancel.c +++ b/hurd/thread-cancel.c -@@ -51,7 +51,6 @@ hurd_thread_cancel (thread_t thread) +@@ -51,7 +51,6 @@ return 0; } @@ -61,7 +57,7 @@ index c7f88ee..eaf3d9e 100644 __spin_lock (&ss->critical_section_lock); __spin_lock (&ss->lock); err = __thread_suspend (thread); -@@ -91,7 +90,6 @@ hurd_check_cancel (void) +@@ -91,7 +90,6 @@ int cancel; __spin_lock (&ss->lock); @@ -69,11 +65,9 @@ index c7f88ee..eaf3d9e 100644 cancel = ss->cancel; ss->cancel = 0; __spin_unlock (&ss->lock); -diff --git a/sysdeps/mach/hurd/jmp-unwind.c b/sysdeps/mach/hurd/jmp-unwind.c -index bdc24b9..0422d9e 100644 --- a/sysdeps/mach/hurd/jmp-unwind.c +++ b/sysdeps/mach/hurd/jmp-unwind.c -@@ -49,9 +49,8 @@ _longjmp_unwind (jmp_buf env, int val) +@@ -49,9 +49,8 @@ /* All access to SS->active_resources must take place inside a critical section where signal handlers cannot run. */ @@ -84,17 +78,15 @@ index bdc24b9..0422d9e 100644 /* Remove local signal preemptors being unwound past. */ while (ss->preemptors -diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c -index 867579d..bcd06dd 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c -@@ -235,7 +235,6 @@ __spawni (pid_t *pid, const char *file, +@@ -333,7 +333,6 @@ ss = _hurd_self_sigstate (); - assert (! __spin_lock_locked (&ss->critical_section_lock)); __spin_lock (&ss->critical_section_lock); - __spin_lock (&ss->lock); --- + _hurd_sigstate_lock (ss); +--- tg: (9a079e2..) t/thread-cancel (depends on: baseline) diff --git a/debian/patches/localedata/fo_FO-date_fmt.diff b/debian/patches/localedata/fo_FO-date_fmt.diff index cb49f2a0..7aaf214c 100644 --- a/debian/patches/localedata/fo_FO-date_fmt.diff +++ b/debian/patches/localedata/fo_FO-date_fmt.diff @@ -7,22 +7,19 @@ # DP: Date: 2006-01-10 --- - localedata/locales/fo_FO | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + localedata/locales/fo_FO | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) --- a/localedata/locales/fo_FO +++ b/localedata/locales/fo_FO -@@ -98,11 +98,12 @@ +@@ -98,8 +98,8 @@ "oktober";/ "november";/ "desember" --d_t_fmt "%a %d %b %Y %T %Z" +-d_t_fmt "%a %d %b %Y %T" +-date_fmt "%a %d %b %Y %T %Z" +d_t_fmt "%a. %d. %b. %Y %T %Z" ++date_fmt "%1 tann %-e. %B %Y klokkan %T (UTC%z)" d_fmt "%d//%m-%Y" t_fmt "%T" am_pm "";"" - t_fmt_ampm "" -+date_fmt "%1 tann %-e. %B %Y klokkan %T (UTC%z)" - week 7;19971130;4 - first_weekday 2 - END LC_TIME diff --git a/debian/patches/localedata/locale-ku_TR.diff b/debian/patches/localedata/locale-ku_TR.diff index 4cc6264e..d15e6288 100644 --- a/debian/patches/localedata/locale-ku_TR.diff +++ b/debian/patches/localedata/locale-ku_TR.diff @@ -7,8 +7,8 @@ # DP: Date: 2006-01-06 --- - localedata/locales/ku_TR | 70 ++++++++++++++++++++++++----------------------- - 1 file changed, 36 insertions(+), 34 deletions(-) + localedata/locales/ku_TR | 67 ++++++++++++++++++++++++----------------------- + 1 file changed, 35 insertions(+), 32 deletions(-) --- a/localedata/locales/ku_TR +++ b/localedata/locales/ku_TR @@ -91,7 +91,7 @@ d_t_fmt "%A %d %B %Y %T %Z" d_fmt "%d//%m//%Y" t_fmt "%T" -@@ -170,19 +172,19 @@ +@@ -170,13 +172,14 @@ LC_NAME name_fmt "%d%t%g%t%m%t%f" % TODO @@ -113,10 +113,3 @@ END LC_NAME LC_ADDRESS - postal_fmt "%f%N%a%N%d%N%b%N%s %h %e %r%N%z %T%N%c%N" --% TODO --country_name "Turkey" -+country_name "Tirkiye" - country_post "TR" - country_ab2 "TR" - country_ab3 "TUR" diff --git a/debian/patches/localedata/locale-zh_TW.diff b/debian/patches/localedata/locale-zh_TW.diff index 42d4cffa..02612cfe 100644 --- a/debian/patches/localedata/locale-zh_TW.diff +++ b/debian/patches/localedata/locale-zh_TW.diff @@ -7,7 +7,7 @@ Not submitted yet. --- a/localedata/locales/zh_TW +++ b/localedata/locales/zh_TW -@@ -114,10 +114,10 @@ +@@ -114,13 +114,13 @@ "<U5341><U6708>";"<U5341><U4E00><U6708>";"<U5341><U4E8C><U6708>" % d_t_fmt: "%Y<y>%m<m>%d<d> (%A) %H<hr>%M<m>%S<s>" @@ -15,6 +15,9 @@ Not submitted yet. +d_t_fmt "%Y<U5E74>%m<U6708>%d<U65E5> (%A) %H<U6642>/ %M<U5206>%S<U79D2>" + date_fmt "<U897F><U5143>%Y<U5E74>%m<U6708>%d<U65E5> (%A) %H<U6642>/ + %M<U5206>%S<U79D2> %Z" + -d_fmt "<U897F><U5143>%Y<U5E74>%m<U6708>%d<U65E5>" +d_fmt "%Y<U5E74>%m<U6708>%d<U65E5>" diff --git a/debian/patches/localedata/locales-fr.diff b/debian/patches/localedata/locales-fr.diff index d35b6f72..d7c54306 100644 --- a/debian/patches/localedata/locales-fr.diff +++ b/debian/patches/localedata/locales-fr.diff @@ -16,14 +16,6 @@ --- a/localedata/locales/fr_BE +++ b/localedata/locales/fr_BE -@@ -120,6 +120,7 @@ - t_fmt "%T" - am_pm "";"" - t_fmt_ampm "" -+date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" - - week 7;19971130;4 - first_weekday 2 @@ -140,7 +141,7 @@ END LC_MEASUREMENT @@ -42,26 +34,8 @@ lang_name "fran<U00E7>ais" lang_ab "fr" lang_term "fra" ---- a/localedata/locales/fr_CA -+++ b/localedata/locales/fr_CA -@@ -117,6 +117,7 @@ - t_fmt "%T" - am_pm "";"" - t_fmt_ampm "" -+date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" - week 7;19971130;1 - END LC_TIME - --- a/localedata/locales/fr_CH +++ b/localedata/locales/fr_CH -@@ -104,6 +104,7 @@ - t_fmt "%T" - am_pm "";"" - t_fmt_ampm "" -+date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" - week 7;19971130;4 - first_weekday 2 - END LC_TIME @@ -123,7 +124,7 @@ END LC_MEASUREMENT @@ -82,14 +56,6 @@ lang_term "fra" --- a/localedata/locales/fr_FR +++ b/localedata/locales/fr_FR -@@ -136,6 +136,7 @@ - t_fmt "%T" - am_pm "";"" - t_fmt_ampm "" -+date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" - - week 7;19971130;4 - first_weekday 2 @@ -158,6 +159,11 @@ LC_NAME @@ -112,14 +78,6 @@ lang_name "fran<U00E7>ais" --- a/localedata/locales/fr_LU +++ b/localedata/locales/fr_LU -@@ -120,6 +120,7 @@ - t_fmt "%T" - am_pm "";"" - t_fmt_ampm "" -+date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" - week 7;19971130;4 - first_weekday 2 - END LC_TIME @@ -139,7 +140,7 @@ END LC_MEASUREMENT diff --git a/debian/patches/localedata/submitted-bz9725-locale-sv_SE.diff b/debian/patches/localedata/submitted-bz9725-locale-sv_SE.diff deleted file mode 100644 index db16eff7..00000000 --- a/debian/patches/localedata/submitted-bz9725-locale-sv_SE.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- - localedata/locales/sv_SE | 4 ++++ - 1 file changed, 4 insertions(+) - ---- a/localedata/locales/sv_SE -+++ b/localedata/locales/sv_SE -@@ -200,6 +200,10 @@ - t_fmt "%H:%M:%S" - am_pm "";"" - t_fmt_ampm "" -+% Appropriate date representation (date(1)) "%a %e %b %Y %H:%M:%S %Z" -+date_fmt "<U0025><U0061><U0020><U0025><U0065><U0020><U0025><U0062>/ -+<U0020><U0025><U0059><U0020><U0025><U0048><U003A><U0025><U004D><U003A>/ -+<U0025><U0053><U0020><U0025><U005A>" - week 7;19971130;4 - first_weekday 2 - END LC_TIME diff --git a/debian/patches/localedata/submitted-en_AU-date_fmt.diff b/debian/patches/localedata/submitted-en_AU-date_fmt.diff deleted file mode 100644 index 1c0900f8..00000000 --- a/debian/patches/localedata/submitted-en_AU-date_fmt.diff +++ /dev/null @@ -1,18 +0,0 @@ -2012-04-29 Aurelien Jarno <aurelien@aurel32.net> - - * locales/en_AU: Change date_fmt to match Australian standards. - ---- - localedata/locales/en_AU | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/localedata/locales/en_AU -+++ b/localedata/locales/en_AU -@@ -113,6 +113,7 @@ - t_fmt "%T" - am_pm "AM";"PM" - t_fmt_ampm "%I:%M:%S %p" -+date_fmt "%a %e %b %H:%M:%S %Z %Y" - week 7;19971130;1 - END LC_TIME - diff --git a/debian/patches/powerpc/local-powerpc8xx-dcbz.diff b/debian/patches/powerpc/local-powerpc8xx-dcbz.diff index c9e7e4f7..199c92a3 100644 --- a/debian/patches/powerpc/local-powerpc8xx-dcbz.diff +++ b/debian/patches/powerpc/local-powerpc8xx-dcbz.diff @@ -1,16 +1,16 @@ ---- a/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c -+++ b/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c -@@ -25,10 +25,28 @@ - /* Scan the Aux Vector for the "Data Cache Block Size" entry. If found - verify that the static extern __cache_line_size is defined by checking - for not NULL. If it is defined then assign the cache block size -- value to __cache_line_size. */ -+ value to __cache_line_size. This is used by memset to -+ optimize setting to zero. We have to detect 8xx processors, which +--- a/sysdeps/unix/sysv/linux/powerpc/dl-auxv.h ++++ b/sysdeps/unix/sysv/linux/powerpc/dl-auxv.h +@@ -23,8 +23,25 @@ int GLRO(dl_cache_line_size); + #endif + + /* Scan the Aux Vector for the "Data Cache Block Size" entry and assign it +- to dl_cache_line_size. */ +-#define DL_PLATFORM_AUXV \ ++ to dl_cache_line_size. We have to detect 8xx processors, which + have buggy dcbz implementations that cannot report page faults + correctly. That requires reading SPR, which is a privileged + operation. Fortunately 2.2.18 and later emulates PowerPC mfspr -+ reads from the PVR register. */ ++ reads from the PVR register. */ +#ifndef __powerpc64__ + #define DL_PLATFORM_AUXV \ + case AT_DCACHEBSIZE: \ @@ -20,43 +20,11 @@ + if ((pvr & 0xffff0000) == 0x00500000) \ + break; \ + } \ -+ __cache_line_size = av->a_un.a_val; \ ++ GLRO(dl_cache_line_size) = av->a_un.a_val; \ + break; +#else --#define DL_PLATFORM_AUXV \ + #define DL_PLATFORM_AUXV \ case AT_DCACHEBSIZE: \ - __cache_line_size = av->a_un.a_val; \ + GLRO(dl_cache_line_size) = av->a_un.a_val; \ break; +#endif - - #include <sysdeps/unix/sysv/linux/dl-sysdep.c> ---- a/sysdeps/unix/sysv/linux/powerpc/libc-start.c -+++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c -@@ -73,11 +73,25 @@ - - /* Initialize the __cache_line_size variable from the aux vector. For the - static case, we also need _dl_hwcap, _dl_hwcap2 and _dl_platform, so we -- can call __tcb_parse_hwcap_and_convert_at_platform (). */ -+ can call __tcb_parse_hwcap_and_convert_at_platform (). -+ This is used by memset to optimize setting to zero. We have to -+ detect 8xx processors, which have buggy dcbz implementations that -+ cannot report page faults correctly. That requires reading SPR, -+ which is a privileged operation. Fortunately 2.2.18 and later -+ emulates PowerPC mfspr reads from the PVR register. */ - for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av) - switch (av->a_type) - { - case AT_DCACHEBSIZE: -+#ifndef __powerpc64__ -+ { -+ unsigned pvr = 0; -+ -+ asm ("mfspr %0, 287" : "=r" (pvr) :); -+ if ((pvr & 0xffff0000) == 0x00500000) -+ break; -+ } -+#endif - __cache_line_size = av->a_un.a_val; - break; - #ifndef SHARED diff --git a/debian/patches/series b/debian/patches/series index d40cbb83..77a1801c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,4 +1,4 @@ -git-updates.diff +#git-updates.diff locale/check-unknown-symbols.diff locale/locale-print-LANGUAGE.diff @@ -12,9 +12,7 @@ localedata/locales-fr.diff localedata/locale-en_DK.diff localedata/locale-zh_TW.diff localedata/tailor-iso14651_t1.diff -localedata/submitted-bz9725-locale-sv_SE.diff localedata/locale-C.diff -localedata/submitted-en_AU-date_fmt.diff localedata/submitted-es_MX-decimal_point.diff alpha/local-gcc4.1.diff @@ -33,37 +31,22 @@ arm/local-arm-futex.diff hppa/local-inlining.diff hurd-i386/posix_openpt.diff -hurd-i386/git-ONSTACK.diff -hurd-i386/git-getrandom.diff -hurd-i386/git-altstack-RPC.diff hurd-i386/local-enable-ldconfig.diff -hurd-i386/git-context_functions.diff hurd-i386/tg-sysvshm.diff hurd-i386/tg-thread-cancel.diff hurd-i386/tg-bigmem.diff hurd-i386/local-disable-ioctls.diff -hurd-i386/git-sendmsg-SCM_RIGHTS.diff hurd-i386/tg-sendmsg-SCM_CREDS.diff hurd-i386/tg-mach-hurd-link.diff hurd-i386/local-ED.diff hurd-i386/local-madvise_warn.diff -hurd-i386/git-hurdsig-fixes.diff -hurd-i386/git-hurdsig-global-dispositions.diff -hurd-i386/git-hurdsig-globaldisp-version.diff hurd-i386/tg-hurdsig-SA_SIGINFO.diff -hurd-i386/git-hurdsig-fixes-2.diff hurd-i386/tg-hooks.diff hurd-i386/local-usr.diff -hurd-i386/git-hurdsig-boot-fix.diff -hurd-i386/git-single-select-timeout.diff -hurd-i386/git-setitimer.diff hurd-i386/tg-pie-sbrk.diff hurd-i386/tg-ifaddrs_v6.diff -hurd-i386/git-remap_getcwd.diff hurd-i386/tg-EIEIO-fr.diff hurd-i386/tg-EGREGIOUS-fr.diff -hurd-i386/git-io_select_timeout.diff -hurd-i386/git-poll_errors_fixes.diff hurd-i386/unsubmitted-clock_t_centiseconds.diff hurd-i386/submitted-path_mounted.diff hurd-i386/tg-sigstate_thread_reference.diff @@ -75,10 +58,6 @@ hurd-i386/tg-eintr.diff hurd-i386/tg-libc_rwlock_recursive.diff hurd-i386/local-no_unsupported_ioctls.diff hurd-i386/local-exec_filename.diff -hurd-i386/git-libpthread_sigs.diff -hurd-i386/git-hurd_sigstate-PLT.diff -hurd-i386/git-rlock.diff -hurd-i386/git-errno_location.diff i386/local-biarch.diff i386/unsubmitted-quiet-ldconfig.diff @@ -118,7 +97,6 @@ any/local-fhs-linux-paths.diff any/local-fhs-nscd.diff any/local-ld-multiarch.diff any/local-ldso-disable-hwcap.diff -any/local-ldconfig.diff any/local-nss-upgrade.diff any/local-stubs_h.diff any/local-tcsetaddr.diff @@ -130,7 +108,6 @@ any/local-ldconfig-multiarch.diff any/local-disable-libnss-db.diff any/local-revert-bz13979.diff any/unsubmitted-ldso-machine-mismatch.diff -any/unsubmitted-dlopen-static-crash.diff any/local-ldconfig-ignore-ld.so.diff any/local-libpic.diff any/local-bootstrap-headers.diff diff --git a/debian/patches/sh4/local-fpscr_values.diff b/debian/patches/sh4/local-fpscr_values.diff index 1448fbfc..f2bbfd94 100644 --- a/debian/patches/sh4/local-fpscr_values.diff +++ b/debian/patches/sh4/local-fpscr_values.diff @@ -25,8 +25,8 @@ # a* alphasort64; ---- a/sysdeps/unix/sysv/linux/sh/libc.abilist -+++ b/sysdeps/unix/sysv/linux/sh/libc.abilist +--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist ++++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -267,6 +267,7 @@ GLIBC_2.2 __flbf F GLIBC_2.2 __fork F diff --git a/debian/symbols.wildcards b/debian/symbols.wildcards index d95a0a95..d8ffb5d5 100644 --- a/debian/symbols.wildcards +++ b/debian/symbols.wildcards @@ -45,4 +45,5 @@ (symver|optional)GLIBC_2.28 2.28 (symver|optional)GLIBC_2.29 2.29 (symver|optional)GLIBC_2.30 2.30 + (symver|optional)GLIBC_2.31 2.31 (symver|optional)GCC_3.0 2.3.6 |