]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
3 years agosysvipc: Fix tst-sysvshm-linux on x32
Adhemerval Zanella [Thu, 15 Oct 2020 18:45:26 +0000 (15:45 -0300)] 
sysvipc: Fix tst-sysvshm-linux on x32

The Linux shminfo fields are '__syscall_ulong_t' (which is 64-bit
for x32).  This patch fixes the test to compare againt the correct
type and to only clamp the value if '__syscall_ulong_t' is the same
size of 'unsigned long int'.

Checked on x86_64-linux-gnu-x32.

(cherry picked from commit 602da9de696099f543ee2bb3c1520bc178f42fc9)

3 years agolibrt: add test (bug 28213)
Nikita Popov [Thu, 12 Aug 2021 10:39:50 +0000 (16:09 +0530)] 
librt: add test (bug 28213)

This test implements following logic:
1) Create POSIX message queue.
   Register a notification with mq_notify (using NULL attributes).
   Then immediately unregister the notification with mq_notify.
   Helper thread in a vulnerable version of glibc
   should cause NULL pointer dereference after these steps.
2) Once again, register the same notification.
   Try to send a dummy message.
   Test is considered successfulif the dummy message
   is successfully received by the callback function.

Signed-off-by: Nikita Popov <npv1310@gmail.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 4cc79c217744743077bf7a0ec5e0a4318f1e6641)

3 years agolibrt: fix NULL pointer dereference (bug 28213)
Nikita Popov [Mon, 9 Aug 2021 14:47:34 +0000 (20:17 +0530)] 
librt: fix NULL pointer dereference (bug 28213)

Helper thread frees copied attribute on NOTIFY_REMOVED message
received from the OS kernel.  Unfortunately, it fails to check whether
copied attribute actually exists (data.attr != NULL).  This worked
earlier because free() checks passed pointer before actually
attempting to release corresponding memory.  But
__pthread_attr_destroy assumes pointer is not NULL.

So passing NULL pointer to __pthread_attr_destroy will result in
segmentation fault.  This scenario is possible if
notification->sigev_notify_attributes == NULL (which means default
thread attributes should be used).

Signed-off-by: Nikita Popov <npv1310@gmail.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit b805aebd42364fe696e417808a700fdb9800c9e8)

4 years agox86_64: Remove unneeded static PIE check for undefined weak diagnostic
Fangrui Song [Thu, 8 Jul 2021 21:26:22 +0000 (14:26 -0700)] 
x86_64: Remove unneeded static PIE check for undefined weak diagnostic

https://sourceware.org/bugzilla/show_bug.cgi?id=21782 dropped an ld
diagnostic for R_X86_64_PC32 referencing an undefined weak symbol in
-pie links.  Arguably keeping the diagnostic like other ports is more
correct, since statically resolving movl foo(%rip), %eax to the
link-time zero address produces a corrupted output.

It turns out that --enable-static-pie builds do not depend on the ld
behavior. GCC generates GOT indirection for weak declarations for
-fPIE/-fPIC, so what ld does with the PC-relative relocation doesn't
really matter.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 115d242456de158e698ffb0f9a5fee3118e9e825)

4 years agowordexp: handle overflow in positional parameter number (bug 28011)
Andreas Schwab [Fri, 25 Jun 2021 13:02:47 +0000 (15:02 +0200)] 
wordexp: handle overflow in positional parameter number (bug 28011)

Use strtoul instead of atoi so that overflow can be detected.

(cherry picked from commit 5adda61f62b77384718b4c0d8336ade8f2b4b35c)

4 years agoFix use of __pthread_attr_copy in mq_notify (bug 27896)
Florian Weimer [Tue, 1 Jun 2021 15:51:41 +0000 (17:51 +0200)] 
Fix use of __pthread_attr_copy in mq_notify (bug 27896)

__pthread_attr_copy can fail and does not initialize the attribute
structure in that case.

If __pthread_attr_copy is never called and there is no allocated
attribute, pthread_attr_destroy should not be called, otherwise
there is a null pointer dereference in rt/tst-mqueue6.

Fixes commit 42d359350510506b87101cf77202fefcbfc790cb
("Use __pthread_attr_copy in mq_notify (bug 27896)").

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 217b6dc298156bdb0d6aea9ea93e7e394a5ff091)

4 years agoUse __pthread_attr_copy in mq_notify (bug 27896)
Andreas Schwab [Thu, 27 May 2021 10:49:47 +0000 (12:49 +0200)] 
Use __pthread_attr_copy in mq_notify (bug 27896)

Make a deep copy of the pthread attribute object to remove a potential
use-after-free issue.

(cherry picked from commit 42d359350510506b87101cf77202fefcbfc790cb)

4 years agosupport: Typo and formatting fixes
Siddhesh Poyarekar [Mon, 15 Mar 2021 10:30:06 +0000 (16:00 +0530)] 
support: Typo and formatting fixes

- Add a newline to the end of error messages in transfer().
- Fixed the name of support_subprocess_init().

(cherry picked from commit 95c68080a3ded882789b1629f872c3ad531efda0)

4 years agosupport: Pass environ to child process
Siddhesh Poyarekar [Mon, 15 Mar 2021 11:53:30 +0000 (17:23 +0530)] 
support: Pass environ to child process

Pass environ to posix_spawn so that the child process can inherit
environment of the test.

(cherry picked from commit e958490f8c74e660bd93c128b3bea746e268f3f6)

4 years agoFix SXID_ERASE behavior in setuid programs (BZ #27471)
Siddhesh Poyarekar [Tue, 16 Mar 2021 07:07:55 +0000 (12:37 +0530)] 
Fix SXID_ERASE behavior in setuid programs (BZ #27471)

When parse_tunables tries to erase a tunable marked as SXID_ERASE for
setuid programs, it ends up setting the envvar string iterator
incorrectly, because of which it may parse the next tunable
incorrectly.  Given that currently the implementation allows malformed
and unrecognized tunables pass through, it may even allow SXID_ERASE
tunables to go through.

This change revamps the SXID_ERASE implementation so that:

- Only valid tunables are written back to the tunestr string, because
  of which children of SXID programs will only inherit a clean list of
  identified tunables that are not SXID_ERASE.

- Unrecognized tunables get scrubbed off from the environment and
  subsequently from the child environment.

- This has the side-effect that a tunable that is not identified by
  the setxid binary, will not be passed on to a non-setxid child even
  if the child could have identified that tunable.  This may break
  applications that expect this behaviour but expecting such tunables
  to cross the SXID boundary is wrong.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 2ed18c5b534d9e92fc006202a5af0df6b72e7aca)

4 years agoEnhance setuid-tunables test
Siddhesh Poyarekar [Tue, 16 Mar 2021 07:07:54 +0000 (12:37 +0530)] 
Enhance setuid-tunables test

Instead of passing GLIBC_TUNABLES via the environment, pass the
environment variable from parent to child.  This allows us to test
multiple variables to ensure better coverage.

The test list currently only includes the case that's already being
tested.  More tests will be added later.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 061fe3f8add46a89b7453e87eabb9c4695005ced)

4 years agotst-env-setuid: Use support_capture_subprogram_self_sgid
Siddhesh Poyarekar [Tue, 16 Mar 2021 07:07:53 +0000 (12:37 +0530)] 
tst-env-setuid: Use support_capture_subprogram_self_sgid

Use the support_capture_subprogram_self_sgid to spawn an sgid child.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit ca335281068a1ed549a75ee64f90a8310755956f)

4 years agosupport: Add capability to fork an sgid child
Siddhesh Poyarekar [Fri, 9 Apr 2021 15:25:45 +0000 (20:55 +0530)] 
support: Add capability to fork an sgid child

Add a new function support_capture_subprogram_self_sgid that spawns an
sgid child of the running program with its own image and returns the
exit code of the child process.  This functionality is used by at
least three tests in the testsuite at the moment, so it makes sense to
consolidate.

There is also a new function support_subprogram_wait which should
provide simple system() like functionality that does not set up file
actions.  This is useful in cases where only the return code of the
spawned subprocess is interesting.

This patch also ports tst-secure-getenv to this new function.  A
subsequent patch will port other tests.  This also brings an important
change to tst-secure-getenv behaviour.  Now instead of succeeding, the
test fails as UNSUPPORTED if it is unable to spawn a setgid child,
which is how it should have been in the first place.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 716a3bdc41b2b4b864dc64475015ba51e35e1273)

4 years agoS390: Also check vector support in memmove ifunc-selector [BZ #27511]
Stefan Liebler [Tue, 23 Mar 2021 16:29:26 +0000 (17:29 +0100)] 
S390: Also check vector support in memmove ifunc-selector [BZ #27511]

The arch13 memmove variant is currently selected by the ifunc selector
if the Miscellaneous-Instruction-Extensions Facility 3 facility bit
is present, but the function is also using vector instructions.
If the vector support is not present, one is receiving an operation
exception.

Therefore this patch also checks for vector support in the ifunc
selector and in ifunc-impl-list.c.

Just to be sure, the configure check is now also testing an arch13
vector instruction and an arch13 Miscellaneous-Instruction-Extensions
Facility 3 instruction.

(cherry picked from commit 7759be2593b689cb1eafc0f52ee7f59c639e5d2f)

4 years agopowerpc64: Workaround sigtramp vdso return call
Raoni Fassina Firmino [Thu, 11 Feb 2021 20:41:20 +0000 (17:41 -0300)] 
powerpc64: Workaround sigtramp vdso return call

A not so recent kernel change[1] changed how the trampoline
`__kernel_sigtramp_rt64` is used to call signal handlers.

This was exposed on the test misc/tst-sigcontext-get_pc

Before kernel 5.9, the kernel set LR to the trampoline address and
jumped directly to the signal handler, and at the end the signal
handler, as any other function, would `blr` to the address set.  In
other words, the trampoline was executed just at the end of the signal
handler and the only thing it did was call sigreturn.  But since
kernel 5.9 the kernel set CTRL to the signal handler and calls to the
trampoline code, the trampoline then `bctrl` to the address in CTRL,
setting the LR to the next instruction in the middle of the
trampoline, when the signal handler returns, the rest of the
trampoline code executes the same code as before.

Here is the full trampoline code as of kernel 5.11.0-rc5 for
reference:

    V_FUNCTION_BEGIN(__kernel_sigtramp_rt64)
    .Lsigrt_start:
            bctrl   /* call the handler */
            addi    r1, r1, __SIGNAL_FRAMESIZE
            li      r0,__NR_rt_sigreturn
            sc
    .Lsigrt_end:
    V_FUNCTION_END(__kernel_sigtramp_rt64)

This new behavior breaks how `backtrace()` uses to detect the
trampoline frame to correctly reconstruct the stack frame when it is
called from inside a signal handling.

This workaround rely on the fact that the trampoline code is at very
least two (maybe 3?) instructions in size (as it is in the 32 bits
version, only on `li` and `sc`), so it is safe to check the return
address be in the range __kernel_sigtramp_rt64 .. + 4.

[1] subject: powerpc/64/signal: Balance return predictor stack in signal trampoline
    commit: 0138ba5783ae0dcc799ad401a1e8ac8333790df9
    url: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0138ba5783ae0dcc799ad401a1e8ac8333790df9

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 5ee506ed35a2c9184bcb1fb5e79b6cceb9bb0dd1)

4 years agonscd: Fix double free in netgroupcache [BZ #27462]
DJ Delorie [Thu, 25 Feb 2021 21:08:21 +0000 (16:08 -0500)] 
nscd: Fix double free in netgroupcache [BZ #27462]

In commit 745664bd798ec8fd50438605948eea594179fba1 a use-after-free
was fixed, but this led to an occasional double-free.  This patch
tracks the "live" allocation better.

Tested manually by a third party.

Related: RHBZ 1927877

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit dca565886b5e8bd7966e15f0ca42ee5cff686673)

4 years agogconv: Fix assertion failure in ISO-2022-JP-3 module (bug 27256)
Florian Weimer [Wed, 27 Jan 2021 12:36:12 +0000 (13:36 +0100)] 
gconv: Fix assertion failure in ISO-2022-JP-3 module (bug 27256)

The conversion loop to the internal encoding does not follow
the interface contract that __GCONV_FULL_OUTPUT is only returned
after the internal wchar_t buffer has been filled completely.  This
is enforced by the first of the two asserts in iconv/skeleton.c:

      /* We must run out of output buffer space in this
 rerun.  */
      assert (outbuf == outerr);
      assert (nstatus == __GCONV_FULL_OUTPUT);

This commit solves this issue by queuing a second wide character
which cannot be written immediately in the state variable, like
other converters already do (e.g., BIG5-HKSCS or TSCII).

Reported-by: Tavis Ormandy <taviso@gmail.com>
(cherry picked from commit 7d88c6142c6efc160c0ee5e4f85cde382c072888)

4 years agoaarch64: fix static PIE start code for BTI [BZ #27068]
Guillaume Gardet [Mon, 14 Dec 2020 15:38:22 +0000 (15:38 +0000)] 
aarch64: fix static PIE start code for BTI [BZ #27068]

A bti c was missing from rcrt1.o which made all -static-pie
binaries fail at program startup on BTI enabled systems.

Fixes bug 27068.

(cherry picked from commit d4136903a29baabeec8987b53081def8b4a49826)

4 years ago__vfscanf_internal: fix aliasing violation (bug 26690)
Andreas Schwab [Thu, 1 Oct 2020 11:59:13 +0000 (13:59 +0200)] 
__vfscanf_internal: fix aliasing violation (bug 26690)

As noted in <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97264>, the cast
in the call to the read_int function is an aliasing violation.  Change the
type of local variable f to a pointer to unsigned, which allows to
eliminate most casts while only adding three new ones.

(cherry picked from commit c0e9ddf59e73e21afe15fca4e94cf7b4b7359bf2)

4 years agoaarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]
Szabolcs Nagy [Tue, 1 Dec 2020 10:13:18 +0000 (10:13 +0000)] 
aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]

Re-mmap executable segments if possible instead of using mprotect
to add PROT_BTI. This allows using BTI protection with security
policies that prevent mprotect with PROT_EXEC.

If the fd of the ELF module is not available because it was kernel
mapped then mprotect is used and failures are ignored.  To protect
the main executable even when mprotect is filtered the linux kernel
 will have to be changed to add PROT_BTI to it.

The delayed failure reporting is mainly needed because currently
_dl_process_gnu_properties does not propagate failures such that
the required cleanups happen. Using the link_map_machine struct for
error propagation is not ideal, but this seemed to be the least
intrusive solution.

Fixes bug 26831.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit cd543b5eb3642d76e365a131ce676f31fe3f1dd4)

4 years agoelf: Pass the fd to note processing
Szabolcs Nagy [Wed, 28 Oct 2020 15:17:06 +0000 (15:17 +0000)] 
elf: Pass the fd to note processing

To handle GNU property notes on aarch64 some segments need to
be mmaped again, so the fd of the loaded ELF module is needed.

When the fd is not available (kernel loaded modules), then -1
is passed.

The fd is passed to both _dl_process_pt_gnu_property and
_dl_process_pt_note for consistency. Target specific note
processing functions are updated accordingly.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit c00452d7757a300931ee186d043c43b48eeb0875)

4 years agoelf: Move note processing after l_phdr is updated
Szabolcs Nagy [Thu, 29 Oct 2020 13:29:15 +0000 (13:29 +0000)] 
elf: Move note processing after l_phdr is updated

Program headers are processed in two pass: after the first pass
load segments are mmapped so in the second pass target specific
note processing logic can access the notes.

The second pass is moved later so various link_map fields are
set up that may be useful for note processing such as l_phdr.
The second pass should be before the fd is closed so that is
available.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2)

elf: Fix dl-load.c

Rebasing broke commit 38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2
it was supposed to move code.

(cherry picked from commit 751acde7ec335506b54e94ed6f2c998f6c0a22c6)

4 years agoaarch64: align address for BTI protection [BZ #26988]
Szabolcs Nagy [Tue, 1 Dec 2020 10:12:32 +0000 (10:12 +0000)] 
aarch64: align address for BTI protection [BZ #26988]

Handle unaligned executable load segments (the bfd linker is not
expected to produce such binaries, but other linkers may).

Computing the mapping bounds follows _dl_map_object_from_fd more
closely now.

Fixes bug 26988.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 8b8f616e6a594b91d0afb152384bf2a9f72b7288)

4 years agoaarch64: Fix missing BTI protection from dependencies [BZ #26926]
Szabolcs Nagy [Fri, 20 Nov 2020 15:27:06 +0000 (15:27 +0000)] 
aarch64: Fix missing BTI protection from dependencies [BZ #26926]

The _dl_open_check and _rtld_main_check hooks are not called on the
dependencies of a loaded module, so BTI protection was missed on
every module other than the main executable and directly dlopened
libraries.

The fix just iterates over dependencies to enable BTI.

Fixes bug 26926.

(cherry picked from commit 72739c79f61989a76b7dd719f34fcfb7b8eadde9)

4 years agox86: Check IFUNC definition in unrelocated executable [BZ #20019]
H.J. Lu [Mon, 28 Dec 2020 13:28:49 +0000 (05:28 -0800)] 
x86: Check IFUNC definition in unrelocated executable [BZ #20019]

Calling an IFUNC function defined in unrelocated executable also leads to
segfault.  Issue a fatal error message when calling IFUNC function defined
in the unrelocated executable from a shared library.

On x86, ifuncmain6pie failed with:

[hjl@gnu-cfl-2 build-i686-linux]$ ./elf/ifuncmain6pie --direct
./elf/ifuncmain6pie: IFUNC symbol 'foo' referenced in '/export/build/gnu/tools-build/glibc-32bit/build-i686-linux/elf/ifuncmod6.so' is defined in the executable and creates an unsatisfiable circular dependency.
[hjl@gnu-cfl-2 build-i686-linux]$ readelf -rW elf/ifuncmod6.so | grep foo
00003ff4  00000706 R_386_GLOB_DAT         0000400c   foo_ptr
00003ff8  00000406 R_386_GLOB_DAT         00000000   foo
0000400c  00000401 R_386_32               00000000   foo
[hjl@gnu-cfl-2 build-i686-linux]$

Remove non-JUMP_SLOT relocations against foo in ifuncmod6.so, which
trigger the circular IFUNC dependency, and build ifuncmain6pie with
-Wl,-z,lazy.

(cherry picked from commits 6ea5b57afa5cdc9ce367d2b69a2cebfb273e4617
 and 7137d682ebfcb6db5dfc5f39724718699922f06c)

4 years agox86: Set header.feature_1 in TCB for always-on CET [BZ #27177]
H.J. Lu [Wed, 13 Jan 2021 03:00:13 +0000 (19:00 -0800)] 
x86: Set header.feature_1 in TCB for always-on CET [BZ #27177]

Update dl_cet_check() to set header.feature_1 in TCB when both IBT and
SHSTK are always on.

(cherry picked from commit 2ef23b520597f4ea1790a669b83e608f24f4cf12)

4 years agoUpdate for [BZ #27130] fix
H.J. Lu [Tue, 12 Jan 2021 13:15:49 +0000 (05:15 -0800)] 
Update for [BZ #27130] fix

4 years agox86-64: Avoid rep movsb with short distance [BZ #27130]
H.J. Lu [Sat, 25 Jan 2020 22:19:40 +0000 (14:19 -0800)] 
x86-64: Avoid rep movsb with short distance [BZ #27130]

When copying with "rep movsb", if the distance between source and
destination is N*4GB + [1..63] with N >= 0, performance may be very
slow.  This patch updates memmove-vec-unaligned-erms.S for AVX and
AVX512 versions with the distance in RCX:

cmpl $63, %ecx
// Don't use "rep movsb" if ECX <= 63
jbe L(Don't use rep movsb")
Use "rep movsb"

Benchtests data with bench-memcpy, bench-memcpy-large, bench-memcpy-random
and bench-memcpy-walk on Skylake, Ice Lake and Tiger Lake show that its
performance impact is within noise range as "rep movsb" is only used for
data size >= 4KB.

(cherry picked from commit 3ec5d83d2a237d39e7fd6ef7a0bc8ac4c171a4a5)

4 years agoFix buffer overrun in EUC-KR conversion module (bz #24973)
Andreas Schwab [Wed, 6 Jan 2021 05:33:44 +0000 (11:03 +0530)] 
Fix buffer overrun in EUC-KR conversion module (bz #24973)

The byte 0xfe as input to the EUC-KR conversion denotes a user-defined
area and is not allowed.  The from_euc_kr function used to skip two bytes
when told to skip over the unknown designation, potentially running over
the buffer end.

(cherry picked from commit ee7a3144c9922808181009b7b3e50e852fb4999b)

4 years agotests-mcheck: New variable to run tests with MALLOC_CHECK_=3
Siddhesh Poyarekar [Thu, 24 Dec 2020 05:50:15 +0000 (11:20 +0530)] 
tests-mcheck: New variable to run tests with MALLOC_CHECK_=3

This new variable allows various subsystems in glibc to run all or
some of their tests with MALLOC_CHECK_=3.  This patch adds
infrastructure support for this variable as well as an implementation
in malloc/Makefile to allow running some of the tests with
MALLOC_CHECK_=3.

At present some tests in malloc/ have been excluded from the mcheck
tests either because they're specifically testing MALLOC_CHECK_ or
they are failing in master even without the Memory Tagging patches
that prompted this work.  Some tests were reviewed and found to need
specific error points that MALLOC_CHECK_ defeats by terminating early
but a thorough review of all tests is needed to bring them into mcheck
coverage.

Backported from 4f969166ce4ab535fa798dcbaa5de4c4e05773ec.

4 years agoiconv: Accept redundant shift sequences in IBM1364 [BZ #26224]
Arjun Shankar [Wed, 4 Nov 2020 11:19:38 +0000 (12:19 +0100)] 
iconv: Accept redundant shift sequences in IBM1364 [BZ #26224]

The IBM1364, IBM1371, IBM1388, IBM1390 and IBM1399 character sets
share converter logic (iconvdata/ibm1364.c) which would reject
redundant shift sequences when processing input in these character
sets.  This led to a hang in the iconv program (CVE-2020-27618).

This commit adjusts the converter to ignore redundant shift sequences
and adds test cases for iconv_prog hangs that would be triggered upon
their rejection.  This brings the implementation in line with other
converters that also ignore redundant shift sequences (e.g. IBM930
etc., fixed in commit 692de4b3960d).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 9a99c682144bdbd40792ebf822fe9264e0376fb5)

4 years agosh: Add sh4 fpu Implies folder
Adhemerval Zanella [Wed, 25 Nov 2020 18:00:44 +0000 (15:00 -0300)] 
sh: Add sh4 fpu Implies folder

The commit 605f38177db (sh: Split BE/LE abilist) did not take in
consideration the SH4 fpu support.

Checked with a build for sh4-linux-gnu and manually checked that
the implementations at sysdeps/sh/sh4/fpu/ are selected.

John Paul Adrian Glaubitz also confirmed it fixes the build issues
he encontered.

(cherry-picked from 9ff2674ef82eccd5ae5dfa6bb733c0e3613764c6)

4 years agostruct _Unwind_Exception alignment should not depend on compiler flags
Florian Weimer [Wed, 11 Nov 2020 10:59:11 +0000 (11:59 +0100)] 
struct _Unwind_Exception alignment should not depend on compiler flags

__attribute__((__aligned__)) selects an alignment that depends on
the micro-architecture selected by GCC flags.  Enabling vector
extensions may increase the allignment.  This is a problem when
building glibc as a collection of ELF multilibs with different
GCC flags because ld.so and libc.so/libpthread.so/&c may end up
with a different layout of struct pthread because of the
changing offset of its struct _Unwind_Exception field.

Tested-By: Matheus Castanho <msc@linux.ibm.com>
(cherry picked from commit 30af7c7fa13e17d82c3f1f91536384715844f432)

4 years agoresolv: Serialize processing in resolv/tst-resolv-txnid-collision
Florian Weimer [Thu, 15 Oct 2020 10:33:13 +0000 (12:33 +0200)] 
resolv: Serialize processing in resolv/tst-resolv-txnid-collision

When switching name servers, response processing by two server
threads clobbers the global test state.  (There is still some
risk that this test is negatively impact by packet drops and
packet reordering, but this applies to many of the resolver tests
and is difficult to avoid.)

Fixes commit f1f00c072138af90ae6da180f260111f09afe7a3 ("resolv:
Handle transaction ID collisions in parallel queries (bug 26600)").

(cherry picked from commit b8b53b338f6da91e86d115a39da860cefac736ad)

4 years agoresolv: Handle transaction ID collisions in parallel queries (bug 26600)
Florian Weimer [Wed, 14 Oct 2020 08:54:39 +0000 (10:54 +0200)] 
resolv: Handle transaction ID collisions in parallel queries (bug 26600)

If the transaction IDs are equal, the old check attributed both
responses to the first query, not recognizing the second response.
This fixes bug 26600.

(cherry picked from commit f1f00c072138af90ae6da180f260111f09afe7a3)

4 years agosupport: Provide a way to clear the RA bit in DNS server responses
Florian Weimer [Wed, 14 Oct 2020 08:54:39 +0000 (10:54 +0200)] 
support: Provide a way to clear the RA bit in DNS server responses

(cherry picked from commit 08443b19965f48862b02c2fd7b33a39d66daf2ff)

4 years agosupport: Provide a way to reorder responses within the DNS test server
Florian Weimer [Wed, 14 Oct 2020 08:54:39 +0000 (10:54 +0200)] 
support: Provide a way to reorder responses within the DNS test server

(cherry picked from commit 873e239a4c3d8ec235c27439c1bdc5bbf8aa1818)

4 years agoRemove __warndecl
Siddhesh Poyarekar [Thu, 5 Nov 2020 04:50:32 +0000 (10:20 +0530)] 
Remove __warndecl

The macro is not used anymore, so remove it and warning-nop.c.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry-picked from 34aec973e15a81926198f4b71ff99081dff87a92)

4 years agoRemove __warn_memset_zero_len [BZ #25399]
Siddhesh Poyarekar [Tue, 3 Nov 2020 09:39:28 +0000 (15:09 +0530)] 
Remove __warn_memset_zero_len [BZ #25399]

Non-gcc compilers (clang and possibly other compilers that do not
masquerade as gcc 5.0 or later) are unable to use
__warn_memset_zero_len since the symbol is no longer available on
glibc built with gcc 5.0 or later.  While it was likely an oversight
that caused this omission, the fact that it wasn't noticed until
recently (when clang closed the gap on _FORTIFY_SUPPORT) that the
symbol was missing.

Given that both gcc and clang are capable of doing this check in the
compiler, drop all remaining signs of __warn_memset_zero_len from
glibc so that no more objects are built with this symbol in future.

(cherry-picked from dc274b141666766b8ef70992d887e3c0c5e41bed)

4 years agoaarch64: Add unwind information to _start (bug 26853)
Florian Weimer [Mon, 9 Nov 2020 10:31:04 +0000 (11:31 +0100)] 
aarch64: Add unwind information to _start (bug 26853)

This adds CFI directives which communicate that the stack ends
with this function.

Fixes bug 26853.

(cherry picked from commit 5edf3d9fd6efe06fda37b2a460e60690a90457a4)

4 years agoaarch64: Fix DT_AARCH64_VARIANT_PCS handling [BZ #26798]
Szabolcs Nagy [Thu, 22 Oct 2020 16:55:01 +0000 (17:55 +0100)] 
aarch64: Fix DT_AARCH64_VARIANT_PCS handling [BZ #26798]

The variant PCS support was ineffective because in the common case
linkmap->l_mach.plt == 0 but then the symbol table flags were ignored
and normal lazy binding was used instead of resolving the relocs early.
(This was a misunderstanding about how GOT[1] is setup by the linker.)

In practice this mainly affects SVE calls when the vector length is
more than 128 bits, then the top bits of the argument registers get
clobbered during lazy binding.

Fixes bug 26798.

(cherry picked from commit 558251bd8785760ad40fcbfeaaee5d27fa5b0fe4)

4 years agox86: Optimizing memcpy for AMD Zen architecture.
Sajan Karumanchi [Wed, 28 Oct 2020 07:35:33 +0000 (13:05 +0530)] 
x86: Optimizing memcpy for AMD Zen architecture.

Modifying the shareable cache '__x86_shared_cache_size', which is a
factor in computing the non-temporal threshold parameter
'__x86_shared_non_temporal_threshold' to optimize memcpy for AMD Zen
architectures.
In the existing implementation, the shareable cache is computed as 'L3
per thread, L2 per core'. Recomputing this shareable cache as 'L3 per
CCX(Core-Complex)' has brought in performance gains.
As per the large bench variant results, this patch also addresses the
regression problem on AMD Zen architectures.

Backport of commit 59803e81f96b479c17f583b31eac44b57591a1bf upstream,
with the fix from cb3a749a22a55645dc6a52659eea765300623f98 ("x86:
Restore processing of cache size tunables in init_cacheinfo") applied.

Reviewed-by: Premachandra Mallappa <premachandra.mallappa@amd.com>
Co-Authored-by: Florian Weimer <fweimer@redhat.com>
4 years agoReversing calculation of __x86_shared_non_temporal_threshold
Patrick McGehearty [Mon, 28 Sep 2020 20:11:28 +0000 (20:11 +0000)] 
Reversing calculation of __x86_shared_non_temporal_threshold

The __x86_shared_non_temporal_threshold determines when memcpy on x86
uses non_temporal stores to avoid pushing other data out of the last
level cache.

This patch proposes to revert the calculation change made by H.J. Lu's
patch of June 2, 2017.

H.J. Lu's patch selected a threshold suitable for a single thread
getting maximum performance. It was tuned using the single threaded
large memcpy micro benchmark on an 8 core processor. The last change
changes the threshold from using 3/4 of one thread's share of the
cache to using 3/4 of the entire cache of a multi-threaded system
before switching to non-temporal stores. Multi-threaded systems with
more than a few threads are server-class and typically have many
active threads. If one thread consumes 3/4 of the available cache for
all threads, it will cause other active threads to have data removed
from the cache. Two examples show the range of the effect. John
McCalpin's widely parallel Stream benchmark, which runs in parallel
and fetches data sequentially, saw a 20% slowdown with this patch on
an internal system test of 128 threads. This regression was discovered
when comparing OL8 performance to OL7.  An example that compares
normal stores to non-temporal stores may be found at
https://vgatherps.github.io/2018-09-02-nontemporal/.  A simple test
shows performance loss of 400 to 500% due to a failure to use
nontemporal stores. These performance losses are most likely to occur
when the system load is heaviest and good performance is critical.

The tunable x86_non_temporal_threshold can be used to override the
default for the knowledgable user who really wants maximum cache
allocation to a single thread in a multi-threaded system.
The manual entry for the tunable has been expanded to provide
more information about its purpose.

modified: sysdeps/x86/cacheinfo.c
modified: manual/tunables.texi

(cherry picked from commit d3c57027470b78dba79c6d931e4e409b1fecfc80)

4 years agosysvipc: Fix IPC_INFO and SHM_INFO handling [BZ #26636]
Adhemerval Zanella [Tue, 29 Sep 2020 17:51:36 +0000 (14:51 -0300)] 
sysvipc: Fix IPC_INFO and SHM_INFO handling [BZ #26636]

Both commands are Linux extensions where the third argument is either
a 'struct shminfo' (IPC_INFO) or a 'struct shm_info' (SHM_INFO) instead
of 'struct shmid_ds'.  And their information does not contain any time
related fields, so there is no need to extra conversion for __IPC_TIME64.

The regression testcase checks for Linux specifix SysV ipc message
control extension.  For SHM_INFO it tries to match the values against the
tunable /proc values and for MSG_STAT/MSG_STAT_ANY it check if the create\
shared memory is within the global list returned by the kernel.

Checked on x86_64-linux-gnu and on i686-linux-gnu (Linux v5.4 and on
Linux v4.15).

(cherry picked from commit  a49d7fd4f764e97ccaf922e433046590ae52fce9)

4 years agosysvipc: Fix IPC_INFO and MSG_INFO handling [BZ #26639]
Adhemerval Zanella [Tue, 29 Sep 2020 17:39:56 +0000 (14:39 -0300)] 
sysvipc: Fix IPC_INFO and MSG_INFO handling [BZ #26639]

Both commands are Linux extensions where the third argument is a
'struct msginfo' instead of 'struct msqid_ds' and its information
does not contain any time related fields (so there is no need to
extra conversion for __IPC_TIME64.

The regression testcase checks for Linux specifix SysV ipc message
control extension.  For IPC_INFO/MSG_INFO it tries to match the values
against the tunable /proc values and for MSG_STAT/MSG_STAT_ANY it
check if the create message queue is within the global list returned
by the kernel.

Checked on x86_64-linux-gnu and on i686-linux-gnu (Linux v5.4 and on
Linux v4.15).

(cherry picked from commit 20a00dbefca5695cccaa44846a482db8ccdd85ab)

4 years agosysvipc: Fix SEM_STAT_ANY kernel argument pass [BZ #26637]
Dmitry V. Levin [Tue, 29 Sep 2020 17:10:20 +0000 (14:10 -0300)] 
sysvipc: Fix SEM_STAT_ANY kernel argument pass [BZ #26637]

Handle SEM_STAT_ANY the same way as SEM_STAT so that the buffer argument
of SEM_STAT_ANY is properly passed to the kernel and back.

The regression testcase checks for Linux specifix SysV ipc message
control extension.  For IPC_INFO/SEM_INFO it tries to match the values
against the tunable /proc values and for SEM_STAT/SEM_STAT_ANY it
check if the create message queue is within the global list returned
by the kernel.

Checked on x86_64-linux-gnu and on i686-linux-gnu (Linux v5.4 and on
Linux v4.15).

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 574500a108be1d2a6a0dc97a075c9e0a98371aba)

4 years agoAArch64: Use __memcpy_simd on Neoverse N2/V1
Wilco Dijkstra [Wed, 14 Oct 2020 12:56:21 +0000 (13:56 +0100)] 
AArch64: Use __memcpy_simd on Neoverse N2/V1

Add CPU detection of Neoverse N2 and Neoverse V1, and select __memcpy_simd as
the memcpy/memmove ifunc.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit e11ed9d2b4558eeacff81557dc9557001af42a6b)

4 years agoAArch64: Improve backwards memmove performance
Wilco Dijkstra [Fri, 28 Aug 2020 16:51:40 +0000 (17:51 +0100)] 
AArch64: Improve backwards memmove performance

On some microarchitectures performance of the backwards memmove improves if
the stores use STR with decreasing addresses.  So change the memmove loop
in memcpy_advsimd.S to use 2x STR rather than STP.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit bd394d131c10c9ec22c6424197b79410042eed99)

4 years agoSet version.h RELEASE to "stable" (Bug 26700)
Carlos O'Donell [Fri, 2 Oct 2020 13:23:35 +0000 (09:23 -0400)] 
Set version.h RELEASE to "stable" (Bug 26700)

The RELEASE macro was accidentaly set to "release" instead of
the expected "stable" by the release manager.  This is a mistake
that leads to the build using "-g -O1" instead of "-g -O2" if
configure was executed with "CFLAGS=" (CFLAGS set but empty).

4 years agostring: Fix strerrorname_np return value [BZ #26555]
Adhemerval Zanella [Mon, 31 Aug 2020 14:53:51 +0000 (11:53 -0300)] 
string: Fix strerrorname_np return value [BZ #26555]

It returns the string of the error constant, not its description (as
strerrordesc_np).  To handle the Hurd error mapping, the ERR_MAP was
removed from errlist.h to errlist.c.

Also, the testcase test-strerr (added on 325081b9eb2) was not added
on the check build neither it builds correctly.  This patch also
changed it to decouple from errlist.h, the expected return values
are added explicitly for both both strerrorname_np and strerrordesc_np
directly.

Checked on x86_64-linux-gnu and i686-linux-gnu.  I also run a make
check for i686-gnu.

(cherry picked from commit cef95fdc2e4002ee6357d8d40ef73c8d875720e3)

4 years agointl: Handle translation output codesets with suffixes [BZ #26383]
Arjun Shankar [Fri, 25 Sep 2020 12:47:06 +0000 (14:47 +0200)] 
intl: Handle translation output codesets with suffixes [BZ #26383]

Commit 91927b7c7643 (Rewrite iconv option parsing [BZ #19519]) did not
handle cases where the output codeset for translations (via the `gettext'
family of functions) might have a caller specified encoding suffix such as
TRANSLIT or IGNORE.  This led to a regression where translations did not
work when the codeset had a suffix.

This commit fixes the above issue by parsing any suffixes passed to
__dcigettext and adds two new test-cases to intl/tst-codeset.c to
verify correct behaviour.  The iconv-internal function __gconv_create_spec
and the static iconv-internal function gconv_destroy_spec are now visible
internally within glibc and used in intl/dcigettext.c.

(cherry picked from commit 7d4ec75e111291851620c6aa2c4460647b7fd50d)

4 years agoNEWS: Update for [BZ #26534] fix
H.J. Lu [Wed, 26 Aug 2020 02:26:50 +0000 (04:26 +0200)] 
NEWS: Update for [BZ #26534] fix

4 years agox86-64: Fix FMA4 detection in ifunc [BZ #26534]
Ondřej Hošek [Wed, 26 Aug 2020 02:26:50 +0000 (04:26 +0200)] 
x86-64: Fix FMA4 detection in ifunc [BZ #26534]

A typo in commit 107e6a3c2212ba7a3a4ec7cae8d82d73f7c95d0b causes the
FMA4 code path to be taken on systems that support FMA, even if they do
not support FMA4. Fix this to detect FMA4.

(cherry picked from commit 23af890b3f04e80da783ba64e6b6d94822e01d54)

5 years agoPrepare for glibc 2.32 release. glibc-2.32
Carlos O'Donell [Wed, 5 Aug 2020 02:17:00 +0000 (22:17 -0400)] 
Prepare for glibc 2.32 release.

Update version.h, features.h, and ChangeLog.old/ChangeLog.21.

5 years agoRegenerate configure scripts.
Carlos O'Donell [Wed, 5 Aug 2020 01:36:19 +0000 (21:36 -0400)] 
Regenerate configure scripts.

5 years agoUpdate NEWS with bugs.
Carlos O'Donell [Wed, 5 Aug 2020 00:39:09 +0000 (20:39 -0400)] 
Update NEWS with bugs.

5 years agoUpdate translations.
Carlos O'Donell [Wed, 5 Aug 2020 00:31:51 +0000 (20:31 -0400)] 
Update translations.

Incorporate updates from translationproject.org.

5 years agoDon't mix linker error messages into edited scripts
Alan Modra [Wed, 29 Jul 2020 06:58:57 +0000 (16:28 +0930)] 
Don't mix linker error messages into edited scripts

* Makerules (shlib.lds): Discard linker warning output.
(format.lds): Likewise.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agobenchtests/README update.
Paul Zimmermann [Tue, 4 Aug 2020 11:27:39 +0000 (13:27 +0200)] 
benchtests/README update.

Improve documentation of the 'name' directive and the 'workload' mechanism.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoRISC-V: Update lp64d libm-test-ulps according to HiFive Unleashed
Maciej W. Rozycki [Tue, 4 Aug 2020 12:00:17 +0000 (13:00 +0100)] 
RISC-V: Update lp64d libm-test-ulps according to HiFive Unleashed

Produced with HiFive Unleashed hardware using Linux 5.8-rc5 exactly and
GCC 10.0.1 20200426.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoaarch64: update NEWS about branch protection
Szabolcs Nagy [Wed, 29 Jul 2020 07:27:27 +0000 (08:27 +0100)] 
aarch64: update NEWS about branch protection

After some discussions it seems the original news was not clear
and that it is valid to manually pass the branch protection flags
iff GCC target libs are built with them too. The main difference
between manually passing the flags and using the configure
option is that the latter also makes branch protection the
default in GCC which may not be desirable in some cases.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoAdd NEWS entry for CVE-2016-10228 (bug 19519)
Aurelien Jarno [Thu, 30 Jul 2020 08:07:33 +0000 (10:07 +0200)] 
Add NEWS entry for CVE-2016-10228 (bug 19519)

5 years agopowerpc: Fix incorrect cache line size load in memset (bug 26332)
Florian Weimer [Mon, 3 Aug 2020 16:07:19 +0000 (18:07 +0200)] 
powerpc: Fix incorrect cache line size load in memset (bug 26332)

__GLRO loaded the word after the requested variable on big-endian
PowerPC, where LOWORD is 4.  This can cause the memset implement
go wrong because the masking with the cache line size produces
wrong results, particularly if the loaded value happens to be 1.

The __GLRO macro is not used in any place where loading the lower
32-bit word of a 64-bit value is desired, so the +4 offset is always
wrong.

Fixes commit 18363b4f010da9ba459b13310b113ac0647c2fcc
("powerpc: Move cache line size to rtld_global_ro") and bug 26332.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoUpdate Nios II libm-test-ulps file.
Chung-Lin Tang [Mon, 3 Aug 2020 08:42:48 +0000 (01:42 -0700)] 
Update Nios II libm-test-ulps file.

5 years agoMove NEWS entry for CVE-2020-1751 to the 2.31 section
Florian Weimer [Fri, 31 Jul 2020 10:07:06 +0000 (12:07 +0200)] 
Move NEWS entry for CVE-2020-1751 to the 2.31 section

It was fixed in commit d93769405996dfc11d216ddbe415946617b5a494
("Fix array overflow in backtrace on PowerPC (bug 25423)"), which
went into glibc 2.31.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoNEWS: Deprecate weak libpthread symbols for single-threaded checks
Florian Weimer [Fri, 24 Jul 2020 14:50:38 +0000 (16:50 +0200)] 
NEWS: Deprecate weak libpthread symbols for single-threaded checks

Recommend the new __libc_single_thread variable instead.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoNEWS: Deprecate nss_hesiod
Florian Weimer [Fri, 24 Jul 2020 14:46:23 +0000 (16:46 +0200)] 
NEWS: Deprecate nss_hesiod

Storing user databases in DNS, without client-side DNSSEC validation,
is problematic from a security point of view.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agonptl: Zero-extend arguments to SETXID syscalls [BZ #26248]
H.J. Lu [Thu, 16 Jul 2020 10:37:10 +0000 (03:37 -0700)] 
nptl: Zero-extend arguments to SETXID syscalls [BZ #26248]

nptl has

/* Opcodes and data types for communication with the signal handler to
   change user/group IDs.  */
struct xid_command
{
  int syscall_no;
  long int id[3];
  volatile int cntr;
  volatile int error;
};

 /* This must be last, otherwise the current thread might not have
     permissions to send SIGSETXID syscall to the other threads.  */
  result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, 3,
                                 cmdp->id[0], cmdp->id[1], cmdp->id[2]);

But the second argument of setgroups syscal is a pointer:

       int setgroups (size_t size, const gid_t *list);

But on x32, pointers passed to syscall must have pointer type so that
they will be zero-extended.  The kernel XID arguments are unsigned and
do not require sign extension.  Change xid_command to

struct xid_command
{
  int syscall_no;
  unsigned long int id[3];
  volatile int cntr;
  volatile int error;
};

so that all arguments are zero-extended.  A testcase is added for x32 and
setgroups returned with EFAULT when running as root without the fix.

5 years agoUse binutils 2.35 branch in build-many-glibcs.py.
Joseph Myers [Mon, 27 Jul 2020 14:55:10 +0000 (14:55 +0000)] 
Use binutils 2.35 branch in build-many-glibcs.py.

This patch makes build-many-glibcs.py use binutils 2.35 branch.

Tested with build-many-glibcs.py (compilers and glibcs builds).

5 years agoaarch64: Use future HWCAP2_MTE in ifunc resolver
Szabolcs Nagy [Fri, 24 Jul 2020 11:37:23 +0000 (12:37 +0100)] 
aarch64: Use future HWCAP2_MTE in ifunc resolver

Make glibc MTE-safe on systems where MTE is available. This allows
using heap tagging with an LD_PRELOADed malloc implementation that
enables MTE. We don't document this as guaranteed contract yet, so
glibc may not be MTE safe when HWCAP2_MTE is set (older glibcs
certainly aren't). This is mainly for testing and debugging.

The HWCAP flag is not exposed in public headers until Linux adds it
to its uapi. The HWCAP value reservation will be in Linux 5.9.

5 years agoUpdate x86-64 libm-test-ulps
Andreas K. Hüttel [Sat, 25 Jul 2020 09:36:00 +0000 (12:36 +0300)] 
Update x86-64 libm-test-ulps

x86_64 Intel(R) Core(TM) i5-8265U
gcc (Gentoo 10.1.0-r2 p3) 10.1.0
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoaarch64: Respect p_flags when protecting code with PROT_BTI
Szabolcs Nagy [Mon, 13 Jul 2020 10:28:18 +0000 (11:28 +0100)] 
aarch64: Respect p_flags when protecting code with PROT_BTI

Use PROT_READ and PROT_WRITE according to the load segment p_flags
when adding PROT_BTI.

This is before processing relocations which may drop PROT_BTI in
case of textrels.  Executable stacks are not protected via PROT_BTI
either.  PROT_BTI is hardening in case memory corruption happened,
it's value is reduced if there is writable and executable memory
available so missing it on such memory is fine, but we should
respect the p_flags and should not drop PROT_WRITE.

5 years agoDisable warnings due to deprecated libselinux symbols used by nss and nscd
Arjun Shankar [Thu, 23 Jul 2020 10:20:38 +0000 (12:20 +0200)] 
Disable warnings due to deprecated libselinux symbols used by nss and nscd

The SELinux API deprecated several symbols in its 3.1 release, including
security_context_t, matchpathcon, avc_init, and sidput, which are used in
makedb and nscd.  While the usage of these should eventually be replaced by
newer interfaces, this commit disables GCC warnings due to the use of the
above symbols.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
5 years agoRegenerate INSTALL for ARC port updates.
Carlos O'Donell [Thu, 23 Jul 2020 03:32:07 +0000 (23:32 -0400)] 
Regenerate INSTALL for ARC port updates.

5 years agoUpdate libc.pot for 2.32 release.
Carlos O'Donell [Thu, 23 Jul 2020 03:28:05 +0000 (23:28 -0400)] 
Update libc.pot for 2.32 release.

5 years agopowerpc: Fix POWER10 selection
Tulio Magno Quites Machado Filho [Tue, 21 Jul 2020 21:01:39 +0000 (18:01 -0300)] 
powerpc: Fix POWER10 selection

Add a line that was missing from a previous commit.
Without increasing str, the null-byte is not validated, and
_dl_string_platform returns -1.

Fixes: d2ba3677da7a ("powerpc: Add support for POWER10")
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agopowerpc64le: guarantee a .gnu.attributes section [BZ #26220]
Paul E. Murphy [Wed, 8 Jul 2020 21:49:34 +0000 (16:49 -0500)] 
powerpc64le: guarantee a .gnu.attributes section [BZ #26220]

Upstream GCC 11 development is now building the ibm128 runtime
support (in libgcc) without a .gnu.attributes section on ppc64le.
Ensure we have one to replace by building one ibm128 file in
libc and libm with attributes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
5 years agolibio: Remove __libc_readline_unlocked
Florian Weimer [Wed, 15 Jul 2020 10:37:01 +0000 (12:37 +0200)] 
libio: Remove __libc_readline_unlocked

__nss_readline supersedes it.  This reverts part of commit
3f5e3f5d066dcffb80af48ae2cf35a01a85a8f10 ("libio: Implement
internal function __libc_readline_unlocked").  The internal
aliases __fseeko64 and __ftello64 are preserved because
they are needed by __nss_readline as well.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoshadow: Implement fgetspent_r using __nss_fgetent_r
Florian Weimer [Thu, 16 Jul 2020 15:34:43 +0000 (17:34 +0200)] 
shadow: Implement fgetspent_r using __nss_fgetent_r

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agopwd: Implement fgetpwent_r using __nss_fgetent_r
Florian Weimer [Thu, 16 Jul 2020 15:34:19 +0000 (17:34 +0200)] 
pwd: Implement fgetpwent_r using __nss_fgetent_r

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agogshadow: Implement fgetsgent_r using __nss_fgetent_r (bug 20338)
Florian Weimer [Thu, 16 Jul 2020 15:31:20 +0000 (17:31 +0200)] 
gshadow: Implement fgetsgent_r using __nss_fgetent_r (bug 20338)

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agogrp: Implement fgetgrent_r using __nss_fgetent_r
Florian Weimer [Thu, 16 Jul 2020 15:28:28 +0000 (17:28 +0200)] 
grp: Implement fgetgrent_r using __nss_fgetent_r

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agonss: Add __nss_fgetent_r
Florian Weimer [Wed, 15 Jul 2020 11:41:31 +0000 (13:41 +0200)] 
nss: Add __nss_fgetent_r

And helper functions __nss_readline, __nss_readline_seek,
 __nss_parse_line_result.

This consolidates common code for handling overlong lines and
parse files.  Use the new functionality in internal_getent
in nss/nss_files/files-XXX.c.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agolibio: Add fseterr_unlocked for internal use
Florian Weimer [Thu, 16 Jul 2020 15:00:46 +0000 (17:00 +0200)] 
libio: Add fseterr_unlocked for internal use

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agonss_files: Use generic result pointer in parse_line
Florian Weimer [Thu, 16 Jul 2020 14:55:45 +0000 (16:55 +0200)] 
nss_files: Use generic result pointer in parse_line

As a result, all parse_line functions have the same prototype, except
for that producing struct hostent.  This change is ABI-compatible, so
it does not alter the internal GLIBC_PRIVATE ABI (otherwise we should
probably have renamed the exported functions).

A future change will use this to implement a generict fget*ent_r
function.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agonss_files: Consolidate line parse declarations in <nss_files.h>
Florian Weimer [Thu, 16 Jul 2020 14:40:44 +0000 (16:40 +0200)] 
nss_files: Consolidate line parse declarations in <nss_files.h>

These functions should eventually have the same type, so it makes
sense to declare them together.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agonss_compat: Do not use mmap to read database files (bug 26258)
Florian Weimer [Thu, 16 Jul 2020 14:21:28 +0000 (16:21 +0200)] 
nss_compat: Do not use mmap to read database files (bug 26258)

This avoids crashes in case the files are truncated for some reason.
For typically file sizes, it is also going to be slightly faster.
Using __nss_files_fopen instead mirrors what nss_files does.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agonss_files: Consolidate file opening in __nss_files_fopen
Florian Weimer [Thu, 16 Jul 2020 14:12:46 +0000 (16:12 +0200)] 
nss_files: Consolidate file opening in __nss_files_fopen

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoUpdate powerpc-nofpu libm-test-ulps.
Joseph Myers [Mon, 20 Jul 2020 20:16:25 +0000 (20:16 +0000)] 
Update powerpc-nofpu libm-test-ulps.

5 years agoUse MPFR 4.1.0 in build-many-glibcs.py.
Joseph Myers [Mon, 20 Jul 2020 18:16:50 +0000 (18:16 +0000)] 
Use MPFR 4.1.0 in build-many-glibcs.py.

This patch makes build-many-glibcs.py use the new MPFR 4.1.0 release.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

5 years agoelf: Change TLS static surplus default back to 1664
Florian Weimer [Mon, 20 Jul 2020 11:30:45 +0000 (13:30 +0200)] 
elf: Change TLS static surplus default back to 1664

Make the computation in elf/dl-tls.c more transparent, and add
an explicit test for the historic value.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agohurd: Fix longjmp check for sigstate
Samuel Thibault [Sat, 18 Jul 2020 13:12:56 +0000 (15:12 +0200)] 
hurd: Fix longjmp check for sigstate

* sysdeps/mach/hurd/i386/____longjmp_chk.S,__longjmp.S: Properly check for
sigstate being NULL.

5 years agohurd: Fix longjmp early in initialization
Samuel Thibault [Sat, 18 Jul 2020 13:08:03 +0000 (15:08 +0200)] 
hurd: Fix longjmp early in initialization

When e.g. an LD_PRELOAD fails, _dl_signal_exception/error longjmps, but TLS
is not initialized yet, let along signal state.  We thus mustn't look at
them within __longjmp.

* sysdeps/mach/hurd/i386/____longjmp_chk.S,__longjmp.S: Check for
initialized value of %gs, and that sigstate is non-NULL.

5 years agomanual: New signal and errno string functions are AS-safe
Florian Weimer [Fri, 17 Jul 2020 15:13:59 +0000 (17:13 +0200)] 
manual: New signal and errno string functions are AS-safe

The annotations for sigabbrev_np, sigdescr_np, strerrordesc_np,
strerrorname_np are not preliminary.  These functions were
added precisely because they are AS-safe.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoAArch64: Improve strlen_asimd performance (bug 25824)
Wilco Dijkstra [Fri, 17 Jul 2020 13:09:36 +0000 (14:09 +0100)] 
AArch64: Improve strlen_asimd performance (bug 25824)

Optimize strlen using a mix of scalar and SIMD code.  On modern micro
architectures large strings are 2.6 times faster than existing
strlen_asimd and 35% faster than the new MTE version of strlen.

On a random strlen benchmark using small sizes the speedup is 7% vs
strlen_asimd and 40% vs the MTE strlen.  This fixes the main strlen
regressions on Cortex-A53 and other cores with a simple Neon unit.

Rename __strlen_generic to __strlen_mte, and select strlen_asimd when
MTE is not enabled (this is waiting on support for a HWCAP_MTE bit).

This fixes big-endian bug 25824. Passes GLIBC regression tests.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
5 years agoMove <rpc/netdb.h> from sunrpc to inet
Florian Weimer [Fri, 17 Jul 2020 13:19:35 +0000 (15:19 +0200)] 
Move <rpc/netdb.h> from sunrpc to inet

Restore <rpc/netdb.h> as an installed header. Delete the dummy header
resolv/rpc/netdb.h because inet is not an optional glibc component
(so its <rpc/netdb.h> is always available).

Fixes commit acb527929d0c2b3bb0798472c42ddb3203729708 ("Move
non-deprecated RPC-related functions from sunrpc to inet") in
combination with commit 5500cdba4018ddbda7909bc7f4f9718610b43cf0
("Remove --enable-obsolete-rpc configure flag").

5 years agoen_US: Minimize changes to date_fmt (Bug 25923)
Carlos O'Donell [Wed, 8 Jul 2020 19:58:06 +0000 (15:58 -0400)] 
en_US: Minimize changes to date_fmt (Bug 25923)

In 2000 when date_fmt was originally added as an extension the
en_US locale did not have a date_fmt specifier and so used the
default which resulted in the abbreviated month name coming
before the day of the month (as expected in the US and other
locales).  In commit 7395f3a0efad9fc51bb54fa383ef6524702e0c49 the
date_fmt was added to en_US with a 12H time to better align with
US user expectations.  Unfortunately the abbreviated month name
and day were inverted during that transition, and that was seen
as a regression and reported against Fedora 32:
https://bugzilla.redhat.com/show_bug.cgi?id=1830623

The progression of date_fmt looks like this:
"%a %b %e %H:%M:%S %Z %Y"    <- Originally (2000)
"%a %d %b %Y %I:%M:%S %p %Z" <- glibc 2.29 (2019)
"%a %b %e %r %Z %Y"          <- glibc 2.32 (2020) [this commit]

Note: "%r" is "%I:%M:%S %p" in en_US and so shorter to write.

Likewise the year is in the wrong place in commit
7395f3a0efad9fc51bb54fa383ef6524702e0c49 and this is corrected in
this patch.

For reference d_t_fmt:
"%a %d %b %Y %r %Z"          <- d_t_fmt    (1997)

Yes, d_t_fmt and date_fmt are *not* the same, this is just the
history of this locale. This commit does not change d_t_fmt to
better align with date_fmt. No users have requested we change
d_t_fmt or given any justification for such a change.

The only goals of this change are to place the abbreviated month
name before the day of the month as it has been printed since
2000, and place the year at the end. This minimizes the change
from commit 7395f3a0efad9fc51bb54fa383ef6524702e0c49 and makes
good on changing only from 24H clock to 12H clock.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
5 years agoLinux: Remove rseq support
Florian Weimer [Thu, 16 Jul 2020 15:55:35 +0000 (17:55 +0200)] 
Linux: Remove rseq support

The kernel ABI is not finalized, and there are now various proposals
to change the size of struct rseq, which would make the glibc ABI
dependent on the version of the kernels used for building glibc.
This is of course not acceptable.

This reverts commit 48699da1c468543ade14777819bd1b4d652709de ("elf:
Support at least 32-byte alignment in static dlopen"), commit
8f4632deb3545b2949cec5454afc3cb21a0024ea ("Linux: rseq registration
tests"), commit 6e29cb3f61ff5432c78a1c84b0d9b123a350ab36 ("Linux: Use
rseq in sched_getcpu if available"), and commit
0c76fc3c2b346dc5401dc055d97d4279632b0fb3 ("Linux: Perform rseq
registration at C startup and thread creation"), resolving the conflicts
introduced by the ARC port and the TLS static surplus changes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agomanual: Use Unicode instead HTML entities for characters (bug 19737)
Florian Weimer [Thu, 16 Jul 2020 08:17:31 +0000 (10:17 +0200)] 
manual: Use Unicode instead HTML entities for characters (bug 19737)

Texinfo no longer treats arguments to @set in @ifhtml blocks as
literal HTML, so the & in the entity references was encoded as
@amp; in HTML.  Using the equivalent Unicode characters avoids
this issue.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
5 years agoAdd NEWS entry for CVE-2020-6096 (bug 25620)
Aurelien Jarno [Sun, 12 Jul 2020 19:58:43 +0000 (21:58 +0200)] 
Add NEWS entry for CVE-2020-6096 (bug 25620)

Reviewed-by: Carlos O'Donell <carlos@redhat.com>