platform/upstream/glibc.git
5 years agoFix new file header
Samuel Thibault [Thu, 19 Jul 2018 23:44:58 +0000 (01:44 +0200)]
Fix new file header

5 years agohurd: Implement pipe2
Thomas Schwinge [Thu, 19 Jul 2018 23:29:55 +0000 (01:29 +0200)]
hurd: Implement pipe2

* sysdeps/mach/hurd/pipe2.c: New file, copy from pipe.c.  Evolve it to
implement __pipe2.
* sysdeps/mach/hurd/pipe.c (__pipe): Reimplement using __pipe2.

5 years agohurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socketpair
Thomas Schwinge [Thu, 19 Jul 2018 23:24:41 +0000 (01:24 +0200)]
hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socketpair

* sysdeps/mach/hurd/socketpair.c (__socketpair): Handle SOCK_CLOEXEC
and SOCK_NONBLOCK.

5 years agohurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socket
Thomas Schwinge [Thu, 19 Jul 2018 23:22:12 +0000 (01:22 +0200)]
hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socket

* sysdeps/mach/hurd/socket.c (__socket): Handle SOCK_CLOEXEC and
SOCK_NONBLOCK.

5 years agohurd: Enable thread-safe i386 atomic instructions
Samuel Thibault [Thu, 19 Jul 2018 23:12:08 +0000 (01:12 +0200)]
hurd: Enable thread-safe i386 atomic instructions

* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Set multiple_threads
to 1.

5 years agobenchtests: improve argument parsing through argparse library
Leonardo Sandoval [Fri, 13 Jul 2018 15:45:40 +0000 (10:45 -0500)]
benchtests: improve argument parsing through argparse library

The argparse library is used on compare_bench script to improve command line
argument parsing. The 'schema validation file' is now optional, reducing by
one the number of required parameters.

* benchtests/scripts/compare_bench.py (__main__): use the argparse
library to improve command line parsing.
(__main__): make schema file as optional parameter (--schema),
defaulting to benchtests/scripts/benchout.schema.json.
(main): move out of the parsing stuff to __main_  and leave it
only as caller of main comparison functions.

5 years agoINSTALL: Add a note for Intel CET status
H.J. Lu [Thu, 19 Jul 2018 19:04:56 +0000 (12:04 -0700)]
INSTALL: Add a note for Intel CET status

* NEWS: Add a note for Intel CET status.
* manual/install.texi: Likewise.
* INSTALL: Regenerated.

6 years agooc_FR locale: Multiple updates (bug 23140, bug 23422).
Quentin PAGÈS [Sat, 19 May 2018 15:59:08 +0000 (17:59 +0200)]
oc_FR locale: Multiple updates (bug 23140, bug 23422).

Multiple updates for Occitan language including alternative month names,
update abday and abmon, fix typos in day, fix d_fmt, correct LC_NAME,
and use “copy "ca_ES"” as LC_COLLATE.

[BZ #23140]
* localedata/locales/oc_FR (mon): Rename to...
(alt_mon): This, then update October (typo fix).
(mon): New content (genitive case, month names preceded by
"de" or "d’").

[BZ #23422]
* localedata/locales/oc_FR (abday): Update all items.
(day): Update Wednesday and Saturday (typo fixes).
(abmon): Update all items, except May.
(d_fmt): Update "%d.%m.%Y" -> "%d/%m/%Y".
(LC_IDENTIFICATION): Bump the revision number and date.
Keep the "category" entries in alphabetic order.
(LC_ADDRESS): Remove no longer needed comment.
(LC_COLLATE): Use “copy "ca_ES"”.
(LC_NAME): Set the correct values of "name_fmt", "name_mr", and
"name_mrs".

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoAvoid insecure usage of tmpnam in tests.
Joseph Myers [Wed, 18 Jul 2018 21:04:12 +0000 (21:04 +0000)]
Avoid insecure usage of tmpnam in tests.

Various glibc testcases use tmpnam in ways subject to race conditions
(generate a temporary file name, then later open that file without
O_EXCL).

This patch fixes those tests to use mkstemp - generally a minimal
local fix to use mkstemp instead of tmpnam, rather than a larger fix
to use other testsuite infrastructure for temporary files.  The
unchanged use of tmpnam in posix/wordexp-test.c would fail safe in the
event of a race (it's generating a name for use with mkdir rather than
for a file to be opened for writing).

Tested for x86_64.

* grp/tst_fgetgrent.c: Include <unistd.h>.
(main): Use mkstemp instead of tmpnam.
* io/test-utime.c (main): Likewise.
* posix/annexc.c (macrofile): Change to modifiable array.
(get_null_defines): Use mkstemp instead of tmpnam.  Do not remove
macrofile here.
* posix/bug-getopt1.c: Include <stdlib.h>.
(do_test): Use mkstemp instead of tmpnam.
* posix/bug-getopt2.c: Include <stdlib.h>.
(do_test): Use mkstemp instead of tmpnam.
* posix/bug-getopt3.c: Include <stdlib.h>.
(do_test): Use mkstemp instead of tmpnam.
* posix/bug-getopt4.c: Include <stdlib.h>.
(do_test): Use mkstemp instead of tmpnam.
* posix/bug-getopt5.c: Include <stdlib.h>.
(do_test): Use mkstemp instead of tmpnam.
* stdio-common/bug7.c: Include <stdlib.h> and <unistd.h>.
(main): Use mkstemp instead of tmpnam.
* stdio-common/tst-fdopen.c: Include <stdlib.h>.
(main): Use mkstemp instead of tmpnam.
* stdio-common/tst-ungetc.c: Include <stdlib.h>.
(main): use mkstemp instead of tmpnam.
* stdlib/isomac.c (macrofile): Change to modifiable array.
(get_null_defines): Use mkstemp instead of tmpnam.  Do not remove
macrofile here.

6 years agox86/CET: Document glibc.tune.x86_ibt and glibc.tune.x86_shstk
H.J. Lu [Wed, 18 Jul 2018 18:34:35 +0000 (11:34 -0700)]
x86/CET: Document glibc.tune.x86_ibt and glibc.tune.x86_shstk

* manual/tunables.texi: Document glibc.tune.x86_ibt and
glibc.tune.x86_shstk.

6 years agoIntel CET: Document --enable-cet
H.J. Lu [Wed, 18 Jul 2018 16:52:40 +0000 (09:52 -0700)]
Intel CET: Document --enable-cet

* NEWS: Mention --enable-cet.
* manual/install.texi: Document --enable-cet.
* INSTALL: Regenerated.

6 years agox86-64: Use _CET_NOTRACK in memcmp-sse4.S
H.J. Lu [Wed, 18 Jul 2018 15:07:24 +0000 (08:07 -0700)]
x86-64: Use _CET_NOTRACK in memcmp-sse4.S

* sysdeps/x86_64/multiarch/memcmp-sse4.S (BRANCH_TO_JMPTBL_ENTRY):
Add _CET_NOTRACK before indirect jump to jump table.

6 years agoi386: Use _CET_NOTRACK in memset-sse2-rep.S
H.J. Lu [Wed, 18 Jul 2018 15:04:04 +0000 (08:04 -0700)]
i386: Use _CET_NOTRACK in memset-sse2-rep.S

* sysdeps/i386/i686/multiarch/memset-sse2-rep.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.

6 years agoi386: Use _CET_NOTRACK in strcat-sse2.S
H.J. Lu [Wed, 18 Jul 2018 15:03:07 +0000 (08:03 -0700)]
i386: Use _CET_NOTRACK in strcat-sse2.S

* sysdeps/i386/i686/multiarch/strcat-sse2.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.

6 years agoi386: Use _CET_NOTRACK in strcpy-sse2.S
H.J. Lu [Wed, 18 Jul 2018 15:02:15 +0000 (08:02 -0700)]
i386: Use _CET_NOTRACK in strcpy-sse2.S

* sysdeps/i386/i686/multiarch/strcpy-sse2.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.

6 years agoi386: Use _CET_NOTRACK in memcpy-ssse3.S
H.J. Lu [Wed, 18 Jul 2018 15:00:49 +0000 (08:00 -0700)]
i386: Use _CET_NOTRACK in memcpy-ssse3.S

* sysdeps/i386/i686/multiarch/memcpy-ssse3.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.

6 years agoi386: Use _CET_NOTRACK in memcpy-ssse3-rep.S
H.J. Lu [Wed, 18 Jul 2018 14:59:54 +0000 (07:59 -0700)]
i386: Use _CET_NOTRACK in memcpy-ssse3-rep.S

* sysdeps/i386/i686/multiarch/memcpy-ssse3-rep.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.
(BRANCH_TO_JMPTBL_ENTRY_TAIL): Likewise.

6 years agoi386: Use _CET_NOTRACK in memcmp-sse4.S
H.J. Lu [Wed, 18 Jul 2018 14:58:53 +0000 (07:58 -0700)]
i386: Use _CET_NOTRACK in memcmp-sse4.S

* sysdeps/i386/i686/multiarch/memcmp-sse4.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.

6 years agoi386: Use _CET_NOTRACK in memset-sse2.S
H.J. Lu [Wed, 18 Jul 2018 14:57:50 +0000 (07:57 -0700)]
i386: Use _CET_NOTRACK in memset-sse2.S

* sysdeps/i386/i686/multiarch/memset-sse2.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.

6 years agoi386: Use _CET_NOTRACK in i686/memcmp.S
H.J. Lu [Wed, 18 Jul 2018 14:54:45 +0000 (07:54 -0700)]
i386: Use _CET_NOTRACK in i686/memcmp.S

* sysdeps/i386/i686/memcmp.S (memcmp): Add _CET_NOTRACK before
indirect jump to jump table.

6 years agox86-64: Use _CET_NOTRACK in memcpy-ssse3.S
H.J. Lu [Wed, 18 Jul 2018 13:39:32 +0000 (06:39 -0700)]
x86-64: Use _CET_NOTRACK in memcpy-ssse3.S

* sysdeps/x86_64/multiarch/memcpy-ssse3.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.
(MEMCPY): Likewise.

6 years agox86-64: Use _CET_NOTRACK in memcpy-ssse3-back.S
H.J. Lu [Wed, 18 Jul 2018 13:38:10 +0000 (06:38 -0700)]
x86-64: Use _CET_NOTRACK in memcpy-ssse3-back.S

* sysdeps/x86_64/multiarch/memcpy-ssse3-back.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.
(MEMCPY): Likewise.

6 years agox86-64: Use _CET_NOTRACK in strcmp-sse42.S
H.J. Lu [Wed, 18 Jul 2018 13:36:06 +0000 (06:36 -0700)]
x86-64: Use _CET_NOTRACK in strcmp-sse42.S

* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
_CET_NOTRACK before indirect jump to jump table.

6 years agox86-64: Use _CET_NOTRACK in strcpy-sse2-unaligned.S
H.J. Lu [Wed, 18 Jul 2018 13:32:54 +0000 (06:32 -0700)]
x86-64: Use _CET_NOTRACK in strcpy-sse2-unaligned.S

* sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
to jump table.

6 years agox86_64: Use _CET_NOTRACK in strcmp.S
H.J. Lu [Wed, 18 Jul 2018 13:29:21 +0000 (06:29 -0700)]
x86_64: Use _CET_NOTRACK in strcmp.S

* sysdeps/x86_64/strcmp.S (STRCMP): Add _CET_NOTRACK before
indirect jump to jump table.

6 years agoNew locale: Yakut (Sakha) for Russia (sah_RU) [BZ #22241]
Valery Timiriliyev [Fri, 6 Jul 2018 05:46:13 +0000 (14:46 +0900)]
New locale: Yakut (Sakha) for Russia (sah_RU) [BZ #22241]

* localedata/Makefile (test-input): Add sah_RU.UTF-8.
(LOCALES): Likewise.
* localedata/SUPPORTED (sah_RU/UTF-8): New entry.
* localedata/locales/sah_RU: New file.
* localedata/sah_RU.UTF-8.in: New file.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoi386: Add _CET_ENDBR to indirect jump targets in add_n.S/sub_n.S
H.J. Lu [Tue, 17 Jul 2018 23:11:13 +0000 (16:11 -0700)]
i386: Add _CET_ENDBR to indirect jump targets in add_n.S/sub_n.S

i386 add_n.S and sub_n.S use a trick to implment jump tables with LEA.
We can't use conditional branches nor normal jump tables since jump
table entries use EFLAGS set by jump table index.  This patch adds
_CET_ENDBR to indirect jump targets and adjust destination for
_CET_ENDBR.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysdeps/i386/add_n.S: Include <sysdep.h>, instead of
"sysdep.h".
(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
_CET_ENDBR to indirect jump targets and adjust jump destination
for _CET_ENDBR.
* sysdeps/i386/i686/add_n.S: Include <sysdep.h>, instead of
"sysdep.h".
(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
_CET_ENDBR to indirect jump targets and adjust jump destination
for _CET_ENDBR.
* sysdeps/i386/sub_n.S: Include <sysdep.h>, instead of
"sysdep.h".
(__mpn_sub_n): Save and restore %ebx if IBT is enabed.  Add
_CET_ENDBR to indirect jump targets and adjust jump destination
for _CET_ENDBR.

6 years agox86-64: Add _CET_ENDBR to STRCMP_SSE42
H.J. Lu [Tue, 17 Jul 2018 23:08:35 +0000 (16:08 -0700)]
x86-64: Add _CET_ENDBR to STRCMP_SSE42

Add _CET_ENDBR to STRCMP_SSE42, which is called indirectly, to support
IBT.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
_CET_ENDBR.

6 years agox86: Add _CET_ENDBR to functions in dl-tlsdesc.S
H.J. Lu [Tue, 17 Jul 2018 23:07:03 +0000 (16:07 -0700)]
x86: Add _CET_ENDBR to functions in dl-tlsdesc.S

Add _CET_ENDBR to functions in dl-tlsdesc.S, which are called indirectly,
to support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysdeps/i386/dl-tlsdesc.S (_dl_tlsdesc_return): Add
_CET_ENDBR.
(_dl_tlsdesc_undefweak): Likewise.
(_dl_tlsdesc_dynamic): Likewise.
(_dl_tlsdesc_resolve_abs_plus_addend): Likewise.
(_dl_tlsdesc_resolve_rel): Likewise.
(_dl_tlsdesc_resolve_rela): Likewise.
(_dl_tlsdesc_resolve_hold): Likewise.
* sysdeps/x86_64/dl-tlsdesc.S (_dl_tlsdesc_return): Likewise.
(_dl_tlsdesc_undefweak): Likewise.
(_dl_tlsdesc_dynamic): Likewise.
(_dl_tlsdesc_resolve_rela): Likewise.
(_dl_tlsdesc_resolve_hold): Likewise.

6 years agox86: Add _CET_ENDBR to functions in crti.S
H.J. Lu [Tue, 17 Jul 2018 23:04:41 +0000 (16:04 -0700)]
x86: Add _CET_ENDBR to functions in crti.S

Add _CET_ENDBR to functions in crti.S, which are called indirectly, to
support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
(_fini): Likewise.
* sysdeps/x86_64/crti.S (_init): Likewise.
(_fini): Likewise.

6 years agoos_RU: Add alternative month names (bug 23140).
Rafal Luzynski [Tue, 30 Jan 2018 11:31:12 +0000 (12:31 +0100)]
os_RU: Add alternative month names (bug 23140).

[BZ #23140]
* localedata/locales/os_RU (mon): Rename to...
(alt_mon): This.
(mon): Import from CLDR (genitive case).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agox86: Always include <dl-cet.h>/cet-tunables.h> for --enable-cet
H.J. Lu [Tue, 17 Jul 2018 11:16:19 +0000 (04:16 -0700)]
x86: Always include <dl-cet.h>/cet-tunables.h> for --enable-cet

Always include <dl-cet.h> and cet-tunables.h> when CET is enabled.
Otherwise, configure glibc with --enable-cet --disable-tunables will
fail to build.

* sysdeps/x86/cpu-features.c: Always include <dl-cet.h> and
cet-tunables.h> when CET is enabled.

6 years agox86: Support IBT and SHSTK in Intel CET [BZ #21598]
H.J. Lu [Mon, 16 Jul 2018 21:08:15 +0000 (14:08 -0700)]
x86: Support IBT and SHSTK in Intel CET [BZ #21598]

Intel Control-flow Enforcement Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-en
forcement-technology-preview.pdf

includes Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK).

GNU_PROPERTY_X86_FEATURE_1_IBT is added to GNU program property to
indicate that all executable sections are compatible with IBT when
ENDBR instruction starts each valid target where an indirect branch
instruction can land.  Linker sets GNU_PROPERTY_X86_FEATURE_1_IBT on
output only if it is set on all relocatable inputs.

On an IBT capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable IBT and
lock IBT if GNU_PROPERTY_X86_FEATURE_1_IBT is set on the executable.
2. When loading an executable with an interpreter, enable IBT if
GNU_PROPERTY_X86_FEATURE_1_IBT is set on the interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_IBT isn't set on the executable,
     disable IBT.
  b. Lock IBT.
3. If IBT is enabled, when loading a shared object without
GNU_PROPERTY_X86_FEATURE_1_IBT:
  a. If legacy interwork is allowed, then mark all pages in executable
     PT_LOAD segments in legacy code page bitmap.  Failure of legacy code
     page bitmap allocation causes an error.
  b. If legacy interwork isn't allowed, it causes an error.

GNU_PROPERTY_X86_FEATURE_1_SHSTK is added to GNU program property to
indicate that all executable sections are compatible with SHSTK where
return address popped from shadow stack always matches return address
popped from normal stack.  Linker sets GNU_PROPERTY_X86_FEATURE_1_SHSTK
on output only if it is set on all relocatable inputs.

On a SHSTK capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on the executable.
2. When loading an executable with an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_SHSTK isn't set on the executable
     or any shared objects loaded via the DT_NEEDED tag, disable SHSTK.
  b. Otherwise lock SHSTK.
3. After SHSTK is enabled, it is an error to load a shared object
without GNU_PROPERTY_X86_FEATURE_1_SHSTK.

To enable CET support in glibc, --enable-cet is required to configure
glibc.  When CET is enabled, both compiler and assembler must support
CET.  Otherwise, it is a configure-time error.

To support CET run-time control,

1. _dl_x86_feature_1 is added to the writable ld.so namespace to indicate
if IBT or SHSTK are enabled at run-time.  It should be initialized by
init_cpu_features.
2. For dynamic executables:
   a. A l_cet field is added to struct link_map to indicate if IBT or
      SHSTK is enabled in an ELF module.  _dl_process_pt_note or
      _rtld_process_pt_note is called to process PT_NOTE segment for
      GNU program property and set l_cet.
   b. _dl_open_check is added to check IBT and SHSTK compatibilty when
      dlopening a shared object.
3. Replace i386 _dl_runtime_resolve and _dl_runtime_profile with
_dl_runtime_resolve_shstk and _dl_runtime_profile_shstk, respectively if
SHSTK is enabled.

CET run-time control can be changed via GLIBC_TUNABLES with

$ export GLIBC_TUNABLES=glibc.tune.x86_shstk=[permissive|on|off]
$ export GLIBC_TUNABLES=glibc.tune.x86_ibt=[permissive|on|off]

1. permissive: SHSTK is disabled when dlopening a legacy ELF module.
2. on: IBT or SHSTK are always enabled, regardless if there are IBT or
SHSTK bits in GNU program property.
3. off: IBT or SHSTK are always disabled, regardless if there are IBT or
SHSTK bits in GNU program property.

<cet.h> from CET-enabled GCC is automatically included by assembly codes
to add GNU_PROPERTY_X86_FEATURE_1_IBT and GNU_PROPERTY_X86_FEATURE_1_SHSTK
to GNU program property.  _CET_ENDBR is added at the entrance of all
assembly functions whose address may be taken.  _CET_NOTRACK is used to
insert NOTRACK prefix with indirect jump table to support IBT.  It is
defined as notrack when _CET_NOTRACK is defined in <cet.h>.

 [BZ #21598]
* configure.ac: Add --enable-cet.
* configure: Regenerated.
* elf/Makefille (all-built-dso): Add a comment.
* elf/dl-load.c (filebuf): Moved before "dynamic-link.h".
Include <dl-prop.h>.
(_dl_map_object_from_fd): Call _dl_process_pt_note on PT_NOTE
segment.
* elf/dl-open.c: Include <dl-prop.h>.
(dl_open_worker): Call _dl_open_check.
* elf/rtld.c: Include <dl-prop.h>.
(dl_main): Call _rtld_process_pt_note on PT_NOTE segment.  Call
_rtld_main_check.
* sysdeps/generic/dl-prop.h: New file.
* sysdeps/i386/dl-cet.c: Likewise.
* sysdeps/unix/sysv/linux/x86/cpu-features.c: Likewise.
* sysdeps/unix/sysv/linux/x86/dl-cet.h: Likewise.
* sysdeps/x86/cet-tunables.h: Likewise.
* sysdeps/x86/check-cet.awk: Likewise.
* sysdeps/x86/configure: Likewise.
* sysdeps/x86/configure.ac: Likewise.
* sysdeps/x86/dl-cet.c: Likewise.
* sysdeps/x86/dl-procruntime.c: Likewise.
* sysdeps/x86/dl-prop.h: Likewise.
* sysdeps/x86/libc-start.h: Likewise.
* sysdeps/x86/link_map.h: Likewise.
* sysdeps/i386/dl-trampoline.S (_dl_runtime_resolve): Add
_CET_ENDBR.
(_dl_runtime_profile): Likewise.
(_dl_runtime_resolve_shstk): New.
(_dl_runtime_profile_shstk): Likewise.
* sysdeps/linux/x86/Makefile (sysdep-dl-routines): Add dl-cet
if CET is enabled.
(CFLAGS-.o): Add -fcf-protection if CET is enabled.
(CFLAGS-.os): Likewise.
(CFLAGS-.op): Likewise.
(CFLAGS-.oS): Likewise.
(asm-CPPFLAGS): Add -fcf-protection -include cet.h if CET
is enabled.
(tests-special): Add $(objpfx)check-cet.out.
(cet-built-dso): New.
(+$(cet-built-dso:=.note)): Likewise.
(common-generated): Add $(cet-built-dso:$(common-objpfx)%=%.note).
($(objpfx)check-cet.out): New.
(generated): Add check-cet.out.
* sysdeps/x86/cpu-features.c: Include <dl-cet.h> and
<cet-tunables.h>.
(TUNABLE_CALLBACK (set_x86_ibt)): New prototype.
(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
(init_cpu_features): Call get_cet_status to check CET status
and update dl_x86_feature_1 with CET status.  Call
TUNABLE_CALLBACK (set_x86_ibt) and TUNABLE_CALLBACK
(set_x86_shstk).  Disable and lock CET in libc.a.
* sysdeps/x86/cpu-tunables.c: Include <cet-tunables.h>.
(TUNABLE_CALLBACK (set_x86_ibt)): New function.
(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
* sysdeps/x86/sysdep.h (_CET_NOTRACK): New.
(_CET_ENDBR): Define if not defined.
(ENTRY): Add _CET_ENDBR.
* sysdeps/x86/dl-tunables.list (glibc.tune): Add x86_ibt and
x86_shstk.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Add
_CET_ENDBR.
(_dl_runtime_profile): Likewise.

6 years agopowerpc64: Always restore TOC on longjmp [BZ #21895]
Rogerio Alves [Mon, 16 Jul 2018 18:07:10 +0000 (15:07 -0300)]
powerpc64: Always restore TOC on longjmp [BZ #21895]

This patch changes longjmp to always restore the TOC pointer (r2 register)
to the caller frame on powerpc64 and powerpc64le.  This is related to bug
21895 that reports a situation where you have a static longjmp to a
shared object file.

[BZ #21895]
* sysdeps/powerpc/powerpc64/__longjmp-common.S: Remove condition code for
restoring r2 in longjmp.
* sysdeps/powerpc/powerpc64/Makefile: Added tst-setjmp-bug21895-static to
test list.
Added rules to build test tst-setjmp-bug21895-static.
Added module setjmp-bug21895 and rules to build a shared object from it.
* sysdeps/powerpc/powerpc64/setjmp-bug21895.c: New test file.
* sysdeps/powerpc/powerpc64/tst-setjmp-bug21895-static.c: New test file.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
6 years agoImprove strstr performance
Wilco Dijkstra [Mon, 16 Jul 2018 16:50:09 +0000 (17:50 +0100)]
Improve strstr performance

Improve strstr performance.  Strstr tends to be slow because it uses
many calls to memchr and a slow byte loop to scan for the next match.
Performance is significantly improved by using strnlen on larger blocks
and using strchr to search for the next matching character.  strcasestr
can also use strnlen to scan ahead, and memmem can use memchr to check
for the next match.

On the GLIBC bench tests the performance gains on Cortex-A72 are:
strstr: +25%
strcasestr: +4.3%
memmem: +18%

On a 256KB dataset strstr performance improves by 67%, strcasestr by 47%.

Reviewd-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 years agox86_64: Undef SHADOW_STACK_POINTER_OFFSET last
H.J. Lu [Sun, 15 Jul 2018 15:48:40 +0000 (08:48 -0700)]
x86_64: Undef SHADOW_STACK_POINTER_OFFSET last

Since SHADOW_STACK_POINTER_OFFSET is defined in jmp_buf-ssp.h, we must
undef SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.

* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Undef
SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.

6 years agox86: Support shadow stack pointer in setjmp/longjmp
H.J. Lu [Sat, 14 Jul 2018 12:59:29 +0000 (05:59 -0700)]
x86: Support shadow stack pointer in setjmp/longjmp

Save and restore shadow stack pointer in setjmp and longjmp to support
shadow stack in Intel CET.  Use feature_1 in tcbhead_t to check if
shadow stack is enabled before saving and restoring shadow stack pointer.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysdeps/i386/__longjmp.S: Include <jmp_buf-ssp.h>.
(__longjmp): Restore shadow stack pointer if shadow stack is
enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
isn't defined for __longjmp_cancel.
* sysdeps/i386/bsd-_setjmp.S: Include <jmp_buf-ssp.h>.
(_setjmp): Save shadow stack pointer if shadow stack is enabled
and SHADOW_STACK_POINTER_OFFSET is defined.
* sysdeps/i386/bsd-setjmp.S: Include <jmp_buf-ssp.h>.
(setjmp): Save shadow stack pointer if shadow stack is enabled
and SHADOW_STACK_POINTER_OFFSET is defined.
* sysdeps/i386/setjmp.S: Include <jmp_buf-ssp.h>.
(__sigsetjmp): Save shadow stack pointer if shadow stack is
enabled and SHADOW_STACK_POINTER_OFFSET is defined.
* sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: Include
<jmp_buf-ssp.h>.
(____longjmp_chk): Restore shadow stack pointer if shadow stack
is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
* sysdeps/unix/sysv/linux/x86/Makefile (gen-as-const-headers):
Remove jmp_buf-ssp.sym.
* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Include
<jmp_buf-ssp.h>.
(____longjmp_chk): Restore shadow stack pointer if shadow stack
is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
* sysdeps/x86/Makefile (gen-as-const-headers): Add
jmp_buf-ssp.sym.
* sysdeps/x86/jmp_buf-ssp.sym: New dummy file.
* sysdeps/x86_64/__longjmp.S: Include <jmp_buf-ssp.h>.
(__longjmp): Restore shadow stack pointer if shadow stack is
enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
isn't defined for __longjmp_cancel.
* sysdeps/x86_64/setjmp.S: Include <jmp_buf-ssp.h>.
(__sigsetjmp): Save shadow stack pointer if shadow stack is
enabled and SHADOW_STACK_POINTER_OFFSET is defined.

6 years agox86: Rename __glibc_reserved1 to feature_1 in tcbhead_t [BZ #22563]
H.J. Lu [Sat, 14 Jul 2018 12:53:05 +0000 (05:53 -0700)]
x86: Rename __glibc_reserved1 to feature_1 in tcbhead_t [BZ #22563]

feature_1 has X86_FEATURE_1_IBT and X86_FEATURE_1_SHSTK bits for CET
run-time control.

CET_ENABLED, IBT_ENABLED and SHSTK_ENABLED are defined to 1 or 0 to
indicate that if CET, IBT and SHSTK are enabled.

<tls-setup.h> is added to set up thread-local data.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ #22563]
* nptl/pthread_create.c: Include <tls-setup.h>.
(__pthread_create_2_1): Call tls_setup_tcbhead.
* sysdeps/generic/tls-setup.h: New file.
* sysdeps/x86/nptl/tls-setup.h: Likewise.
* sysdeps/i386/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
* sysdeps/x86_64/nptl/tcb-offsets.sym (FEATURE_1_OFFSET):
Likewise.
* sysdeps/i386/nptl/tls.h (tcbhead_t): Rename __glibc_reserved1
to feature_1.
* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Likewise.
* sysdeps/x86/sysdep.h (X86_FEATURE_1_IBT): New.
(X86_FEATURE_1_SHSTK): Likewise.
(CET_ENABLED): Likewise.
(IBT_ENABLED): Likewise.
(SHSTK_ENABLED): Likewise.

6 years agodsb_DE locale: Fix syntax error and add tests (bug 23208).
Rafal Luzynski [Wed, 11 Jul 2018 21:25:15 +0000 (23:25 +0200)]
dsb_DE locale: Fix syntax error and add tests (bug 23208).

Fixed syntax error in the collation rules of Lower Sorbian language.
Collation test added in order to test the bugs like this early.

Reported-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
[BZ #23208]
* localedata/Makefile (test-input): Add dsb_DE.UTF-8.
(LOCALES): Likewise.
* localedata/dsb_DE.UTF-8.in: New file.
* localedata/locales/dsb_DE (LC_COLLATE): Fix syntax error.

6 years agonptl: Use __mprotect consistently for _STACK_GROWS_UP
Florian Weimer [Thu, 12 Jul 2018 13:01:43 +0000 (15:01 +0200)]
nptl: Use __mprotect consistently for _STACK_GROWS_UP

6 years agoInstall <bits/statx.h> header
Florian Weimer [Wed, 11 Jul 2018 06:59:51 +0000 (08:59 +0200)]
Install <bits/statx.h> header

6 years agoPut the correct Unicode version number 11.0.0 into the generated files
Mike FABIAN [Tue, 10 Jul 2018 09:25:48 +0000 (11:25 +0200)]
Put the correct Unicode version number 11.0.0 into the generated files

In some places there was still the old Unicode version 10.0.0 in the files.

* localedata/charmaps/UTF-8: Use correct Unicode version 11.0.0 in comment.
* localedata/locales/i18n_ctype: Use correct Unicode version in comments
and headers.
* localedata/unicode-gen/utf8_gen.py: Add option to specify Unicode version
* localedata/unicode-gen/Makefile: Use option to specify Unicode version
for utf8_gen.py

6 years agoAdd the statx function
Florian Weimer [Tue, 10 Jul 2018 14:14:45 +0000 (16:14 +0200)]
Add the statx function

6 years agoComment tst-ofdlocks-compat expected failure in some Linux releases
Adhemerval Zanella [Tue, 10 Jul 2018 12:24:40 +0000 (09:24 -0300)]
Comment tst-ofdlocks-compat expected failure in some Linux releases

As pointed out in a libc-alpha thread [1], the misc/tst-ofdlocks-compat
may fail in some specific Linux releases.  This patch adds a comment
along with a link to discussion in the test source code.

No changes are expected.

* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Add a comment about
a kernel issue which lead to test failure in some cases.

[1] https://sourceware.org/ml/libc-alpha/2018-07/msg00243.html

6 years agoregexec: Fix off-by-one bug in weight comparison [BZ #23036]
Florian Weimer [Tue, 10 Jul 2018 09:18:26 +0000 (11:18 +0200)]
regexec: Fix off-by-one bug in weight comparison [BZ #23036]

Each weight is prefixed by its length, and the length does not include
itself in the count.  This can be seen clearly from the find_idx
function in string/strxfrm_l.c, for example.  The old code behaved as if
the length itself counted, thus comparing an additional byte after the
weight, leading to spurious comparison failures and incorrect further
partitioning of character equivalence classes.

6 years agoFix copyright years in recent commits
Florian Weimer [Tue, 10 Jul 2018 09:03:08 +0000 (11:03 +0200)]
Fix copyright years in recent commits

6 years agonss_files: Fix re-reading of long lines [BZ #18991]
Florian Weimer [Fri, 6 Jul 2018 12:23:15 +0000 (14:23 +0200)]
nss_files: Fix re-reading of long lines [BZ #18991]

Use the new __libc_readline_unlocked function to pick up
reading at the same line in case the buffer needs to be enlarged.

6 years agolibio: Implement internal function __libc_readline_unlocked
Florian Weimer [Fri, 6 Jul 2018 14:53:48 +0000 (16:53 +0200)]
libio: Implement internal function __libc_readline_unlocked

This is a variant of fgets which fails with ERANGE if the
buffer is too small, and the buffer length is given as an
argument of type size_t.

This function will be useful for implementing NSS file reading
operations.  Compared to a direct implementation using the public API,
it avoids an lseek system call in case the line terminator can be
found in the internal read buffer.

6 years agoaarch64: add HWCAP_ATOMICS to HWCAP_IMPORTANT
Szabolcs Nagy [Thu, 28 Jun 2018 14:30:32 +0000 (15:30 +0100)]
aarch64: add HWCAP_ATOMICS to HWCAP_IMPORTANT

This enables searching shared libraries in atomics/ when the hardware
supports LSE atomics of armv8.1 so one can provide optimized variants
of libraries in a portable way.

LSE atomics does not affect library abi, the new instructions can
interoperate with old ones.

I considered the earlier comments on the patch

https://sourceware.org/ml/libc-alpha/2018-04/msg00400.html
https://sourceware.org/ml/libc-alpha/2018-04/msg00625.html

It turns out that the way glibc dynamic linker decides on the search
path is not very flexible: it wants to use hwcap bits and associated
strings.  So some targets reuse hwcap bits for glibc internal purposes
to affect the search logic.  But hwcap is an interface with the kernel,
glibc should not allocate bits in it for its internal logic as that
limits future hwcap extensions and confusing to users who expect to see
hwcap bits in ifunc resolvers.  Instead of rewriting the dynamic linker
path logic (which affects all targets) this patch just uses the existing
mechanism, however this means that the path name has to be the hwcap
name "atomics" and cannot be changed to something more meaningful to
users.

It is hard to tell how much performance benefit this can give, in
principle armv8.1 atomics can be better optimized in the hardware, so it
can make a difference for synchronization heavy code.  On some systems
such multilib setup may be the only viable way to get optimized
libraries used.

* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT): Add
HWCAP_ATOMICS.

6 years agoaarch64: Remove HWCAP_CPUID from HWCAP_IMPORTANT
Szabolcs Nagy [Thu, 28 Jun 2018 13:43:07 +0000 (14:43 +0100)]
aarch64: Remove HWCAP_CPUID from HWCAP_IMPORTANT

This partially reverts

commit f82e9672ad89ea1ef40bbe1af71478e255e87c5e
Author:     Siddhesh Poyarekar <siddhesh@sourceware.org>

    aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASK

The idea was to make it possible to disable cpuid based ifunc resolution
in glibc by changing the hwcap mask which the user could already control.

However the hwcap mask has an orthogonal role: it specifies additional
library search paths for the dynamic linker.  So "cpuid" got added to
the search paths when it was set in the default mask (HWCAP_IMPORTANT),
which is not useful behaviour, the hwcap masking should not be reused
in the cpu features code.

Meanwhile there is a tunable to set the cpu explicitly so it is possible
to disable the cpuid based dispatch without using a hwcap mask:

  GLIBC_TUNABLES=glibc.tune.cpu=generic

* sysdeps/unix/sysv/linux/aarch64/cpu-features.c (init_cpu_features):
Use dl_hwcap without masking.
* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT):
Remove HWCAP_CPUID.

6 years agoconform/conformtest.pl: Escape literal braces in regular expressions
Florian Weimer [Fri, 6 Jul 2018 14:31:24 +0000 (16:31 +0200)]
conform/conformtest.pl: Escape literal braces in regular expressions

This suppresses Perl warnings like these:

Unescaped left brace in regex is deprecated here (and will be fatal in
Perl 5.32), passed through in regex; marked by <-- HERE in m/^element
*({ <-- HERE ([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*)
*(.*)/ at conformtest.pl line 370.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoUse AVX_Fast_Unaligned_Load from Zen onwards.
Amit Pawar [Fri, 6 Jul 2018 13:55:36 +0000 (09:55 -0400)]
Use AVX_Fast_Unaligned_Load from Zen onwards.

From Zen onwards this will be enabled. It was disabled for the
Excavator case and will remain disabled.

Reviewd-by: Carlos O'Donell <carlos@redhat.com>
6 years agoBuild csu/elf-init.c and csu/static-reloc.c with stack protector
Florian Weimer [Thu, 5 Jul 2018 20:57:45 +0000 (22:57 +0200)]
Build csu/elf-init.c and csu/static-reloc.c with stack protector

This does not change generated code (with -fstack-protector-strong), but
is important for formal compiler flags compliance.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoCompile debug/stack_chk_fail_local.c with stack protector
Florian Weimer [Thu, 5 Jul 2018 17:28:11 +0000 (19:28 +0200)]
Compile debug/stack_chk_fail_local.c with stack protector

The resulting object file is statically linked into applications, so
it is desirable to have (formal) stack protector coverage there.

6 years agolibc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
Maciej W. Rozycki [Thu, 5 Jul 2018 17:06:43 +0000 (18:06 +0100)]
libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]

Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
where correct absolute (SHN_ABS) symbol run-time load semantics is
required.  This way it can be ensured at static link time that a program
or DSO will not suffer from previous semantics where absolute symbols
were relocated by the base address, or symbols whose `st_value' is zero
silently ignored leading to a confusing "undefined symbol" error message
at load time, and instead "ELF file ABI version invalid" is printed with
old dynamic loaders, making it clear that there is an ABI version
incompatibility.

[BZ #19818]
[BZ #23307]
* libc-abis (ABSOLUTE): New ABI.
* sysdeps/unix/sysv/linux/mips/libc-abis (ABSOLUTE): New ABI.
* NEWS: Mention the new ABI.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoAdd renameat2 function [BZ #17662]
Florian Weimer [Thu, 5 Jul 2018 16:59:02 +0000 (18:59 +0200)]
Add renameat2 function [BZ #17662]

The implementation falls back to renameat if renameat2 is not available
in the kernel (or in the kernel headers) and the flags argument is zero.
Without kernel support, a non-zero argument returns EINVAL, not ENOSYS.
This mirrors what the kernel does for invalid renameat2 flags.

6 years agoposix: Fix bug-regex33 after regex sync
Adhemerval Zanella [Wed, 4 Jul 2018 20:26:22 +0000 (17:26 -0300)]
posix: Fix bug-regex33 after regex sync

On some platforms the inclusion of regex-internal.h in bug-regex33
testcase show a MAX redefinition if test-skeleton.c is include later.
This patch fixes by removing regex-internal.h inclusion and using
SBC_MAX value directly.

Checked on aarch64-linux-gnu.

* posix/bug-regex33.c: Fix build after regex sync.

6 years agolocale: XFAIL newlocale usage in static binary (Bug 23164)
Carlos O'Donell [Mon, 14 May 2018 12:25:46 +0000 (08:25 -0400)]
locale: XFAIL newlocale usage in static binary (Bug 23164)

There is a glibc optimization which allows for locale categories
to be removed during static compilation. There have been various
bugs for this support over the years, with bug 16915 being the
most recent. The solution there was to emit a reference to all the
categories to avoid any being removed. This fix, although it's in
the generic __nl_langinfo_l function, doesn't appear to be enough
to fix the case for a statically linked program that uses newlocale
and nl_langinfo_l. This commit doesn't fix the problem, but it does
add a XFAIL'd test case such that a fix can be applied against this
and the XFAIL removed. It's not entirely clear that the problem is
the same as that which was seen in bug 16915.

6 years agotestrun.sh: Implement --tool=strace, --tool=valgrind
Florian Weimer [Wed, 4 Jul 2018 13:27:24 +0000 (15:27 +0200)]
testrun.sh: Implement --tool=strace, --tool=valgrind

$(file …) appears to be the only convenient way to create files
with newlines and make substitution variables.  This needs make 4.0
(released in 2013), so update the requirement to match.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoposix: Sync gnulib regex implementation
Adhemerval Zanella [Wed, 20 Dec 2017 11:47:44 +0000 (09:47 -0200)]
posix: Sync gnulib regex implementation

This patch syncs the regex implementation with gnulib (commit 0ee5212).
Only two changes in GLIBC regex testing are required:

  1. posix/bug-regex28.c: as previously discussed [1] the change of
     expected results on the pattern should be safe.

  2. posix/PCRE.tests: the ERE (a)|\1 is malformed (in the sense that
     the \1 doesn't mean anything) and although current GLIBC accepts
     it has undefined behavior.  This patch removes the specific test.

This sync contains some patches from thread 'Regex: Make libc regex
more usable outside GLIBC.' [2] which have been pushed upstream in
gnulib.  This patches also fixes some regex issues (BZ #23233,
BZ #21163, BZ #18986, BZ #13762) and I did not add testcases for
both #23233 and #13762 because I couldn't think a simple way to
trigger the expected failure path to trigger them.

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

[BZ #23233]
[BZ #21163]
[BZ #18986]
[BZ #13762]
* posix/Makefile (tests): Add bug-regex37 and bug-regex38.
* posix/PCRE.tests: Remove invalid test.
* posix/bug-regex28.c: Fix expected values for used syntax.
* posix/bug-regex37.c: New file.
* posix/bug-regex38.c: Likewise.
* posix/regcomp.c: Sync with gnulib.
* posix/regex.c: Likewise.
* posix/regex.h: Likewise.
* posix/regex_internal.c: Likewise.
* posix/regex_internal.h: Likewise.
* posix/regexec.c: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2017-12/msg00807.html
[2] https://sourceware.org/ml/libc-alpha/2017-12/msg00237.html

6 years agoBug 23308: Update to Unicode 11.0.0
Mike FABIAN [Mon, 18 Jun 2018 16:23:44 +0000 (18:23 +0200)]
Bug 23308: Update to Unicode 11.0.0

Unicode 11.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 11.0.0, using
the generator scripts contributed by Mike FABIAN (Red Hat).

Some info about the number of characters added:

Total added characters in newly generated CHARMAP: 684
Total added characters in newly generated WIDTH: 119
alpha: Added 380 characters in new ctype which were not in old ctype
combining: Added 56 characters in new ctype which were not in old ctype
combining_level3: Added 37 characters in new ctype which were not in old ctype
graph: Added 684 characters in new ctype which were not in old ctype
lower: Added 82 characters in new ctype which were not in old ctype
print: Added 684 characters in new ctype which were not in old ctype
punct: Added 304 characters in new ctype which were not in old ctype
tolower: Added 79 characters in new ctype which were not in old ctype
totitle: Added 33 characters in new ctype which were not in old ctype
toupper: Added 79 characters in new ctype which were not in old ctype
upper: Added 79 characters in new ctype which were not in old ctype

No characters were removed.

[BZ #23308]
* unicode-gen/Makefile (UNICODE_VERSION): Set to 11.0.0.
* localedata/unicode-gen/DerivedCoreProperties.txt: Update to Unicode 11.0.0.
* localedata/unicode-gen/EastAsianWidth.txt: likewise.
* localedata/unicode-gen/PropList.txt: likewise.
* localedata/unicode-gen/UnicodeData.txt: likewise.
* localedata/charmaps/UTF-8: Regenerate.
* localedata/locales/i18n_ctype: likewise.
* localedata/locales/tr_TR: likewise.
* localedata/locales/translit_circle: likewise.
* localedata/locales/translit_cjk_compat: likewise.
* localedata/locales/translit_combining: likewise.
* localedata/locales/translit_compat: likewise.
* localedata/locales/translit_font: likewise.
* localedata/locales/translit_fraction: likewise.

6 years agostdio-common/tst-printf.c: Remove part under a non-free license [BZ #23363]
Florian Weimer [Tue, 3 Jul 2018 16:29:16 +0000 (18:29 +0200)]
stdio-common/tst-printf.c: Remove part under a non-free license [BZ #23363]

The license does not allow modification.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoFix hurd expected fcntl version
Adhemerval Zanella [Mon, 2 Jul 2018 19:45:53 +0000 (16:45 -0300)]
Fix hurd expected fcntl version

Different than Linux, hurd does not need the OFD locks fix from
06ab719d30b (since OFD locks are current Linux specific). This in
turn allows hurd to not provide a fcntl compat symbol.

Checked on a i686-gnu with check-abi.

* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl): Remove
symbol.

6 years agoldbl-128ibm-compat: Add printf_size
Gabriel F. T. Gomes [Fri, 29 Jun 2018 01:38:55 +0000 (22:38 -0300)]
ldbl-128ibm-compat: Add printf_size

Since the addition of the _Float128 API, strfromf128 and printf_size use
__printf_fp to print _Float128 values.  This is achieved by setting the
'is_binary128' member of the 'printf_info' structure to one.  Now that
the format of long double on powerpc64le is getting a third option, this
mechanism is reused for long double values that have binary128 format
(i.e.: when -mabi=ieeelongdouble).

This patch adds __printf_sizeieee128 as an exported symbol, but doesn't
provide redirections from printf_size, yet.  All redirections will be
installed in a future commit, once all other functions that print or
read long double values with binary128 format are ready.  In
__printf_fp, when 'is_binary128' is one, the floating-point argument is
treated as if it was of _Float128 type, regardless of the value of
'is_long_double', thus __printf_sizeieee128 sets 'is_binary128' to the
same value of 'is_long_double'.  Otherwise, double values would not be
printed correctly.

Tested for powerpc64le.

6 years agoUse uint32_t sign in single precision math error handling functions
Szabolcs Nagy [Wed, 13 Jun 2018 14:07:21 +0000 (15:07 +0100)]
Use uint32_t sign in single precision math error handling functions

Ideally sign should be bool, but sometimes (e.g. in powf) it's more
efficient to pass a non-zero value than 1 to indicate that the sign
should be set.  The fixed size int is less ambigous than unsigned
long.

* sysdeps/ieee754/flt-32/e_powf.c (__powf): Use uint32_t.
(exp2f_inline): Likewise.
* sysdeps/ieee754/flt-32/math_config.h (__math_oflowf): Likewise.
(__math_uflowf): Likewise.
(__math_may_uflowf): Likewise.
(__math_divzerof): Likewise.
(__math_invalidf): Likewise.
* sysdeps/ieee754/flt-32/math_errf.c (xflowf): Likewise.
(__math_oflowf): Likewise.
(__math_uflowf): Likewise.
(__math_may_uflowf): Likewise.
(__math_divzerof): Likewise.
(__math_invalidf): Likewise.

6 years agolibc: Extend __libc_freeres framework (Bug 23329).
Carlos O'Donell [Fri, 22 Jun 2018 13:28:47 +0000 (09:28 -0400)]
libc: Extend __libc_freeres framework (Bug 23329).

The __libc_freeres framework does not extend to non-libc.so objects.
This causes problems in general for valgrind and mtrace detecting
unfreed objects in both libdl.so and libpthread.so.  This change is
a pre-requisite to properly moving the malloc hooks out of malloc
since such a move now requires precise accounting of all allocated
data before destructors are run.

This commit adds a proper hook in libc.so.6 for both libdl.so and
for libpthread.so, this ensures that shm-directory.c which uses
freeit () to free memory is called properly.  We also remove the
nptl_freeres hook and fall back to using weak-ref-and-check idiom
for a loaded libpthread.so, thus making this process similar for
all DSOs.

Lastly we follow best practice and use explicit free calls for
both libdl.so and libpthread.so instead of the generic hook process
which has undefined order.

Tested on x86_64 with no regressions.

Signed-off-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Carlos O'Donell <carlos@redhat.com>
6 years agoAdd long double input for strfmon test
Rajalakshmi Srinivasaraghavan [Sat, 30 Jun 2018 01:24:34 +0000 (06:54 +0530)]
Add long double input for strfmon test

This patch adds long double type inputs in strfmon_l test
which will help in long double migration.

Tested for powerpc64le.

6 years agoNew locale: Lower Sorbian (dsb_DE) [BZ #23208]
Michael Wolf [Thu, 7 Jun 2018 23:26:43 +0000 (01:26 +0200)]
New locale: Lower Sorbian (dsb_DE) [BZ #23208]

[BZ #23208]
* localedata/SUPPORTED (dsb_DE/UTF-8): New entry.
* localedata/locales/dsb_DE: New file.

6 years agohy_AM: Add alternative month names (bug 23140).
Rafal Luzynski [Fri, 24 Feb 2017 02:13:15 +0000 (03:13 +0100)]
hy_AM: Add alternative month names (bug 23140).

This locale already contained correct data in mon array.  Updated from
CLDR to start the month names with the lowercase letters.

alt_mon is a new import from CLDR.  The change has been consulted
off-list with a native speaker.

[BZ #23140]
* localedata/locales/hy_AM (mon): Synchronize with CLDR (lowercase,
genitive case).
(alt_mon): New entry, import from CLDR (nominative case).

6 years agoes_BO locale: Change LC_PAPER to en_US (bug 22996).
Sylvain Lesage [Fri, 29 Jun 2018 18:55:59 +0000 (20:55 +0200)]
es_BO locale: Change LC_PAPER to en_US (bug 22996).

[BZ #22996]
* localedata/locales/es_BO (LC_PAPER): Change to “copy "en_US"”.

6 years agoaarch64,falkor: Use vector registers for memcpy
Siddhesh Poyarekar [Fri, 29 Jun 2018 17:15:59 +0000 (22:45 +0530)]
aarch64,falkor: Use vector registers for memcpy

Vector registers perform better than scalar register pairs for copying
data so prefer them instead.  This results in a time reduction of over
50% (i.e. 2x speed improvemnet) for some smaller sizes for memcpy-walk.
Larger sizes show improvements of around 1% to 2%.  memcpy-random shows
a very small improvement, in the range of 1-2%.

* sysdeps/aarch64/multiarch/memcpy_falkor.S (__memcpy_falkor):
Use vector registers.

6 years agoaarch64,falkor: Use vector registers for memmove
Siddhesh Poyarekar [Fri, 29 Jun 2018 17:15:07 +0000 (22:45 +0530)]
aarch64,falkor: Use vector registers for memmove

Vector registers perform much better for moves compared to pairs of
registers on falkor, so use them instead.  This results in a time
reduction of up to 50% (i.e. 2x improvement) for a lot of the smaller
sizes, i.e. up to 1K in memmove-walk.  Improvements for larger sizes are
smaller, at about 1%-2%.

* sysdeps/aarch64/multiarch/memmove_falkor.S
(__memcpy_falkor): Use vector registers.

6 years agoDocument interaction with GCC built-ins in the Customizing Printf
Martin Sebor [Fri, 29 Jun 2018 16:45:19 +0000 (10:45 -0600)]
Document interaction with GCC built-ins in the Customizing Printf
section of the manual.

6 years agoelf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]
Maciej W. Rozycki [Fri, 29 Jun 2018 16:10:43 +0000 (17:10 +0100)]
elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]

We have this condition in `check_match' (in elf/dl-lookup.c):

  if (__glibc_unlikely ((sym->st_value == 0 /* No value.  */
                         && stt != STT_TLS)
                        || ELF_MACHINE_SYM_NO_MATCH (sym)
                        || (type_class & (sym->st_shndx == SHN_UNDEF))))
    return NULL;

which causes all !STT_TLS symbols whose value is zero to be silently
ignored in lookup.  This may make sense for regular symbols, however not
for absolute (SHN_ABS) ones, where zero is like any value, there's no
special meaning attached to it.

Consequently legitimate programs fail, for example taking the
`elf/tst-absolute-sym' test case, substituting 0 for 0x55aa in
`elf/tst-absolute-sym-lib.lds' and then trying to run the resulting
program we get this:

$ .../elf/tst-absolute-sym
.../elf/tst-absolute-sym: symbol lookup error: .../elf/tst-absolute-sym-lib.so: undefined symbol: absolute
$

even though the symbol clearly is there:

$ readelf --dyn-syms .../elf/tst-absolute-sym-lib.so | grep '\babsolute\b'
     7: 00000000     0 NOTYPE  GLOBAL DEFAULT  ABS absolute
$

The check for the zero value has been there since forever or commit
d66e34cd4234/08162fa88891 ("Implemented runtime dynamic linker to
support ELF shared libraries.") dating back to May 2nd 1995, and the
problem triggers regardless of commit e7feec374c63 ("elf: Correct
absolute (SHN_ABS) symbol run-time calculation [BZ #19818]") being
present or not.

Fix the issue then, by permitting `sym->st_value' to be 0 for SHN_ABS
symbols in lookup.

[BZ #23307]
* elf/dl-lookup.c (check_match): Do not reject a symbol whose
`st_value' is 0 if `st_shndx' is SHN_ABS.
* elf/tst-absolute-zero.c: New file.
* elf/tst-absolute-zero-lib.c: New file.
* elf/tst-absolute-zero-lib.lds: New file.
* elf/Makefile (tests): Add `tst-absolute-zero'.
(modules-names): Add `tst-absolute-zero-lib'.
(LDLIBS-tst-absolute-zero-lib.so): New variable.
($(objpfx)tst-absolute-zero-lib.so): New dependency.
($(objpfx)tst-absolute-zero: New dependency.

6 years agoNew configure option --disable-crypt.
Zack Weinberg [Fri, 29 Jun 2018 14:53:47 +0000 (16:53 +0200)]
New configure option --disable-crypt.

Some Linux distributions are experimenting with a new, separately
maintained and hopefully more agile implementation of the crypt
API.  To facilitate this, add a configure option which disables
glibc's embedded libcrypt.  When this option is given, libcrypt.*
and crypt.h will not be built nor installed.

6 years agomanual: Revise crypt.texi.
Zack Weinberg [Fri, 29 Jun 2018 14:53:37 +0000 (16:53 +0200)]
manual: Revise crypt.texi.

This is a major rewrite of the description of 'crypt', 'getentropy',
and 'getrandom'.

A few highlights of the content changes:

 - Throughout the manual, public headers, and user-visible messages,
   I replaced the term "password" with "passphrase", the term
   "password database" with "user database", and the term
   "encrypt(ion)" with "(one-way) hashing" whenever it was applied to
   passphrases.  I didn't bother making this change in internal code
   or tests.  The use of the term "password" in ruserpass.c survives,
   because that refers to a keyword in netrc files, but it is adjusted
   to make this clearer.

   There is a note in crypt.texi explaining that they were
   traditionally called passwords but single words are not good enough
   anymore, and a note in users.texi explaining that actual passphrase
   hashes are found in a "shadow" database nowadays.

 - There is a new short introduction to the "Cryptographic Functions"
   section, explaining how we do not intend to be a general-purpose
   cryptography library, and cautioning that there _are_, or have
   been, legal restrictions on the use of cryptography in many
   countries, without getting into any kind of detail that we can't
   promise to keep up to date.

 - I added more detail about what a "one-way function" is, and why
   they are used to obscure passphrases for storage.  I removed the
   paragraph saying that systems not connected to a network need no
   user authentication, because that's a pretty rare situation
   nowadays.  (It still says "sometimes it is necessary" to
   authenticate the user, though.)

 - I added documentation for all of the hash functions that glibc
   actually supports, but not for the additional hash functions
   supported by libxcrypt.  If we're going to keep this manual section
   around after the transition is more advanced, it would probably
   make sense to add them then.

 - There is much more detailed discussion of how to generate a salt,
   and the failure behavior for crypt is documented.  (Returning an
   invalid hash on failure is what libxcrypt does; Solar Designer's
   notes say that this was done "for compatibility with old programs
   that assume crypt can never fail".)

 - As far as I can tell, the header 'crypt.h' is entirely a GNU
   invention, and never existed on any other Unix lineage.  The
   function 'crypt', however, was in Issue 1 of the SVID and is now
   in the XSI component of POSIX.  I tried to make all of the
   @standards annotations consistent with this, but I'm not sure I got
   them perfectly right.

 - The genpass.c example has been improved to use getentropy instead
   of the current time to generate the salt, and to use a SHA-256 hash
   instead of MD5. It uses more random bytes than is strictly
   necessary because I didn't want to complicate the code with proper
   base64 encoding.

 - The testpass.c example has three hardwired hashes now, to
   demonstrate that different one-way functions produce different
   hashes for the same input.  It also demonstrates how DES hashing
   only pays attention to the first eight characters of the input.

 - There is new text explaining in more detail how a CSPRNG differs
   from a regular random number generator, and how
   getentropy/getrandom are not exactly a CSPRNG.  I tried not to make
   specific falsifiable claims here.  I also tried to make the
   blocking/cancellation/error behavior of both getentropy and
   getrandom clearer.

6 years agomanual: Reorganize crypt.texi.
Zack Weinberg [Fri, 29 Jun 2018 14:53:29 +0000 (16:53 +0200)]
manual: Reorganize crypt.texi.

In preparation for a major revision of the documentation for
crypt(_r), getentropy, and getrandom, reorganize crypt.texi.  This
patch does not change any text; it only deletes and moves text.

The description of 'getpass' moves to terminal.texi, since all it does
is read a password from the controlling terminal with echo disabled.
The "Legal Problems" section of crypt.texi is dropped, and the
introductory text is shifted down to the "Encrypting Passwords"
section; the next patch will add some new introductory text.

Also, it is no longer true that crypt.texi's top @node needs to have
no pointers.  That was a vestige of crypt/ being an add-on.  (makeinfo
itself doesn't need @node pointers anymore, but the scripts that
assemble the libc manual's topmost node rely on each chapter-level
node having them.)

6 years agoDisallow use of DES encryption functions in new programs.
Zack Weinberg [Fri, 29 Jun 2018 14:53:18 +0000 (16:53 +0200)]
Disallow use of DES encryption functions in new programs.

The functions encrypt, setkey, encrypt_r, setkey_r, cbc_crypt,
ecb_crypt, and des_setparity should not be used in new programs,
because they use the DES block cipher, which is unacceptably weak by
modern standards.  Demote all of them to compatibility symbols, and
remove their prototypes from installed headers.  cbc_crypt, ecb_crypt,
and des_setparity were already compat symbols when glibc was
configured with --disable-obsolete-rpc.

POSIX requires encrypt and setkey to be available when _XOPEN_CRYPT
is defined, so this change also removes the definition of X_OPEN_CRYPT
from <unistd.h>.

The entire "DES Encryption" section is dropped from the manual, as is
the mention of AUTH_DES and FIPS 140-2 in the introduction to
crypt.texi.  The documentation of 'memfrob' cross-referenced the DES
Encryption section, which is replaced by a hyperlink to libgcrypt, and
while I was in there I spruced up the actual documentation of
'memfrob' and 'strfry' a little.  It's still fairly jokey, because
those functions _are_ jokes, but they do also have real use cases, so
people trying to use them for real should have all the information
they need.

DES-based authentication for Sun RPC is also insecure and should be
deprecated or even removed, but maybe that can be left as TI-RPC's
problem.

6 years agomalloc: Update heap dumping/undumping comments [BZ #23351]
Florian Weimer [Fri, 29 Jun 2018 12:54:59 +0000 (14:54 +0200)]
malloc: Update heap dumping/undumping comments [BZ #23351]

Also remove a few now-unused declarations and definitions.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoast_ES: Add alternative month names (bug 23140).
Rafal Luzynski [Tue, 30 Jan 2018 11:31:12 +0000 (12:31 +0100)]
ast_ES: Add alternative month names (bug 23140).

[BZ #23140]
* localedata/locales/ast_ES (mon): Rename to...
(alt_mon): This.
(mon): Import from CLDR (genitive case).

6 years agogetifaddrs: Don't return ifa entries with NULL names [BZ #21812]
Daniel Alvarez [Fri, 29 Jun 2018 07:44:55 +0000 (09:44 +0200)]
getifaddrs: Don't return ifa entries with NULL names [BZ #21812]

A lookup operation in map_newlink could turn into an insert because of
holes in the interface part of the map.  This leads to incorrectly set
the name of the interface to NULL when the interface is not present
for the address being processed (most likely because the interface was
added between the RTM_GETLINK and RTM_GETADDR calls to the kernel).
When such changes are detected by the kernel, it'll mark the dump as
"inconsistent" by setting NLM_F_DUMP_INTR flag on the next netlink
message.

This patch checks this condition and retries the whole operation.
Hopes are that next time the interface corresponding to the address
entry is present in the list and correct name is returned.

6 years agoFix documentation build with old makeinfo
Szabolcs Nagy [Thu, 28 Jun 2018 12:27:31 +0000 (13:27 +0100)]
Fix documentation build with old makeinfo

With old makeinfo '@code {' fails because of the extra space.

* manual/llio.texi: Remove spurious space.

6 years agoUse _STRUCT_TIMESPEC as guard in <bits/types/struct_timespec.h> [BZ #23349]
Florian Weimer [Thu, 28 Jun 2018 11:12:16 +0000 (13:12 +0200)]
Use _STRUCT_TIMESPEC as guard in <bits/types/struct_timespec.h> [BZ #23349]

After commit d76d3703551a362b472c866b5b6089f66f8daa8e ("Fix missing
timespec definition for sys/stat.h (BZ #21371)") in combination with
kernel UAPI changes, GCC sanitizer builds start to fail due to a
conflicting definition of struct timespec in <linux/time.h>.  Use
_STRUCT_TIMESPEC as the header file inclusion guard, which is already
checked in the kernel header, to support including <linux/time.h> and
<sys/stat.h> in the same translation unit.

6 years agoldbl-128ibm-compat: Introduce ieee128 symbols
Rajalakshmi Srinivasaraghavan [Thu, 28 Jun 2018 08:27:50 +0000 (13:57 +0530)]
ldbl-128ibm-compat: Introduce ieee128 symbols

This patch adds __*ieee128 symbols for strfrom, strtold, strtold_l, wcstold
and wcstold_l functions.  Redirection from *l to *ieee128 will be handled
in separate patch once we start building these new files.

2018-06-28  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>

* sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add __strfromieee128,
 __strtoieee128, __strtoieee128_l,__wcstoieee128 and __wcstoieee128_l.
* sysdeps/ieee754/ldbl-128ibm-compat/strfromf128.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/strtof128.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/strtof128_l.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/wcstof128.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/wcstof128_l.c: New file.

6 years agonisplus: Correct pwent parsing issue and resulting build error [BZ #23266]
Maciej W. Rozycki [Wed, 27 Jun 2018 20:12:16 +0000 (21:12 +0100)]
nisplus: Correct pwent parsing issue and resulting build error [BZ #23266]

Copy and null-terminate NIS+ password file UID and GID entries whose
length is non-zero and are not terminated, in addition to empty ones,
fixing a bug and a compilation issue causing an error with GCC 8:

nss_nisplus/nisplus-parser.c: In function '_nss_nisplus_parse_pwent':
nss_nisplus/nisplus-parser.c:90:7: error: 'strncpy' destination unchanged after copying no bytes [-Werror=stringop-truncation]
       strncpy (first_unused, numstr, len);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nss_nisplus/nisplus-parser.c:106:7: error: 'strncpy' destination unchanged after copying no bytes [-Werror=stringop-truncation]
       strncpy (first_unused, numstr, len);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

introduced with commit ac05397075f6:

commit ac05397075f621cfdbe1db527c96167a58b6d18e
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Sun Apr 30 07:01:26 2006 +0000

* nis/nss_nisplus/nisplus-parser.c: Minor optimizations and
cleanups.  Avoid copying data if it can be used in the old place.

(no mailing list reference available).  Obviously regardless of the
recently added compiler diagnostics causing a build error this code has
been long non-functional, so I guess NIS+ servers have been supplying
strings that are non-empty and have already been null-terminated.
Which in turn made it unnecessary to make a null-terminated copy,
masking this bug.

[BZ #23266]
* nis/nss_nisplus/nisplus-parser.c (_nss_nisplus_parse_pwent):
Copy and null-terminate entries that are not terminated, in
addition to empty ones.

6 years agoRemove macros extend_alloca, extend_alloca_account [BZ #18023]
Florian Weimer [Wed, 27 Jun 2018 16:39:05 +0000 (18:39 +0200)]
Remove macros extend_alloca, extend_alloca_account [BZ #18023]

The unused macro definition in posix/glob.c comes from gnulib and will
have to be removed there.

6 years agoRemove nptl/sockperf.c.
Joseph Myers [Wed, 27 Jun 2018 17:01:06 +0000 (17:01 +0000)]
Remove nptl/sockperf.c.

This patch removes nptl/sockperf.c, an unused, x86-specific program
with a hardcoded path in /tmp.  If someone finds some of this code in
future for adding a proper benchmark, that does not of course rule out
adding it back in that form, but for now I think it's best to
eliminate this code with the hardcoded /tmp path.

Tested for x86_64.

* nptl/sockperf.c: Remove file.

6 years ago_dl_map_object_deps: Use struct scratch_buffer [BZ #18023]
Florian Weimer [Wed, 27 Jun 2018 15:55:55 +0000 (17:55 +0200)]
_dl_map_object_deps: Use struct scratch_buffer [BZ #18023]

The function comment suggests that _dl_map_object_deps cannot use
malloc, but it already allocates the l_initfini array on the heap, so
the additional allocation should be acceptable.

6 years agogethostid (Linux variant): Switch to struct scratch_buffer [BZ #18023]
Florian Weimer [Wed, 27 Jun 2018 15:55:38 +0000 (17:55 +0200)]
gethostid (Linux variant): Switch to struct scratch_buffer [BZ #18023]

Previously, extend_alloca was used without alloca accounting,
which could have been problematic with large NSS results.

6 years agowordexp: Rewrite parse_tilde to use struct scratch_buffer [BZ #18023]
Florian Weimer [Wed, 27 Jun 2018 15:54:44 +0000 (17:54 +0200)]
wordexp: Rewrite parse_tilde to use struct scratch_buffer [BZ #18023]

6 years agoRevert hurd errno.h changes
Adhemerval Zanella [Tue, 26 Jun 2018 23:09:17 +0000 (20:09 -0300)]
Revert hurd errno.h changes

Patch 06ab719d30b01 wrongly added mach errno.h changes.

6 years agoFix hardcoded /tmp paths in testing (bug 13888).
Joseph Myers [Tue, 26 Jun 2018 21:48:48 +0000 (21:48 +0000)]
Fix hardcoded /tmp paths in testing (bug 13888).

As noted in bug 13888, and as I noted previously in
<https://sourceware.org/ml/libc-alpha/2000-10/msg00111.html>, various
tests used hardcoded paths in /tmp, so posing issues for simultaneous
test runs from different build directories.

This patch fixes such uses of hardcoded file names to put them in the
build directory instead (in the case of stdio-common/bug5 the file
names are changed as well, to avoid a conflict with the name bug5.out
also used for the automatic test output redirection).  It also fixes
test-installation.pl likewise (that was using filenames with $$ in
them rather than strictly hardcoded names, but that's still not good
practice for temporary file naming).

Note that my list of files changed is not identical to that in bug
13888.  I added tst-spawn3.c and test-installation.pl, and removed
some tests that seem to me (now) to create temporary files securely
(simply using /tmp is not itself a problem if the temporary files are
handled properly with mkstemp; I haven't checked whether those tests
used to do things insecurely).  conformtest is not changed because the
makefiles always pass a --tmpdir option so the /tmp default is
irrelevant, and for the same reason there is no actual problem with
nptl/tst-umask1.c because again the makefiles always override the
default.

nptl/sockperf.c is ignored because there is no code to run it;
probably that file should actually be removed.

Some tests use the mktemp function, but I think they all use it in a
way that *is* secure (for generating names for directories / sockets /
fifos / symlinks, where the operation using the name will not follow
symlinks and so there is no potential for a symlink attack on the
account running the testsuite).

Some tests use the tmpnam function to generate temporary file names.
This is in principle insecure, but not addressed by this patch (I
consider it a separate issue from the fully hardcoded paths).

Tested for x86_64.

[BZ #13888]
* posix/Makefile (CFLAGS-tst-spawn3.c): New variable.
* posix/tst-spawn3.c (do_test): Put tst-spwan3.pid in OBJPFX, not
/tmp.
* scripts/test-installation.pl: Put temporary files in build
directory, not /tmp.
* stdio-common/Makefile (CFLAGS-bug3.c): New variable.
(CFLAGS-bug4.c): Likewise.
(CFLAGS-bug5.c): Likewise.
(CFLAGS-test-fseek.c): Likewise.
(CFLAGS-test-popen.c): Likewise.
(CFLAGS-test_rdwr.c): Likewise.
* stdio-common/bug3.c (main): Put temporary file in OBJPFX, not
/tmp.
* stdio-common/bug4.c (main): Likewise.
* stdio-common/bug5.c (main): Likewise.
* stdio-common/test-fseek.c (TESTFILE): Likewise.
* stdio-common/test-popen.c (do_test): Likewise.
* stdio-common/test_rdwr.c (main): Likewise.

6 years agoIn sem_open.c, pad was not initialized when __HAVE_64B_ATOMICS was
Patsy Franklin [Tue, 26 Jun 2018 14:35:03 +0000 (10:35 -0400)]
In sem_open.c,  pad was not initialized when __HAVE_64B_ATOMICS was
true.  On some arches this caused valgrind to warn about uninitialized
bytes when the struct was written to the file system.

This patch moves the initialization of pad outside of the
conditional.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agoFix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)
Adhemerval Zanella [Wed, 4 Apr 2018 14:24:15 +0000 (11:24 -0300)]
Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)

This patch fixes the OFD ("file private") locks for architectures that
support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The
issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and
F_{SET,GET}L{W}K64 expects a flock64 argument and when using old
F_OFD_* flags with a non LFS flock argument the kernel might interpret
the underlying data wrongly.  Kernel idea originally was to avoid using
such flags in non-LFS syscall, but since GLIBC uses fcntl with LFS
semantic as default it is possible to provide the functionality and
avoid the bogus struct kernel passing by adjusting the struct manually
for the required flags.

The idea follows other LFS interfaces that provide two symbols:

  1. A new LFS fcntl64 is added on default ABI with the usual macros to
     select it for FILE_OFFSET_BITS=64.

  2. The Linux non-LFS fcntl use a stack allocated struct flock64 for
     F_OFD_{GETLK,SETLK,SETLKW} copy the results on the user provided
     struct.

  3. Keep a compat symbol with old broken semantic for architectures
     that do not define __OFF_T_MATCHES_OFF64_T.

So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will
aliased to fcntl and no adjustment would be required.  So to actually
use F_OFD_* with LFS support the source must be built with LFS support
(_FILE_OFFSET_BITS=64).

Also F_OFD_SETLKW command is handled a cancellation point, as for
F_SETLKW{64}.

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

[BZ #20251]
* NEWS: Mention fcntl64 addition.
* csu/check_fds.c: Replace __fcntl_nocancel by __fcntl64_nocancel.
* login/utmp_file.c: Likewise.
* sysdeps/posix/fdopendir.c: Likewise.
* sysdeps/posix/opendir.c: Likewise.
* sysdeps/unix/pt-fcntl.c: Likewise.
* include/fcntl.h (__libc_fcntl64, __fcntl64,
__fcntl64_nocancel_adjusted): New prototype.
(__fcntl_nocancel_adjusted): Remove prototype.
* io/Makefile (routines): Add fcntl64.
(CFLAGS-fcntl64.c): New rule.
* io/Versions [GLIBC_2.28] (fcntl64): New symbol.
[GLIBC_PRIVATE] (__libc_fcntl): Rename to __libc_fcntl64.
* io/fcntl.h (fcntl64): Add prototype and redirect if
__USE_FILE_OFFSET64 is defined.
* io/fcntl64.c: New file.
* manual/llio.text: Add a note for which commands fcntl acts a
cancellation point.
* nptl/Makefile (CFLAGS-fcntl64.c): New rule.
* sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols.
* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl, fcntl64):
New symbols.
* sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64,
F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for
non-LFS case.
* sysdeps/unix/sysv/linux/fcntl64.c: New file.
* sysdeps/unix/sysv/linux/fcntl_nocancel.c (__fcntl_nocancel): Rename
to __fcntl64_nocancel.
(__fcntl_nocancel_adjusted): Rename to __fcntl64_nocancel_adjusted.
* sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): Rename
to __fcntl64_nocancel.
* sysdeps/unix/sysv/linux/tst-ofdlocks.c: New file.
* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.
* sysdeps/unix/sysv/linux/Makefile (tests): Add tst-ofdlocks.
(tests-internal): Add tst-ofdlocks-compat.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28]
(fcntl64): New symbol.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist [GLIBC_2.28] (fcntl,
fcntl64): Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.

6 years agoRun thread shutdown functions in an explicit order
Florian Weimer [Tue, 26 Jun 2018 13:13:54 +0000 (15:13 +0200)]
Run thread shutdown functions in an explicit order

This removes the __libc_thread_subfreeres hook in favor of explict
calls.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6 years agosunrpc: Remove always-defined _RPC_THREAD_SAFE_ macro
Florian Weimer [Tue, 26 Jun 2018 13:27:03 +0000 (15:27 +0200)]
sunrpc: Remove always-defined _RPC_THREAD_SAFE_ macro

Header and C source file changes were generated using:

unifdef -m -D_RPC_THREAD_SAFE_ include/rpc/rpc.h sunrpc/*.c

6 years agolibio: Add tst-vtables, tst-vtables-interposed
Florian Weimer [Tue, 26 Jun 2018 10:20:44 +0000 (12:20 +0200)]
libio: Add tst-vtables, tst-vtables-interposed

6 years agosupport: Add TEST_NO_SETVBUF
Florian Weimer [Tue, 26 Jun 2018 10:05:21 +0000 (12:05 +0200)]
support: Add TEST_NO_SETVBUF

This is sometimes needed for testing stdio streams, where the
setvbuf call in the test driver could interfere with the test.

6 years agolibio: Disable vtable validation in case of interposition [BZ #23313]
Florian Weimer [Tue, 26 Jun 2018 08:24:52 +0000 (10:24 +0200)]
libio: Disable vtable validation in case of interposition [BZ #23313]

6 years agonss_files: Use struct scratch_buffer instead of extend_alloca [BZ #18023]
Florian Weimer [Mon, 25 Jun 2018 17:29:11 +0000 (19:29 +0200)]
nss_files: Use struct scratch_buffer instead of extend_alloca [BZ #18023]