]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
5 years agoriscv: Use __has_include__ to include <asm/syscalls.h> [BZ #24022]
H.J. Lu [Thu, 3 Jan 2019 13:13:32 +0000 (14:13 +0100)] 
riscv: Use __has_include__ to include <asm/syscalls.h> [BZ #24022]

<asm/syscalls.h> has been removed by

commit 27f8899d6002e11a6e2d995e29b8deab5aa9cc25
Author: David Abdurachmanov <david.abdurachmanov@gmail.com>
Date:   Thu Nov 8 20:02:39 2018 +0100

    riscv: add asm/unistd.h UAPI header

    Marcin Juszkiewicz reported issues while generating syscall table for riscv
    using 4.20-rc1. The patch refactors our unistd.h files to match some other
    architectures.

    - Add asm/unistd.h UAPI header, which has __ARCH_WANT_NEW_STAT only for 64-bit
    - Remove asm/syscalls.h UAPI header and merge to asm/unistd.h
    - Adjust kernel asm/unistd.h

    So now asm/unistd.h UAPI header should show all syscalls for riscv.

<asm/syscalls.h> may be restored by

Subject: [PATCH] riscv: restore asm/syscalls.h UAPI header
Date: Tue, 11 Dec 2018 09:09:35 +0100

UAPI header asm/syscalls.h was merged into UAPI asm/unistd.h header,
which did resolve issue with missing syscalls macros resulting in
glibc (2.28) build failure. It also broke glibc in a different way:
asm/syscalls.h is being used by glibc. I noticed this while doing
Fedora 30/Rawhide mass rebuild.

The patch returns asm/syscalls.h header and incl. it into asm/unistd.h.
I plan to send a patch to glibc to use asm/unistd.h instead of
asm/syscalls.h

In the meantime, we use __has_include__, which was added to GCC 5, to
check if <asm/syscalls.h> exists before including it.  Tested with
build-many-glibcs.py for riscv against kernel 4.19.12 and 4.20-rc7.

[BZ #24022]
* sysdeps/unix/sysv/linux/riscv/flush-icache.c: Check if
<asm/syscalls.h> exists with __has_include__ before including it.

(cherry picked from commit 0b9c84906f653978fb8768c7ebd0ee14a47e662e)

5 years agointl: Do not return NULL on asprintf failure in gettext [BZ #24018]
Florian Weimer [Wed, 2 Jan 2019 15:46:12 +0000 (16:46 +0100)] 
intl: Do not return NULL on asprintf failure in gettext [BZ #24018]

Fixes commit 9695dd0c9309712ed8e9c17a7040fe7af347f2dc ("DCIGETTEXT:
Use getcwd, asprintf to construct absolute pathname").

(cherry picked from commit 8c1aafc1f34d090a5b41dc527c33e8687f6a1287)

5 years agomalloc: Always call memcpy in _int_realloc [BZ #24027]
Florian Weimer [Mon, 31 Dec 2018 21:04:36 +0000 (22:04 +0100)] 
malloc: Always call memcpy in _int_realloc [BZ #24027]

This commit removes the custom memcpy implementation from _int_realloc
for small chunk sizes.  The ncopies variable has the wrong type, and
an integer wraparound could cause the existing code to copy too few
elements (leaving the new memory region mostly uninitialized).
Therefore, removing this code fixes bug 24027.

(cherry picked from commit b50dd3bc8cbb1efe85399b03d7e6c0310c2ead84)

5 years agoUpdate Alpha libm-test-ulps
Aurelien Jarno [Fri, 28 Dec 2018 10:24:48 +0000 (11:24 +0100)] 
Update Alpha libm-test-ulps

Changelog:
* sysdeps/alpha/fpu/libm-test-ulps: Regenerated.

5 years agom68k: Fix sigaction kernel definition (BZ #23967)
Adhemerval Zanella [Tue, 11 Dec 2018 18:52:47 +0000 (16:52 -0200)] 
m68k: Fix sigaction kernel definition (BZ #23967)

Commit b4a5d26d883 (linux: Consolidate sigaction implementation) added
a wrong kernel_sigaction definition for m68k, meant for __NR_sigaction
instead of __NR_rt_sigaction as used on generic Linux sigaction
implementation.  This patch fixes it by using the Linux generic
definition meant for the RT kernel ABI.

Checked the signal tests on emulated m68-linux-gnu (Aranym).  It fixes
the faulty signal/tst-sigaction and man works as expected.

Adhemerval Zanella  <adhemerval.zanella@linaro.org>
James Clarke  <jrtc27@jrtc27.com>

[BZ #23967]
* sysdeps/unix/sysv/linux/kernel_sigaction.h (HAS_SA_RESTORER):
Define if SA_RESTORER is defined.
(kernel_sigaction): Define sa_restorer if HAS_SA_RESTORER is defined.
(SET_SA_RESTORER, RESET_SA_RESTORER): Define iff the macro are not
already defined.
* sysdeps/unix/sysv/linux/m68k/kernel_sigaction.h (SA_RESTORER,
kernel_sigaction, SET_SA_RESTORER, RESET_SA_RESTORER): Remove
definitions.
(HAS_SA_RESTORER): Define.
* sysdeps/unix/sysv/linux/sparc/kernel_sigaction.h (SA_RESTORER,
SET_SA_RESTORER, RESET_SA_RESTORER): Remove definition.
(HAS_SA_RESTORER): Define.
* sysdeps/unix/sysv/linux/nios2/kernel_sigaction.h: Include generic
kernel_sigaction after define SET_SA_RESTORER and RESET_SA_RESTORER.
* sysdeps/unix/sysv/linux/powerpc/kernel_sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/sigaction.c: Likewise.

(cherry picked from commit 43a45c2d829f164c1fb94d5f44afe326fae946e1)

5 years agoRISC-V: properly terminate call chain (bug 23125)
Andreas Schwab [Tue, 25 Sep 2018 09:11:27 +0000 (11:11 +0200)] 
RISC-V: properly terminate call chain (bug 23125)

Mark the ra register as undefined in _start, so that unwinding through
main works correctly.  Also, don't use a tail call so that ra points after
the call to __libc_start_main, not after the previous call.

(cherry picked from commit 2dd12baa045f25c52b30a34b10f72d51f2605413)

5 years agosupport: Do not require overflow builtin in support/blob_repeat.c
Florian Weimer [Sat, 15 Dec 2018 17:58:09 +0000 (18:58 +0100)] 
support: Do not require overflow builtin in support/blob_repeat.c

It is only available in GCC 5 and later.

Tested-by: Romain Naour <romain.naour@gmail.com>
(cherry picked from commit 0c1719e65b2a5a80331d4f635612799f853b0479)

5 years agoFix rwlock stall with PREFER_WRITER_NONRECURSIVE_NP (bug 23861)
Andreas Schwab [Thu, 8 Nov 2018 13:28:22 +0000 (14:28 +0100)] 
Fix rwlock stall with PREFER_WRITER_NONRECURSIVE_NP (bug 23861)

In the read lock function (__pthread_rwlock_rdlock_full) there was a
code path which would fail to reload __readers while waiting for
PTHREAD_RWLOCK_RWAITING to change. This failure to reload __readers
into a local value meant that various conditionals used the old value
of __readers and with only two threads left it could result in an
indefinite stall of one of the readers (waiting for PTHREAD_RWLOCK_RWAITING
to go to zero, but it never would).

(cherry picked from commit f21e8f8ca466320fed38bdb71526c574dae98026)

5 years agopowerpc: Add missing CFI register information (bug #23614)
Tulio Magno Quites Machado Filho [Thu, 13 Dec 2018 08:42:22 +0000 (09:42 +0100)] 
powerpc: Add missing CFI register information (bug #23614)

Add CFI information about the offset of registers stored in the stack
frame.

[BZ #23614]
* sysdeps/powerpc/powerpc64/addmul_1.S (FUNC): Add CFI offset for
registers saved in the stack frame.
* sysdeps/powerpc/powerpc64/lshift.S (__mpn_lshift): Likewise.
* sysdeps/powerpc/powerpc64/mul_1.S (__mpn_mul_1): Likewise.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
(cherry picked from commit 1d880d4a9bf7608c2cd33bbe954ce6995f79121a)

5 years agomalloc: Add another test for tcache double free check.
DJ Delorie [Sat, 1 Dec 2018 03:13:09 +0000 (22:13 -0500)] 
malloc: Add another test for tcache double free check.

This one tests for BZ#23907 where the double free
test didn't check the tcache bin bounds before dereferencing
the bin.

[BZ #23907]
* malloc/tst-tcfree3.c: New.
* malloc/Makefile: Add it.

(cherry picked from commit 7c9a7c68363051cfc5fa1ebb96b3b2c1f82dcb76)

5 years agoinet/tst-if_index-long: New test case for CVE-2018-19591 [BZ #23927]
Florian Weimer [Thu, 6 Dec 2018 14:39:50 +0000 (15:39 +0100)] 
inet/tst-if_index-long: New test case for CVE-2018-19591 [BZ #23927]

(cherry picked from commit 899478c2bfa00c5df8d8bedb52effbb065700278)

5 years agosupport: Implement <support/descriptors.h> to track file descriptors
Florian Weimer [Thu, 6 Dec 2018 14:39:42 +0000 (15:39 +0100)] 
support: Implement <support/descriptors.h> to track file descriptors

(cherry picked from commit f255336a9301619519045548acb2e1027065a837)

5 years agosupport: Close original descriptors in support_capture_subprocess
Florian Weimer [Sat, 1 Dec 2018 20:43:36 +0000 (21:43 +0100)] 
support: Close original descriptors in support_capture_subprocess

(cherry picked from commit 02cd5c1a8d033d7f91fea12a66bb44d1bbf85f76)

5 years agosupport_quote_string: Do not use str parameter name
Florian Weimer [Wed, 28 Nov 2018 06:00:48 +0000 (07:00 +0100)] 
support_quote_string: Do not use str parameter name

This avoids a build failure if this identifier is used as a macro
in a test.

(cherry picked from commit 47d8d9a2172f827a8dde7695f415aa6f78a82d0e)

5 years agosupport: Implement support_quote_string
Florian Weimer [Tue, 27 Nov 2018 20:35:56 +0000 (21:35 +0100)] 
support: Implement support_quote_string

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
(cherry picked from commit c74a91deaa5de416237c02bbb3e41bda76ca4c7b)

5 years agocompat getdents64: Use correct offset for retry [BZ #23972]
Florian Weimer [Mon, 10 Dec 2018 15:50:37 +0000 (16:50 +0100)] 
compat getdents64: Use correct offset for retry [BZ #23972]

d_off is the offset of the *next* entry, not the offset of the current
entry.

(cherry picked from commit 8d20a2f414fa52aceef8a0e3675415df54a840db)

5 years agoFix _dl_profile_fixup data-dependency issue (Bug 23690)
Tulio Magno Quites Machado Filho [Fri, 30 Nov 2018 20:05:32 +0000 (18:05 -0200)] 
Fix _dl_profile_fixup data-dependency issue (Bug 23690)

There is a data-dependency between the fields of struct l_reloc_result
and the field used as the initialization guard. Users of the guard
expect writes to the structure to be observable when they also observe
the guard initialized. The solution for this problem is to use an acquire
and release load and store to ensure previous writes to the structure are
observable if the guard is initialized.

The previous implementation used DL_FIXUP_VALUE_ADDR (l_reloc_result->addr)
as the initialization guard, making it impossible for some architectures
to load and store it atomically, i.e. hppa and ia64, due to its larger size.

This commit adds an unsigned int to l_reloc_result to be used as the new
initialization guard of the struct, making it possible to load and store
it atomically in all architectures. The fix ensures that the values
observed in l_reloc_result are consistent and do not lead to crashes.
The algorithm is documented in the code in elf/dl-runtime.c
(_dl_profile_fixup). Not all data races have been eliminated.

Tested with build-many-glibcs and on powerpc, powerpc64, and powerpc64le.

[BZ #23690]
* elf/dl-runtime.c (_dl_profile_fixup): Guarantee memory
modification order when accessing reloc_result->addr.
* include/link.h (reloc_result): Add field init.
* nptl/Makefile (tests): Add tst-audit-threads.
(modules-names): Add tst-audit-threads-mod1 and
tst-audit-threads-mod2.
Add rules to build tst-audit-threads.
* nptl/tst-audit-threads-mod1.c: New file.
* nptl/tst-audit-threads-mod2.c: Likewise.
* nptl/tst-audit-threads.c: Likewise.
* nptl/tst-audit-threads.h: Likewise.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit e5d262effe3a87164308a3f37e61b32d0348692a)

5 years agomalloc: tcache double free check
DJ Delorie [Tue, 20 Nov 2018 18:24:09 +0000 (13:24 -0500)] 
malloc: tcache double free check

* malloc/malloc.c (tcache_entry): Add key field.
(tcache_put): Set it.
(tcache_get): Likewise.
(_int_free): Check for double free in tcache.
* malloc/tst-tcfree1.c: New.
* malloc/tst-tcfree2.c: New.
* malloc/Makefile: Run the new tests.
* manual/probes.texi: Document memory_tcache_double_free probe.

* dlfcn/dlerror.c (check_free): Prevent double frees.

(cherry picked from commit bcdaad21d4635931d1bd3b54a7894276925d081d)

malloc: tcache: Validate tc_idx before checking for double-frees [BZ #23907]

The previous check could read beyond the end of the tcache entry
array.  If the e->key == tcache cookie check happened to pass, this
would result in crashes.

(cherry picked from commit affec03b713c82c43a5b025dddc21bde3334f41e)

5 years agoCVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927]
Florian Weimer [Tue, 27 Nov 2018 15:12:43 +0000 (16:12 +0100)] 
CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927]

(cherry picked from commit d527c860f5a3f0ed687bd03f0cb464612dc23408)

5 years agoRevert "malloc: tcache double free check" [BZ #23907]
Florian Weimer [Thu, 22 Nov 2018 21:05:57 +0000 (22:05 +0100)] 
Revert "malloc: tcache double free check" [BZ #23907]

This reverts commit 481a6cf0c24f02f251d7cd0b776c12d00e6b144f, the
backport of commit bcdaad21d4635931d1bd3b54a7894276925d081d on the
master branch.

5 years agomalloc: tcache double free check
DJ Delorie [Tue, 20 Nov 2018 18:24:09 +0000 (13:24 -0500)] 
malloc: tcache double free check

* malloc/malloc.c (tcache_entry): Add key field.
(tcache_put): Set it.
(tcache_get): Likewise.
(_int_free): Check for double free in tcache.
* malloc/tst-tcfree1.c: New.
* malloc/tst-tcfree2.c: New.
* malloc/Makefile: Run the new tests.
* manual/probes.texi: Document memory_tcache_double_free probe.

* dlfcn/dlerror.c (check_free): Prevent double frees.

5 years agosupport: Print timestamps in timeout handler
Florian Weimer [Mon, 19 Nov 2018 14:35:03 +0000 (15:35 +0100)] 
support: Print timestamps in timeout handler

This is sometimes useful to determine if a test truly got stuck, or if
it was making progress (logging information to standard output) and
was merely slow to finish.

(cherry picked from commit 35e3fbc4512c880fccb35b8e3abd132d4be18480)

5 years agoIncrease timeout of libio/tst-readline
Szabolcs Nagy [Tue, 9 Oct 2018 13:31:28 +0000 (14:31 +0100)] 
Increase timeout of libio/tst-readline

Increase timeout from the default 20s to 100s. This test makes close to
20 million syscalls with distribution:

12327675 read
 4143204 lseek
  929475 close
  929471 openat
   92817 fstat
    1431 write
...

The default timeout assumes each can finish in 1us on average which
is not true on slow machines.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* libio/tst-readline.c (TIMEOUT): Define.

(cherry picked from commit ed643089cd3251038863d32e67ec47b94cd557f3)

5 years agoUpdate kernel version in syscall-names.list to 4.19.
Joseph Myers [Mon, 22 Oct 2018 23:26:37 +0000 (23:26 +0000)] 
Update kernel version in syscall-names.list to 4.19.

Linux 4.19 does not add any new syscalls (some existing ones are added
to more architectures); this patch updates the version number in
syscall-names.list to reflect that it's still current for 4.19.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 4.19.

(cherry picked from commit 029ad711b8ad4cf0e5d98e0c138a35a23a376a74)

5 years agoFix tzfile low-memory assertion failure
Paul Eggert [Tue, 18 Sep 2018 22:02:10 +0000 (15:02 -0700)] 
Fix tzfile low-memory assertion failure

[BZ #21716]
* time/tzfile.c (__tzfile_read): Check for memory exhaustion
when registering time zone abbreviations.

(cherry picked from commit e4e4fde51a309801af5eed72d3494cbf4b7737aa)

5 years ago[BZ #20271] Add newlines in __libc_fatal calls.
Paul Pluzhnikov [Sat, 1 Sep 2018 01:04:32 +0000 (18:04 -0700)] 
[BZ #20271] Add newlines in __libc_fatal calls.

(cherry picked from commit a6e8926f8d49a213a9abb1a61f6af964f612ab7f)

5 years agonscd: Fix use-after-free in addgetnetgrentX [BZ #23520]
Florian Weimer [Tue, 28 Aug 2018 11:19:27 +0000 (13:19 +0200)] 
nscd: Fix use-after-free in addgetnetgrentX [BZ #23520]

addinnetgrX may use the heap-allocated buffer, so free the buffer
in this function.

(cherry picked from commit 745664bd798ec8fd50438605948eea594179fba1)

5 years agomalloc: Additional checks for unsorted bin integrity I.
Istvan Kurucsai [Tue, 16 Jan 2018 13:54:32 +0000 (14:54 +0100)] 
malloc: Additional checks for unsorted bin integrity I.

On Thu, Jan 11, 2018 at 3:50 PM, Florian Weimer <fweimer@redhat.com> wrote:
> On 11/07/2017 04:27 PM, Istvan Kurucsai wrote:
>>
>> +          next = chunk_at_offset (victim, size);
>
>
> For new code, we prefer declarations with initializers.

Noted.

>> +          if (__glibc_unlikely (chunksize_nomask (victim) <= 2 * SIZE_SZ)
>> +              || __glibc_unlikely (chunksize_nomask (victim) >
>> av->system_mem))
>> +            malloc_printerr("malloc(): invalid size (unsorted)");
>> +          if (__glibc_unlikely (chunksize_nomask (next) < 2 * SIZE_SZ)
>> +              || __glibc_unlikely (chunksize_nomask (next) >
>> av->system_mem))
>> +            malloc_printerr("malloc(): invalid next size (unsorted)");
>> +          if (__glibc_unlikely ((prev_size (next) & ~(SIZE_BITS)) !=
>> size))
>> +            malloc_printerr("malloc(): mismatching next->prev_size
>> (unsorted)");
>
>
> I think this check is redundant because prev_size (next) and chunksize
> (victim) are loaded from the same memory location.

I'm fairly certain that it compares mchunk_size of victim against
mchunk_prev_size of the next chunk, i.e. the size of victim in its
header and footer.

>> +          if (__glibc_unlikely (bck->fd != victim)
>> +              || __glibc_unlikely (victim->fd != unsorted_chunks (av)))
>> +            malloc_printerr("malloc(): unsorted double linked list
>> corrupted");
>> +          if (__glibc_unlikely (prev_inuse(next)))
>> +            malloc_printerr("malloc(): invalid next->prev_inuse
>> (unsorted)");
>
>
> There's a missing space after malloc_printerr.

Noted.

> Why do you keep using chunksize_nomask?  We never investigated why the
> original code uses it.  It may have been an accident.

You are right, I don't think it makes a difference in these checks. So
the size local can be reused for the checks against victim. For next,
leaving it as such avoids the masking operation.

> Again, for non-main arenas, the checks against av->system_mem could be made
> tighter (against the heap size).  Maybe you could put the condition into a
> separate inline function?

We could also do a chunk boundary check similar to what I proposed in
the thread for the first patch in the series to be even more strict.
I'll gladly try to implement either but believe that refining these
checks would bring less benefits than in the case of the top chunk.
Intra-arena or intra-heap overlaps would still be doable here with
unsorted chunks and I don't see any way to counter that besides more
generic measures like randomizing allocations and your metadata
encoding patches.

I've attached a revised version with the above comments incorporated
but without the refined checks.

Thanks,
Istvan

From a12d5d40fd7aed5fa10fc444dcb819947b72b315 Mon Sep 17 00:00:00 2001
From: Istvan Kurucsai <pistukem@gmail.com>
Date: Tue, 16 Jan 2018 14:48:16 +0100
Subject: [PATCH v2 1/1] malloc: Additional checks for unsorted bin integrity
 I.

Ensure the following properties of chunks encountered during binning:
- victim chunk has reasonable size
- next chunk has reasonable size
- next->prev_size == victim->size
- valid double linked list
- PREV_INUSE of next chunk is unset

    * malloc/malloc.c (_int_malloc): Additional binning code checks.

(cherry picked from commit b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c)

5 years agomalloc: Mitigate null-byte overflow attacks
Moritz Eckert [Fri, 17 Aug 2018 01:08:36 +0000 (21:08 -0400)] 
malloc: Mitigate null-byte overflow attacks

* malloc/malloc.c (_int_free): Check for corrupt prev_size vs size.
(malloc_consolidate): Likewise.

(cherry picked from commit d6db68e66dff25d12c3bc5641b60cbd7fb6ab44f)

5 years agomalloc: Verify size of top chunk.
Pochang Chen [Thu, 16 Aug 2018 19:24:24 +0000 (15:24 -0400)] 
malloc: Verify size of top chunk.

The House of Force is a well-known technique to exploit heap
overflow. In essence, this exploit takes three steps:
1. Overwrite the size of top chunk with very large value (e.g. -1).
2. Request x bytes from top chunk. As the size of top chunk
   is corrupted, x can be arbitrarily large and top chunk will
   still be offset by x.
3. The next allocation from top chunk will thus be controllable.

If we verify the size of top chunk at step 2, we can stop such attack.

(cherry picked from commit 30a17d8c95fbfb15c52d1115803b63aaa73a285c)

5 years agoUpdate syscall-names.list for Linux 4.18.
Joseph Myers [Mon, 13 Aug 2018 21:35:27 +0000 (21:35 +0000)] 
Update syscall-names.list for Linux 4.18.

This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 4.18.  The io_pgetevents and rseq syscalls are added to the
kernel on various architectures, so need to be mentioned in this file.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 4.18.
(io_pgetevents): New syscall.
(rseq): Likewise.

(cherry picked from commit 17b26500f9bb926d85e86821d014f7c1bb88043c)

5 years agoAdd an additional test to resolv/tst-resolv-network.c
Alexandra Hájková [Fri, 19 Oct 2018 11:30:44 +0000 (13:30 +0200)] 
Add an additional test to resolv/tst-resolv-network.c

Test for the infinite loop in getnetbyname, bug #17630.

(cherry picked from commit ac8060265bcaca61568ef3a20b9a0140a270af54)

5 years agoCheck multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]
H.J. Lu [Thu, 8 Nov 2018 18:06:58 +0000 (10:06 -0800)] 
Check multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]

Linkers group input note sections with the same name into one output
note section with the same name.  One output note section is placed in
one PT_NOTE segment.  Since new linkers merge input .note.gnu.property
sections into one output .note.gnu.property section, there is only
one NT_GNU_PROPERTY_TYPE_0 note in one PT_NOTE segment with new linkers.
Since older linkers treat input .note.gnu.property section as a generic
note section and just concatenate all input .note.gnu.property sections
into one output .note.gnu.property section without merging them, we may
see multiple NT_GNU_PROPERTY_TYPE_0 notes in one PT_NOTE segment with
older linkers.

When an older linker is used to created the program on CET-enabled OS,
the linker output has a single .note.gnu.property section with multiple
NT_GNU_PROPERTY_TYPE_0 notes, some of which have IBT and SHSTK enable
bits set even if the program isn't CET enabled.  Such programs will
crash on CET-enabled machines.  This patch updates the note parser:

1. Skip note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
2. Check multiple NT_GNU_PROPERTY_TYPE_0 notes.

[BZ #23509]
* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Skip
note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
Update the l_cet field when processing NT_GNU_PROPERTY_TYPE_0 note.
Check multiple NT_GNU_PROPERTY_TYPE_0 notes.
* sysdeps/x86/link_map.h (l_cet): Expand to 3 bits,  Add
lc_unknown.

(cherry picked from commit d524fa6c35e675eedbd8fe6cdf4db0b49c658026)

5 years agolibanl: properly cleanup if first helper thread creation failed (bug 22927)
Andreas Schwab [Tue, 6 Nov 2018 15:12:07 +0000 (16:12 +0100)] 
libanl: properly cleanup if first helper thread creation failed (bug 22927)

(cherry picked from commit bd3b0fbae33a9a4cc5e2daf049443d5cf03d4251)

5 years agox86: Fix Haswell CPU string flags (BZ#23709)
Adhemerval Zanella [Fri, 2 Nov 2018 09:56:00 +0000 (10:56 +0100)] 
x86: Fix Haswell CPU string flags (BZ#23709)

Th commit 'Disable TSX on some Haswell processors.' (2702856bf4) changed the
default flags for Haswell models.  Previously, new models were handled by the
default switch path, which assumed a Core i3/i5/i7 if AVX is available. After
the patch, Haswell models (0x3f, 0x3c, 0x45, 0x46) do not set the flags
Fast_Rep_String, Fast_Unaligned_Load, Fast_Unaligned_Copy, and
Prefer_PMINUB_for_stringop (only the TSX one).

This patch fixes it by disentangle the TSX flag handling from the memory
optimization ones.  The strstr case cited on patch now selects the
__strstr_sse2_unaligned as expected for the Haswell cpu.

Checked on x86_64-linux-gnu.

[BZ #23709]
* sysdeps/x86/cpu-features.c (init_cpu_features): Set TSX bits
independently of other flags.

(cherry picked from commit c3d8dc45c9df199b8334599a6cbd98c9950dba62)

5 years agostdlib/tst-strtod-overflow: Switch to support_blob_repeat
Florian Weimer [Tue, 30 Oct 2018 12:55:01 +0000 (13:55 +0100)] 
stdlib/tst-strtod-overflow: Switch to support_blob_repeat

This is another test with an avoidable large memory allocation.

(cherry picked from commit 07da99aad93c9364acb7efdab47c27ba698f6313)

5 years agosupport_blob_repeat: Call mkstemp directory for the backing file
Florian Weimer [Tue, 30 Oct 2018 12:55:50 +0000 (13:55 +0100)] 
support_blob_repeat: Call mkstemp directory for the backing file

This avoids a warning during post-test cleanup.

(cherry picked from commit a91e9301c47bb688f4e496a19cfc68261ff18293)

5 years agostdlib/test-bz22786: Avoid memory leaks in the test itself
Florian Weimer [Tue, 30 Oct 2018 12:56:40 +0000 (13:56 +0100)] 
stdlib/test-bz22786: Avoid memory leaks in the test itself

(cherry picked from commit 60708030536df82616c16aa2f14f533c4362b969)

5 years agostdlib/test-bz22786: Avoid spurious test failures using alias mappings
Florian Weimer [Tue, 30 Oct 2018 12:11:47 +0000 (13:11 +0100)] 
stdlib/test-bz22786: Avoid spurious test failures using alias mappings

On systems without enough random-access memory, stdlib/test-bz22786
will go deeply into swap and time out, even with a substantial
TIMEOUTFACTOR.  This commit adds a facility to construct repeating
strings with alias mappings, so that the requirement for physical
memory, and uses it in stdlib/test-bz22786.

(cherry picked from commit f5e7e95921847bd83186bfe621fc2b48c4de5477)

5 years agoTest stdlib/test-bz22786 exits now with unsupported if malloc fails.
Stefan Liebler [Thu, 30 Aug 2018 06:44:32 +0000 (08:44 +0200)] 
Test stdlib/test-bz22786 exits now with unsupported if malloc fails.

The test tries to allocate more than 2^31 bytes which will always fail on s390
as it has maximum 2^31bit of memory.
Before commit 6c3a8a9d868a8deddf0d6dcc785b6d120de90523, this test returned
unsupported if malloc fails.  This patch re enables this behaviour.

Furthermore support_delete_temp_files() failed to remove the temp directory
in this case as it is not empty due to the created symlink.
Thus the creation of the symlink is moved behind malloc.

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

* stdlib/test-bz22786.c (do_test): Return EXIT_UNSUPPORTED
if malloc fails.

(cherry picked from commit 3bad2358d67d371497079bba4f8eca9c0096f4e2)

5 years agoFix BZ#23400 (creating temporary files in source tree), and undefined behavior in...
Paul Pluzhnikov [Fri, 2 Nov 2018 09:47:07 +0000 (10:47 +0100)] 
Fix BZ#23400 (creating temporary files in source tree), and undefined behavior in test.

(cherry picked from commit 6c3a8a9d868a8deddf0d6dcc785b6d120de90523)

5 years agoi64: fix missing exp2f, log2f and powf symbols in libm.a [BZ #23822]
Szabolcs Nagy [Fri, 26 Oct 2018 13:39:42 +0000 (14:39 +0100)] 
i64: fix missing exp2f, log2f and powf symbols in libm.a [BZ #23822]

When new symbol versions were introduced without SVID compatible
error handling the exp2f, log2f and powf symbols were accidentally
removed from the ia64 lim.a.  The regression was introduced by
the commits

f5f0f5265162fe6f4f238abcd3086985f7c38d6d
New expf and exp2f version without SVID compat wrapper

72d3d281080be9f674982067d72874fd6cdb4b64
New symbol version for logf, log2f and powf without SVID compat

With WEAK_LIBM_ENTRY(foo), there is a hidden __foo and weak foo
symbol definition in both SHARED and !SHARED build.

[BZ #23822]
* sysdeps/ia64/fpu/e_exp2f.S (exp2f): Use WEAK_LIBM_ENTRY.
* sysdeps/ia64/fpu/e_log2f.S (log2f): Likewise.
* sysdeps/ia64/fpu/e_exp2f.S (powf): Likewise.

(cherry picked from commit ba5b14c7613980dfefcad6b6e88f913e5f596c59)

5 years agoconform: XFAIL siginfo_t si_band test on sparc64
Florian Weimer [Fri, 26 Oct 2018 07:19:40 +0000 (09:19 +0200)] 
conform: XFAIL siginfo_t si_band test on sparc64

We can use long int on sparcv9, but on sparc64, we must match the int
type used by the kernel (and not long int, as in POSIX).

(cherry picked from commit 7c5e34d7f1b8f8f5acd94c2b885ae13b85414dcd)

5 years agosignal: Use correct type for si_band in siginfo_t [BZ #23562]
Ilya Yu. Malakhov [Mon, 22 Oct 2018 11:03:57 +0000 (13:03 +0200)] 
signal: Use correct type for si_band in siginfo_t [BZ #23562]

(cherry picked from commit f997b4be18f7e57d757d39e42f7715db26528aa0)

5 years agoFix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP [BZ #23275]
Stefan Liebler [Wed, 17 Oct 2018 10:23:04 +0000 (12:23 +0200)] 
Fix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP [BZ #23275]

The race leads either to pthread_mutex_destroy returning EBUSY
or triggering an assertion (See description in bugzilla).

This patch is fixing the race by ensuring that the elision path is
used in all cases if elision is enabled by the GLIBC_TUNABLES framework.

The __kind variable in struct __pthread_mutex_s is accessed concurrently.
Therefore we are now using the atomic macros.

The new testcase tst-mutex10 is triggering the race on s390x and intel.
Presumably also on power, but I don't have access to a power machine
with lock-elision. At least the code for power is the same as on the other
two architectures.

ChangeLog:

[BZ #23275]
* nptl/tst-mutex10.c: New File.
* nptl/Makefile (tests): Add tst-mutex10.
(tst-mutex10-ENV): New variable.
* sysdeps/unix/sysv/linux/s390/force-elision.h: (FORCE_ELISION):
Ensure that elision path is used if elision is available.
* sysdeps/unix/sysv/linux/powerpc/force-elision.h (FORCE_ELISION):
Likewise.
* sysdeps/unix/sysv/linux/x86/force-elision.h: (FORCE_ELISION):
Likewise.
* nptl/pthreadP.h (PTHREAD_MUTEX_TYPE, PTHREAD_MUTEX_TYPE_ELISION)
(PTHREAD_MUTEX_PSHARED): Use atomic_load_relaxed.
* nptl/pthread_mutex_consistent.c (pthread_mutex_consistent): Likewise.
* nptl/pthread_mutex_getprioceiling.c (pthread_mutex_getprioceiling):
Likewise.
* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full)
(__pthread_mutex_cond_lock_adjust): Likewise.
* nptl/pthread_mutex_setprioceiling.c (pthread_mutex_setprioceiling):
Likewise.
* nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Likewise.
* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
* sysdeps/nptl/bits/thread-shared-types.h (struct __pthread_mutex_s):
Add comments.
* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy):
Use atomic_load_relaxed and atomic_store_relaxed.
* nptl/pthread_mutex_init.c (__pthread_mutex_init):
Use atomic_store_relaxed.

(cherry picked from commit 403b4feb22dcbc85ace72a361d2a951380372471)

5 years agoi386: Use _dl_runtime_[resolve|profile]_shstk for SHSTK [BZ #23716]
H.J. Lu [Fri, 28 Sep 2018 20:31:19 +0000 (13:31 -0700)] 
i386: Use _dl_runtime_[resolve|profile]_shstk for SHSTK [BZ #23716]

When elf_machine_runtime_setup is called to set up resolver, it should
use _dl_runtime_resolve_shstk or _dl_runtime_profile_shstk if SHSTK is
enabled by kernel.

Tested on i686 with and without --enable-cet as well as on CET emulator
with --enable-cet.

[BZ #23716]
* sysdeps/i386/dl-cet.c: Removed.
* sysdeps/i386/dl-machine.h (_dl_runtime_resolve_shstk): New
prototype.
(_dl_runtime_profile_shstk): Likewise.
(elf_machine_runtime_setup): Use _dl_runtime_profile_shstk or
_dl_runtime_resolve_shstk if SHSTK is enabled by kernel.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 7b1f9406761331cf35fe521fbdb592beecf68a2c)

5 years agokl_GL: Fix spelling of Sunday, should be "sapaat" (bug 20209).
Rafal Luzynski [Tue, 2 Oct 2018 21:34:18 +0000 (23:34 +0200)] 
kl_GL: Fix spelling of Sunday, should be "sapaat" (bug 20209).

Although CLDR says otherwise, it is confirmed by Oqaasileriffik, the
official Greenlandic language regulator, that this change is correct.

[BZ #20209]
* localedata/locales/kl_GL: (abday): Fix spelling of Sun (Sunday),
should be "sap" rather than "sab".
(day): Fix spelling of Sunday, should be "sapaat" rather than
"sabaat".

(cherry picked from commit dae3ed958c3d0090838e49ff4f78c201262b1cf0)

5 years agoFix misreported errno on preadv2/pwritev2 (BZ#23579)
Adhemerval Zanella [Wed, 29 Aug 2018 19:36:44 +0000 (16:36 -0300)] 
Fix misreported errno on preadv2/pwritev2 (BZ#23579)

The fallback code of Linux wrapper for preadv2/pwritev2 executes
regardless of the errno code for preadv2, instead of the case where
the syscall is not supported.

This fixes it by calling the fallback code iff errno is ENOSYS. The
patch also adds tests for both invalid file descriptor and invalid
iov_len and vector count.

The only discrepancy between preadv2 and fallback code regarding
error reporting is when an invalid flags are used.  The fallback code
bails out earlier with ENOTSUP instead of EINVAL/EBADF when the syscall
is used.

Checked on x86_64-linux-gnu on a 4.4.0 and 4.15.0 kernel.

[BZ #23579]
* misc/tst-preadvwritev2-common.c (do_test_with_invalid_fd): New
test.
* misc/tst-preadvwritev2.c, misc/tst-preadvwritev64v2.c (do_test):
Call do_test_with_invalid_fd.
* sysdeps/unix/sysv/linux/preadv2.c (preadv2): Use fallback code iff
errno is ENOSYS.
* sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise.
* sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise.
* sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise.

(cherry picked from commit 7a16bdbb9ff4122af0a28dc20996c95352011fdd)

5 years agoFix stack overflow in tst-setcontext9 (bug 23717)
Andreas Schwab [Thu, 27 Sep 2018 10:37:06 +0000 (12:37 +0200)] 
Fix stack overflow in tst-setcontext9 (bug 23717)

The function f1a, executed on a stack of size 32k, allocates an object of
size 32k on the stack.  Make the stack variables static to reduce
excessive stack usage.

(cherry picked from commit f841c97e515a1673485a2b12b3c280073d737890)

5 years agoi386: Use ENTRY and END in start.S [BZ #23606]
H.J. Lu [Wed, 12 Sep 2018 15:40:59 +0000 (08:40 -0700)] 
i386: Use ENTRY and END in start.S [BZ #23606]

Wrapping the _start function with ENTRY and END to insert ENDBR32 at
function entry when CET is enabled.  Since _start now includes CFI,
without "cfi_undefined (eip)", unwinder may not terminate at _start
and we will get

Program received signal SIGSEGV, Segmentation fault.
0xf7dc661e in ?? () from /lib/libgcc_s.so.1
Missing separate debuginfos, use: dnf debuginfo-install libgcc-8.2.1-3.0.fc28.i686
(gdb) bt
 #0  0xf7dc661e in ?? () from /lib/libgcc_s.so.1
 #1  0xf7dc7c18 in _Unwind_Backtrace () from /lib/libgcc_s.so.1
 #2  0xf7f0d809 in __GI___backtrace (array=array@entry=0xffffc7d0,
    size=size@entry=20) at ../sysdeps/i386/backtrace.c:127
 #3  0x08049254 in compare (p1=p1@entry=0xffffcad0, p2=p2@entry=0xffffcad4)
    at backtrace-tst.c:12
 #4  0xf7e2a28c in msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0,
    n=n@entry=2) at msort.c:65
 #5  0xf7e29f64 in msort_with_tmp (n=2, b=0xffffcad0, p=0xffffca5c)
    at msort.c:53
 #6  msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0, n=n@entry=5)
    at msort.c:53
 #7  0xf7e29f64 in msort_with_tmp (n=5, b=0xffffcad0, p=0xffffca5c)
    at msort.c:53
 #8  msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0, n=n@entry=10)
    at msort.c:53
 #9  0xf7e29f64 in msort_with_tmp (n=10, b=0xffffcad0, p=0xffffca5c)
    at msort.c:53
 #10 msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0, n=n@entry=20)
    at msort.c:53
 #11 0xf7e2a5b6 in msort_with_tmp (n=20, b=0xffffcad0, p=0xffffca5c)
    at msort.c:297
 #12 __GI___qsort_r (b=b@entry=0xffffcad0, n=n@entry=20, s=s@entry=4,
    cmp=cmp@entry=0x8049230 <compare>, arg=arg@entry=0x0) at msort.c:297
 #13 0xf7e2a84d in __GI_qsort (b=b@entry=0xffffcad0, n=n@entry=20, s=s@entry=4,
    cmp=cmp@entry=0x8049230 <compare>) at msort.c:308
 #14 0x080490f6 in main (argc=2, argv=0xffffcbd4) at backtrace-tst.c:39

FAIL: debug/backtrace-tst

[BZ #23606]
* sysdeps/i386/start.S: Include <sysdep.h>
(_start): Use ENTRY/END to insert ENDBR32 at entry when CET is
enabled.  Add cfi_undefined (eip).

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 5a274db4ea363d6b0b92933f085a92daaf1be2f2)

5 years agoFix strstr bug with huge needles (bug 23637)
Wilco Dijkstra [Wed, 19 Sep 2018 15:50:18 +0000 (16:50 +0100)] 
Fix strstr bug with huge needles (bug 23637)

The generic strstr in GLIBC 2.28 fails to match huge needles.  The optimized
AVAILABLE macro reads ahead a large fixed amount to reduce the overhead of
repeatedly checking for the end of the string.  However if the needle length
is larger than this, two_way_long_needle may confuse this as meaning the end
of the string and return NULL.  This is fixed by adding the needle length to
the amount to read ahead.

[BZ #23637]
* string/test-strstr.c (pr23637): New function.
(test_main): Add tests with longer needles.
* string/strcasestr.c (AVAILABLE): Fix readahead distance.
* string/strstr.c (AVAILABLE): Likewise.

    (cherry picked from commit 83a552b0bb9fc2a5e80a0ab3723c0a80ce1db9f2)

5 years agoFix tst-setcontext9 for optimized small stacks.
Carlos O'Donell [Wed, 5 Sep 2018 05:16:42 +0000 (01:16 -0400)] 
Fix tst-setcontext9 for optimized small stacks.

If the compiler reduces the stack usage in function f1 before calling
into function f2, then when we swapcontext back to f1 and continue
execution we may overwrite registers that were spilled to the stack
while f2 was executing.  Later when we return to f2 the corrupt
registers will be reloaded from the stack and the test will crash.  This
was most commonly observed on i686 with __x86.get_pc_thunk.dx and
needing to save and restore $edx.  Overall i686 has few registers and
the spilling to the stack is bound to happen, therefore the solution to
making this test robust is to split function f1 into two parts f1a and
f1b, and allocate f1b it's own stack such that subsequent execution does
not overwrite the stack in use by function f2.

Tested on i686 and x86_64.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 791b350dc725545e3f9b5db0f97ebdbc60c9735f)

5 years agomisc: New test misc/tst-gethostid
Florian Weimer [Thu, 20 Sep 2018 10:03:01 +0000 (12:03 +0200)] 
misc: New test misc/tst-gethostid

The empty /etc/hosts file used to trigger bug 23679.

(cherry picked from commit db9a8ad4ff3fc58e3773a9a4d0cabe3c1bc9c94c)

5 years agoLinux gethostid: Check for NULL value from gethostbyname_r [BZ #23679]
Mingli Yu [Thu, 20 Sep 2018 10:41:13 +0000 (12:41 +0200)] 
Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679]

A NULL value can happen with certain gethostbyname_r failures.

(cherry picked from commit 1214ba06e6771acb953a190091b0f6055c64fd25)

5 years agoFix segfault in maybe_script_execute.
Stefan Liebler [Thu, 6 Sep 2018 12:27:03 +0000 (14:27 +0200)] 
Fix segfault in maybe_script_execute.

If glibc is built with gcc 8 and -march=z900,
the testcase posix/tst-spawn4-compat crashes with a segfault.

In function maybe_script_execute, the new_argv array is dynamically
initialized on stack with (argc + 1) elements.
The function wants to add _PATH_BSHELL as the first argument
and writes out of bounds of new_argv.
There is an off-by-one because maybe_script_execute fails to count
the terminating NULL when sizing new_argv.

ChangeLog:

* sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute):
Increment size of new_argv by one.

(cherry picked from commit 28669f86f6780a18daca264f32d66b1428c9c6f1)

5 years agoregex: Add test tst-regcomp-truncated [BZ #23578]
Florian Weimer [Tue, 28 Aug 2018 10:57:46 +0000 (12:57 +0200)] 
regex: Add test tst-regcomp-truncated [BZ #23578]

(cherry picked from commit 761404b74d9853ce1608195e24f25b78a910591a)

5 years agoregex: fix uninitialized memory access
Paul Eggert [Tue, 28 Aug 2018 19:54:28 +0000 (21:54 +0200)] 
regex: fix uninitialized memory access

I introduced this bug into gnulib in commit
8335a4d6c7b4448cd0bcb6d0bebf1d456bcfdb17 dated 2006-04-10;
eventually it was merged into glibc.  The bug was found by
project-repo <bugs@feusi.co> and reported here:
https://lists.gnu.org/r/sed-devel/2018-08/msg00017.html
Diagnosis and draft fix reported by Assaf Gordon here:
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00071.html
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00142.html
* posix/regex_internal.c (build_wcs_upper_buffer):
Fix bug when mbrtowc returns 0.

(cherry picked from commit bc680b336971305cb39896b30d72dc7101b62242)

5 years agopthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538]
Martin Kuchta [Mon, 27 Aug 2018 16:54:46 +0000 (18:54 +0200)] 
pthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538]

(cherry picked from commit 99ea93ca31795469d2a1f1570f17a5c39c2eb7e2)

5 years agoImprove ChangeLog message.
DJ Delorie [Wed, 22 Aug 2018 16:54:51 +0000 (18:54 +0200)] 
Improve ChangeLog message.

(cherry picked from commit e5721f45f6377c27ccb2572001dc98f7a2e6a146)

5 years agoRegen RISC-V rvd ULPs
DJ Delorie [Fri, 3 Aug 2018 17:52:01 +0000 (13:52 -0400)] 
Regen RISC-V rvd ULPs

* sysdeps/riscv/rv64/rvd/libm-test-ulps: Update.

Note: I regen'd these from scratch, but I'm only committing the
increases, as I only tested on hardware.  There were a few 2->1
decreases that I omitted, possibly "for now".

(cherry picked from commit bb17621ab89b2135c4d8d0d250b2aab5aa3e36c4)

5 years agoRISC-V: Fix rounding save/restore bug.
DJ Delorie [Fri, 3 Aug 2018 17:43:31 +0000 (13:43 -0400)] 
RISC-V: Fix rounding save/restore bug.

* sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv):
Fix rounding save-restore bug.

Fixes about a hundred off-by-ULP failures in the math testsuite.

(cherry picked from commit bf4181878780be9b53e37a3b0fbabc40cdd07649)

5 years agonss_files: Fix file stream leak in aliases lookup [BZ #23521]
Florian Weimer [Tue, 14 Aug 2018 08:57:48 +0000 (10:57 +0200)] 
nss_files: Fix file stream leak in aliases lookup [BZ #23521]

In order to get a clean test case, it was necessary to fix partially
fixed bug 23522 as well.

(cherry picked from commit e95c6f61920a0f9237cfb292fa44ad500e1df09b)

5 years agonscd: Deallocate existing user names in file parser
Florian Weimer [Tue, 14 Aug 2018 08:51:07 +0000 (10:51 +0200)] 
nscd: Deallocate existing user names in file parser

This avoids a theoretical memory leak (theoretical because it depends on
multiple server-user/stat-user directives in the configuration file).

(cherry picked from commit 2d7acfac3ebf266dcbc82d0d6cc576f626953a03)

5 years agoerror, error_at_line: Add missing va_end calls
Florian Weimer [Mon, 13 Aug 2018 12:28:07 +0000 (14:28 +0200)] 
error, error_at_line: Add missing va_end calls

(cherry picked from commit b7b52b9dec337a08a89bc67638773be652eba332)

5 years agoLinux: Rewrite __old_getdents64 [BZ #23497]
Florian Weimer [Fri, 10 Aug 2018 09:19:26 +0000 (11:19 +0200)] 
Linux: Rewrite __old_getdents64 [BZ #23497]

Commit 298d0e3129c0b5137f4989275b13fe30d0733c4d ("Consolidate Linux
getdents{64} implementation") broke the implementation because it does
not take into account struct offset differences.

The new implementation is close to the old one, before the
consolidation, but has been cleaned up slightly.

(cherry picked from commit 690652882b499defb3d950dfeff8fe421d13cab5)

5 years agohurd: Avoid PLTs for __pthread_get/setspecific
Samuel Thibault [Wed, 8 Aug 2018 23:26:19 +0000 (01:26 +0200)] 
hurd: Avoid PLTs for __pthread_get/setspecific

* sysdeps/htl/pthreadP.h [IS_IN (libpthread)] (__pthread_getspecific,
__pthread_setspecific): Add hidden proto.
* sysdeps/htl/pt-getspecific.c (__pthread_getspecific): Add hidden def.
* sysdeps/htl/pt-setspecific.c (__pthread_setspecific): Add hidden def.

5 years agohurd: Add missing symbols for proper libc_get/setspecific
Samuel Thibault [Tue, 7 Aug 2018 23:55:04 +0000 (01:55 +0200)] 
hurd: Add missing symbols for proper libc_get/setspecific

* htl/Versions (__pthread_getspecific, __pthread_setspecific): Add
symbols.

5 years agoUpdate NEWS, version.h, and features.h for glibc 2.28. glibc-2.28
Carlos O'Donell [Wed, 1 Aug 2018 05:10:47 +0000 (01:10 -0400)] 
Update NEWS, version.h, and features.h for glibc 2.28.

5 years agoSynchronize translation project PO files.
Carlos O'Donell [Wed, 1 Aug 2018 04:59:03 +0000 (00:59 -0400)] 
Synchronize translation project PO files.

5 years agohurd: Fix exec usage of mach_setup_thread
Samuel Thibault [Tue, 31 Jul 2018 22:10:03 +0000 (00:10 +0200)] 
hurd: Fix exec usage of mach_setup_thread

Exec needs that mach_setup_thread does *not* set up TLS since it works on
another task, so we have to split this into mach_setup_tls.

* mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes.
* mach/setup-thread.c (__mach_setup_thread): Move TLS setup to...
(__mach_setup_tls): ... new function.
(mach_setup_tls): New alias.
* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after
__mach_setup_thread.
* sysdeps/mach/hurd/profil.c (update_waiter): Likewise.
* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise.
* mach/Versions [libc] (mach_setup_tls): Add symbol.
* sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.

5 years agohurd: Add missing ChangeLog entry
Samuel Thibault [Tue, 31 Jul 2018 22:07:29 +0000 (00:07 +0200)] 
hurd: Add missing ChangeLog entry

5 years agohurd: Fix startup of static binaries linked against libpthread
Samuel Thibault [Tue, 31 Jul 2018 20:33:05 +0000 (22:33 +0200)] 
hurd: Fix startup of static binaries linked against libpthread

* sysdeps/mach/hurd/i386/init-first.c (init1): Move ELF hdr and TLS
initialization...
(init): ... before initializing libpthread.

5 years agoUpdate tooling versions verified to work with glibc.
Carlos O'Donell [Tue, 31 Jul 2018 20:37:07 +0000 (16:37 -0400)] 
Update tooling versions verified to work with glibc.

5 years agoUpdate contrib.texi contributions.
Carlos O'Donell [Tue, 31 Jul 2018 19:26:24 +0000 (15:26 -0400)] 
Update contrib.texi contributions.

5 years agoUpdate translation for be.
Carlos O'Donell [Tue, 31 Jul 2018 19:23:23 +0000 (15:23 -0400)] 
Update translation for be.

5 years agoUpdate SH libm-tests-ulps
Adhemerval Zanella [Tue, 31 Jul 2018 13:33:53 +0000 (10:33 -0300)] 
Update SH libm-tests-ulps

* sysdeps/sh/libm-test-ulps: Update.

5 years agoUpdate translations for bg, de, hr, pt_BR, sv, and vi.
Carlos O'Donell [Mon, 30 Jul 2018 20:20:00 +0000 (16:20 -0400)] 
Update translations for bg, de, hr, pt_BR, sv, and vi.

5 years agox86/CET: Fix property note parser [BZ #23467]
H.J. Lu [Mon, 30 Jul 2018 23:14:46 +0000 (16:14 -0700)] 
x86/CET: Fix property note parser [BZ #23467]

GNU_PROPERTY_X86_FEATURE_1_AND may not be the first property item.  We
need to check each property item until we reach the end of the property
or find GNU_PROPERTY_X86_FEATURE_1_AND.

This patch adds 2 tests.  The first test checks if IBT is enabled and
the second test reads the output from the first test to check if IBT
is is enabled.  The second second test fails if IBT isn't enabled
properly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ #23467]
* sysdeps/unix/sysv/linux/x86/Makefile (tests): Add
tst-cet-property-1 and tst-cet-property-2 if CET is enabled.
(CFLAGS-tst-cet-property-1.o): New.
(ASFLAGS-tst-cet-property-dep-2.o): Likewise.
($(objpfx)tst-cet-property-2): Likewise.
($(objpfx)tst-cet-property-2.out): Likewise.
* sysdeps/unix/sysv/linux/x86/tst-cet-property-1.c: New file.
* sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c: Likewise.
* sysdeps/unix/sysv/linux/x86/tst-cet-property-dep-2.S: Likewise.
* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Parse
each property item until GNU_PROPERTY_X86_FEATURE_1_AND is found.

5 years agox86: Add tst-get-cpu-features-static to $(tests) [BZ #23458]
H.J. Lu [Mon, 30 Jul 2018 23:11:05 +0000 (16:11 -0700)] 
x86: Add tst-get-cpu-features-static to $(tests) [BZ #23458]

All tests should be added to $(tests).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ #23458]
* sysdeps/x86/Makefile (tests): Add tst-get-cpu-features-static.

5 years agohurd: Fix some ld.so symbol override from libc
Samuel Thibault [Sat, 28 Jul 2018 13:12:42 +0000 (15:12 +0200)] 
hurd: Fix some ld.so symbol override from libc

ld.so symbols to be overriden by libc need to be extern to really get
overriden.

* sysdeps/mach/hurd/not-errno.h: New file.
* sysdeps/mach/hurd/i386/localplt.data: Update accordingly.

5 years agohurd: Fix some ld.so symbol override from libc
Samuel Thibault [Sat, 28 Jul 2018 12:57:10 +0000 (14:57 +0200)] 
hurd: Fix some ld.so symbol override from libc

ld.so symbols to be overriden by libc need to be extern to really get
overriden.

* sysdeps/mach/hurd/dl-unistd.h (__access, __brk, __lseek, __read,
__sbrk): Do not set attribute_hidden.
* sysdeps/mach/hurd/i386/ld.abilist: Update accordingly.
* sysdeps/mach/hurd/i386/localplt.data: Update accordingly.

5 years agoUpdate translations for cs, pl, and uk.
Carlos O'Donell [Sat, 28 Jul 2018 00:07:33 +0000 (20:07 -0400)] 
Update translations for cs, pl, and uk.

5 years agox86/CET: Don't parse beyond the note end
H.J. Lu [Fri, 27 Jul 2018 20:20:51 +0000 (13:20 -0700)] 
x86/CET: Don't parse beyond the note end

Simply check if "ptr < ptr_end" since "ptr" is always incremented by 8.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Don't
parse beyond the note end.

5 years agoUpdate NEWS with ISO 14651 update information.
Carlos O'Donell [Fri, 27 Jul 2018 19:56:24 +0000 (15:56 -0400)] 
Update NEWS with ISO 14651 update information.

5 years agoNEWS: Avoid the words "nominative" and "genitive".
Rafal Luzynski [Fri, 27 Jul 2018 09:27:48 +0000 (11:27 +0200)] 
NEWS: Avoid the words "nominative" and "genitive".

Glibc supports two grammatical forms of month names and we keep adding
the locale data which actually use this feature but those two forms are
not necessarily nominative and genitive.  It is better to use a more
generic term.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoFix Linux fcntl OFD locks on unsupported kernels
Adhemerval Zanella [Fri, 27 Jul 2018 13:07:14 +0000 (10:07 -0300)] 
Fix Linux fcntl OFD locks on unsupported kernels

This patch make the OFD tests return unsupported if kernel does not
support OFD locks (it was added on 3.15).

Checked on a ia64-linux-gnu with Linux 3.14.

* sysdeps/unix/sysv/linux/tst-ofdlocks.c: Return unsupported if
kernel does not support OFD locks.
* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.

5 years agoAdd the missing ChangeLog entry for commit be525a69a66
H.J. Lu [Fri, 27 Jul 2018 17:28:30 +0000 (10:28 -0700)] 
Add the missing ChangeLog entry for commit be525a69a66

5 years agohurd: Fix some ld.so symbol override from libc
Samuel Thibault [Fri, 27 Jul 2018 09:18:29 +0000 (11:18 +0200)] 
hurd: Fix some ld.so symbol override from libc

ld.so symbols to be overriden by libc need to be extern to really get
overriden.

More fixes are needed to avoid the hidden attribute.

* sysdeps/mach/hurd/Versions (libc): Make __access and
__access_noerrno external so they can override the ld symbols.
(ld): Make __access, __read, __sbrk, __strtoul_internal, __write,
__writev, __open64, __access_noerrno extern so they can be overrided.
* sysdeps/mach/hurd/i386/libc.abilist: Update accordingly.
* sysdeps/mach/hurd/i386/ld.abilist: Update accordingly.

5 years agoUpdate libc.pot.
Carlos O'Donell [Fri, 27 Jul 2018 02:21:34 +0000 (22:21 -0400)] 
Update libc.pot.

5 years agoUpdate powerpc-nofpu ulps.
Joseph Myers [Thu, 26 Jul 2018 22:51:06 +0000 (22:51 +0000)] 
Update powerpc-nofpu ulps.

* sysdeps/powerpc/nofpu/libm-test-ulps: Update.

5 years agox86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
H.J. Lu [Thu, 26 Jul 2018 17:49:19 +0000 (10:49 -0700)] 
x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ #23459]
* sysdeps/x86/cpu-features.c (get_extended_indices): New
function.
(init_cpu_features): Call get_extended_indices for both Intel
and AMD CPUs.
* sysdeps/x86/cpu-features.h (COMMON_CPUID_INDEX_80000001):
Remove "for AMD" comment.

5 years agox86: Correct index_cpu_LZCNT [BZ # 23456]
H.J. Lu [Thu, 26 Jul 2018 18:10:08 +0000 (11:10 -0700)] 
x86: Correct index_cpu_LZCNT [BZ # 23456]

cpu-features.h has

 #define bit_cpu_LZCNT (1 << 5)
 #define index_cpu_LZCNT COMMON_CPUID_INDEX_1
 #define reg_LZCNT

But the LZCNT feature bit is in COMMON_CPUID_INDEX_80000001:

Initial EAX Value: 80000001H
ECX Extended Processor Signature and Feature Bits:
Bit 05: LZCNT available

index_cpu_LZCNT should be COMMON_CPUID_INDEX_80000001, not
COMMON_CPUID_INDEX_1.  The VMX feature bit is in COMMON_CPUID_INDEX_1:

Initial EAX Value: 01H
Feature Information Returned in the ECX Register:
5 VMX

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ # 23456]
* sysdeps/x86/cpu-features.h (index_cpu_LZCNT): Set to
COMMON_CPUID_INDEX_80000001.

5 years agoFix string/tst-xbzero-opt if build with gcc head.
Stefan Liebler [Thu, 26 Jul 2018 15:09:44 +0000 (17:09 +0200)] 
Fix string/tst-xbzero-opt if build with gcc head.

On s390x, the test string/tst-xbzero-opt is failing if build with gcc head:
FAIL: no clear/prepare: expected 32 got 0
FAIL: no clear/test: expected some got 0
FAIL: ordinary clear/prepare: expected 32 got 0
INFO: ordinary clear/test: found 0 patterns (memset not eliminated)
PASS: explicit clear/prepare: expected 32 got 32
PASS: explicit clear/test: expected 0 got 0

In setup_no_clear / setup_ordinary_clear, GCC is omitting the memcpy loop
in prepare_test_buffer. Thus count_test_patterns does not find any of the
test_pattern.

This patch calls use_test_buffer in order to force the compiler to really copy
the pattern to buf.

ChangeLog:

* string/tst-xbzero-opt.c (use_test_buffer): New function.
(prepare_test_buffer): Call use_test_buffer as compiler barrier.

5 years agohtl: Use weak aliases for public symbols
Florian Weimer [Thu, 26 Jul 2018 06:34:05 +0000 (08:34 +0200)] 
htl: Use weak aliases for public symbols

Strong definitions of flockfile, funlockfile, ftrylockfile can conflict
with application symbols when linking statically.

5 years agoAdd missing localedata/en_US.UTF-8.in (Bug 23393).
Carlos O'Donell [Thu, 26 Jul 2018 01:58:10 +0000 (21:58 -0400)] 
Add missing localedata/en_US.UTF-8.in (Bug 23393).

Commit 7cd7d36f1feb3ccacf476e909b115b45cdd46e77 failed to include
the new testing file en_US.UTF-8.in.

5 years agoKeep expected behaviour for [a-z] and [A-z] (Bug 23393).
Carlos O'Donell [Wed, 25 Jul 2018 21:00:45 +0000 (17:00 -0400)] 
Keep expected behaviour for [a-z] and [A-z] (Bug 23393).

In commit 9479b6d5e08eacce06c6ab60abc9b2f4eb8b71e4 we updated all of
the collation data to harmonize with the new version of ISO 14651
which is derived from Unicode 9.0.0.  This collation update brought
with it some changes to locales which were not desirable by some
users, in particular it altered the meaning of the
locale-dependent-range regular expression, namely [a-z] and [A-Z], and
for en_US it caused uppercase letters to be matched by [a-z] for the
first time.  The matching of uppercase letters by [a-z] is something
which is already known to users of other locales which have this
property, but this change could cause significant problems to en_US
and other similar locales that had never had this change before.
Whether this behaviour is desirable or not is contentious and GNU Awk
has this to say on the topic:
https://www.gnu.org/software/gawk/manual/html_node/Ranges-and-Locales.html
While the POSIX standard also has this further to say: "RE Bracket
Expression":
http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html
"The current standard leaves unspecified the behavior of a range
expression outside the POSIX locale. ... As noted above, efforts were
made to resolve the differences, but no solution has been found that
would be specific enough to allow for portable software while not
invalidating existing implementations."
In glibc we implement the requirement of ISO POSIX-2:1993 and use
collation element order (CEO) to construct the range expression, the
API internally is __collseq_table_lookup().  The fact that we use CEO
and also have 4-level weights on each collation rule means that we can
in practice reorder the collation rules in iso14651_t1_common (the new
data) to provide consistent range expression resolution *and* the
weights should maintain the expected total order.  Therefore this
patch does three things:

* Reorder the collation rules for the LATIN script in
  iso14651_t1_common to deinterlace uppercase and lowercase letters in
  the collation element orders.

* Adds new test data en_US.UTF-8.in for sort-test.sh which exercises
  strcoll* and strxfrm* and ensures the ISO 14651 collation remains.

* Add back tests to tst-fnmatch.input and tst-regexloc.c which
  exercise that [a-z] does not match A or Z.

The reordering of the ISO 14651 data is done in an entirely mechanical
fashion using the following program attached to the bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=23393#c28

It is up for discussion if the iso14651_t1_common data should be
refined further to have 3 very tight collation element ranges that
include only a-z, A-Z, and 0-9, which would implement the solution
sought after in:
https://sourceware.org/bugzilla/show_bug.cgi?id=23393#c12
and implemented here:
https://www.sourceware.org/ml/libc-alpha/2018-07/msg00854.html

No regressions on x86_64.
Verified that removal of the iso14651_t1_common change causes tst-fnmatch
to regress with:
422: fnmatch ("[a-z]", "A", 0) = 0 (FAIL, expected FNM_NOMATCH) ***
...
425: fnmatch ("[A-Z]", "z", 0) = 0 (FAIL, expected FNM_NOMATCH) ***

5 years agoia64: Work around incorrect type of IA64 uc_sigmask
H.J. Lu [Wed, 25 Jul 2018 20:54:08 +0000 (13:54 -0700)] 
ia64: Work around incorrect type of IA64 uc_sigmask

Work around:

https://sourceware.org/bugzilla/show_bug.cgi?id=21634

* sysdeps/unix/sysv/linux/ia64/tst-setcontext4.c: New file.

5 years agoFix ISO C threads installed header and HURD assumption
Adhemerval Zanella [Wed, 25 Jul 2018 18:20:44 +0000 (15:20 -0300)] 
Fix ISO C threads installed header and HURD assumption

Set installed NPTL header as the expected one (instead of an
internal one for glibc testsuite) and add a hurd specific
stdc-predef with __STDC_NO_THREADS__.

Checked on both i686-linux-gnu and i686-gnu that both threads.h
and stdc-predef.h are the expected ones.

* nptl/threads.h: Move to ...
* sysdeps/nptl/threads.h: ... here.
* sysdeps/hurd/stdc-predef.h: New file.

5 years agox86/CET: Add a setcontext test for CET
H.J. Lu [Wed, 25 Jul 2018 15:40:39 +0000 (08:40 -0700)] 
x86/CET: Add a setcontext test for CET

Verify that setcontext works with gaps above and below the newly
allocated shadow stack.

* sysdeps/unix/sysv/linux/x86/Makefile (tests): Add
tst-cet-setcontext-1 if CET is enabled.
(CFLAGS-tst-cet-setcontext-1.c): Add -mshstk.
* sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c: New file.

5 years agoFix C11 conformance issues
Adhemerval Zanella [Wed, 25 Jul 2018 13:20:15 +0000 (13:20 +0000)] 
Fix C11 conformance issues

Remove conformace assumption of NPTL implementation for ISO C threads
and revert wrong libcrypt addition on linknamespace-libs-XPG4.

The i686-gnu target now shows two new conformance failures:

FAIL: conform/ISO11/threads.h/conform
FAIL: conform/ISO11/threads.h/linknamespace

It is expected due missing HTL ISO C threads support and both conformance
.out files indicates the reason ("#error "HTL does not implement ISO C
threads").

Checked on i686-linux-gnu and i686-gnu.

* include/threads.h: Move to ...
* sysdeps/nptl/threads.h: ... here.
* sysdeps/htl/threads.h: New file.
* conform/Makefile (linknamespace-libs-ISO11): Use
static-thread-library instead of linking libpthread.
(linknamespace-libs-XPG4): Revert wrong libcrypt.a addition.