commit be9a328c93834648e0bec106a1f86357d1a8c7e1
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Aug 1 16:48:12 2019 +0200

    malloc: Remove unwanted leading whitespace in malloc_info [BZ #24867]
    
    It was introduced in commit 6c8dbf00f536d78b1937b5af6f57be47fd376344
    ("Reformat malloc to gnu style.").
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    (cherry picked from commit b0f6679bcd738ea244a14acd879d974901e56c8e)

diff --git a/ChangeLog b/ChangeLog
index cdb9e14881..a2bf94f6e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-01  Florian Weimer  <fweimer@redhat.com>
+
+	[BZ #24867]
+	* malloc/malloc.c (__malloc_info): Remove unwanted leading
+	whitespace.
+
 2019-08-01  Carlos O'Donell <carlos@redhat.com>
 
 	* version.h (RELEASE): Set to "stable".
diff --git a/NEWS b/NEWS
index ee9ed4de5a..2a57721d72 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,13 @@ See the end for copying conditions.
 
 Please send GNU C library bug reports via <https://sourceware.org/bugzilla/>
 using `glibc' in the "product" field.
+
+Version 2.30.1
+
+The following bugs are resolved with this release:
+
+  [24867] malloc: Remove unwanted leading whitespace in malloc_info
+
 
 Version 2.30
 
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 00ce48cf58..343d89f489 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5491,7 +5491,7 @@ __malloc_info (int options, FILE *fp)
 
       for (size_t i = 0; i < nsizes; ++i)
 	if (sizes[i].count != 0 && i != NFASTBINS)
-	  fprintf (fp, "							      \
+	  fprintf (fp, "\
   <size from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n",
 		   sizes[i].from, sizes[i].to, sizes[i].total, sizes[i].count);
 

commit d74461fa348de4176894f98672cb9ce721e26676
Author: Rafal Luzynski <digitalfreak@lingonborough.com>
Date:   Thu Aug 22 23:50:04 2019 +0200

    Chinese locales: Set first_weekday to 2 (bug 24682).
    
    The first day of the week in China (Mainland) should be Monday according
    to the national standard GB/T 7408-2005.  References:
    
    * https://www.doc88.com/p-1166696540287.html
    * https://unicode-org.atlassian.net/browse/CLDR-11510
    
            [BZ #24682]
            * NEWS: Mention this bug fixed.
            * localedata/locales/bo_CN (first_weekday): Add, set to 2 (Monday).
            * localedata/locales/ug_CN (first_weekday): Likewise.
            * localedata/locales/zh_CN (first_weekday): Likewise.
    
    (cherry picked from commit c0fd3244e71db39cef1e2d1d8ba12bb8b7375ce4)

diff --git a/ChangeLog b/ChangeLog
index a2bf94f6e9..e3da8f9a76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-08-28  Rafal Luzynski  <digitalfreak@lingonborough.com>
+
+	[BZ #24682]
+	* NEWS: Mention this bug fixed.
+	* localedata/locales/bo_CN (first_weekday): Add, set to 2 (Monday).
+	* localedata/locales/ug_CN (first_weekday): Likewise.
+	* localedata/locales/zh_CN (first_weekday): Likewise.
+
 2019-08-01  Florian Weimer  <fweimer@redhat.com>
 
 	[BZ #24867]
diff --git a/NEWS b/NEWS
index 2a57721d72..09f2ce9752 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ Version 2.30.1
 
 The following bugs are resolved with this release:
 
+  [24682] localedata: zh_CN first weekday should be Monday per GB/T
+    7408-2005
   [24867] malloc: Remove unwanted leading whitespace in malloc_info
 
 
diff --git a/localedata/locales/bo_CN b/localedata/locales/bo_CN
index 90cbc7807b..9df91a1721 100644
--- a/localedata/locales/bo_CN
+++ b/localedata/locales/bo_CN
@@ -128,6 +128,7 @@ t_fmt_ampm        "<U0F46><U0F74><U0F0B><U0F5A><U0F7C><U0F51>/
 <U0025><U0070>"
 
 week 7;19971130;1
+first_weekday 2
 END LC_TIME
 
 LC_MESSAGES
diff --git a/localedata/locales/ug_CN b/localedata/locales/ug_CN
index 1ba583c588..83d15c90e4 100644
--- a/localedata/locales/ug_CN
+++ b/localedata/locales/ug_CN
@@ -165,6 +165,7 @@ am_pm    "";""
 date_fmt "%a<U060C> %d-%m-%Y<U060C> %T"
 
 week 7;19971130;1
+first_weekday 2
 END LC_TIME
 
 LC_MESSAGES
diff --git a/localedata/locales/zh_CN b/localedata/locales/zh_CN
index 62a46415c1..cd4b33602a 100644
--- a/localedata/locales/zh_CN
+++ b/localedata/locales/zh_CN
@@ -139,6 +139,7 @@ t_fmt_ampm "%p %I<U65F6>%M<U5206>%S<U79D2>"
 
 date_fmt       "%Y<U5E74> %m<U6708> %d<U65E5> %A %H:%M:%S %Z"
 week 7;19971130;1
+first_weekday 2
 END LC_TIME
 
 LC_MESSAGES

commit 5438639cffe9323a5b766aff505f8f0462e10bd2
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Tue Sep 3 21:35:51 2019 +0200

    Update Alpha libm-test-ulps
    
    Changelog:
    
            * sysdeps/alpha/fpu/libm-test-ulps: Regenerated using GCC 9.2.
    
    (cherry picked from commit b5367a08ae810e3c648fb036f2e5766204f9d83f)

diff --git a/ChangeLog b/ChangeLog
index e3da8f9a76..3ae73ace06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-09-03  Aurelien Jarno  <aurelien@aurel32.net>
+
+	* sysdeps/alpha/fpu/libm-test-ulps: Regenerated using GCC 9.2.
+
 2019-08-28  Rafal Luzynski  <digitalfreak@lingonborough.com>
 
 	[BZ #24682]
diff --git a/sysdeps/alpha/fpu/libm-test-ulps b/sysdeps/alpha/fpu/libm-test-ulps
index 0f77dd2ed0..89c4527a81 100644
--- a/sysdeps/alpha/fpu/libm-test-ulps
+++ b/sysdeps/alpha/fpu/libm-test-ulps
@@ -1084,10 +1084,10 @@ ildouble: 1
 ldouble: 1
 
 Function: Real part of "cpow_downward":
-double: 2
-float: 4
-idouble: 2
-ifloat: 4
+double: 5
+float: 8
+idouble: 5
+ifloat: 8
 ildouble: 6
 ldouble: 6
 
@@ -1100,10 +1100,10 @@ ildouble: 2
 ldouble: 2
 
 Function: Real part of "cpow_towardzero":
-double: 2
-float: 4
-idouble: 2
-ifloat: 4
+double: 5
+float: 8
+idouble: 5
+ifloat: 8
 ildouble: 6
 ldouble: 6
 

commit 3c3f8dc307a08f586718ded347bfc11a27becc1e
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Aug 1 09:19:34 2019 -0300

    hppa: Update libm-tests-ulps
    
    The make regen-ulps was done on a PA8900 with 8.3.0.
    
            * sysdeps/hppa/fpu/libm-test-ulps: Update.
    
    (cherry picked from commit 3175dcc1e67425ad471caddc3d3cfae357de26ff)

diff --git a/ChangeLog b/ChangeLog
index 3ae73ace06..8e29a549b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-09-08  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+	* sysdeps/hppa/fpu/libm-test-ulps: Update.
+
 2019-09-03  Aurelien Jarno  <aurelien@aurel32.net>
 
 	* sysdeps/alpha/fpu/libm-test-ulps: Regenerated using GCC 9.2.
diff --git a/sysdeps/hppa/fpu/libm-test-ulps b/sysdeps/hppa/fpu/libm-test-ulps
index d0c4dea001..2c61a7ae91 100644
--- a/sysdeps/hppa/fpu/libm-test-ulps
+++ b/sysdeps/hppa/fpu/libm-test-ulps
@@ -544,9 +544,9 @@ idouble: 1
 ifloat: 1
 
 Function: Imaginary part of "ccos_downward":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Real part of "ccos_towardzero":
@@ -556,9 +556,9 @@ idouble: 1
 ifloat: 2
 
 Function: Imaginary part of "ccos_towardzero":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Real part of "ccos_upward":
@@ -588,27 +588,27 @@ idouble: 1
 ifloat: 1
 
 Function: Real part of "ccosh_downward":
-double: 1
+double: 2
 float: 3
-idouble: 1
+idouble: 2
 ifloat: 3
 
 Function: Imaginary part of "ccosh_downward":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Real part of "ccosh_towardzero":
-double: 1
+double: 2
 float: 3
-idouble: 1
+idouble: 2
 ifloat: 3
 
 Function: Imaginary part of "ccosh_towardzero":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Real part of "ccosh_upward":
@@ -636,27 +636,27 @@ idouble: 1
 ifloat: 2
 
 Function: Real part of "cexp_downward":
-double: 1
+double: 2
 float: 2
-idouble: 1
+idouble: 2
 ifloat: 2
 
 Function: Imaginary part of "cexp_downward":
-double: 1
+double: 3
 float: 3
-idouble: 1
+idouble: 3
 ifloat: 3
 
 Function: Real part of "cexp_towardzero":
-double: 1
+double: 2
 float: 2
-idouble: 1
+idouble: 2
 ifloat: 2
 
 Function: Imaginary part of "cexp_towardzero":
-double: 1
+double: 3
 float: 3
-idouble: 1
+idouble: 3
 ifloat: 3
 
 Function: Real part of "cexp_upward":
@@ -666,9 +666,9 @@ idouble: 1
 ifloat: 2
 
 Function: Imaginary part of "cexp_upward":
-double: 1
+double: 3
 float: 2
-idouble: 1
+idouble: 3
 ifloat: 2
 
 Function: Real part of "clog":
@@ -800,21 +800,21 @@ idouble: 1
 ifloat: 1
 
 Function: "cosh_downward":
-double: 1
+double: 2
 float: 1
-idouble: 1
+idouble: 2
 ifloat: 1
 
 Function: "cosh_towardzero":
-double: 1
+double: 2
 float: 1
-idouble: 1
+idouble: 2
 ifloat: 1
 
 Function: "cosh_upward":
-double: 1
+double: 2
 float: 2
-idouble: 1
+idouble: 2
 ifloat: 2
 
 Function: Real part of "cpow":
@@ -834,9 +834,9 @@ ildouble: 2
 ldouble: 2
 
 Function: Real part of "cpow_downward":
-double: 4
+double: 5
 float: 8
-idouble: 4
+idouble: 5
 ifloat: 8
 
 Function: Imaginary part of "cpow_downward":
@@ -846,9 +846,9 @@ idouble: 2
 ifloat: 2
 
 Function: Real part of "cpow_towardzero":
-double: 4
+double: 5
 float: 8
-idouble: 4
+idouble: 5
 ifloat: 8
 
 Function: Imaginary part of "cpow_towardzero":
@@ -876,9 +876,9 @@ idouble: 1
 ifloat: 1
 
 Function: Real part of "csin_downward":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Imaginary part of "csin_downward":
@@ -888,9 +888,9 @@ idouble: 1
 ifloat: 2
 
 Function: Real part of "csin_towardzero":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Imaginary part of "csin_towardzero":
@@ -930,9 +930,9 @@ idouble: 2
 ifloat: 2
 
 Function: Imaginary part of "csinh_downward":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Real part of "csinh_towardzero":
@@ -942,9 +942,9 @@ idouble: 2
 ifloat: 2
 
 Function: Imaginary part of "csinh_towardzero":
-double: 2
+double: 3
 float: 3
-idouble: 2
+idouble: 3
 ifloat: 3
 
 Function: Real part of "csinh_upward":
@@ -1172,15 +1172,15 @@ ildouble: 6
 ldouble: 6
 
 Function: "exp10_downward":
-double: 2
+double: 3
 float: 1
-idouble: 2
+idouble: 3
 ifloat: 1
 
 Function: "exp10_towardzero":
-double: 2
+double: 3
 float: 1
-idouble: 2
+idouble: 3
 ifloat: 1
 
 Function: "exp10_upward":

commit b1299aab223503e3ba2b447c3ec4f6f0197aa824
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Sat Sep 14 18:22:52 2019 +0200

    alpha: force old OSF1 syscalls for getegid, geteuid and getppid [BZ #24986]
    
    On alpha, Linux kernel 5.1 added the standard getegid, geteuid and
    getppid syscalls (commit ecf7e0a4ad15287). Up to now alpha was using
    the corresponding OSF1 syscalls through:
     - sysdeps/unix/alpha/getegid.S
     - sysdeps/unix/alpha/geteuid.S
     - sysdeps/unix/alpha/getppid.S
    
    When building against kernel headers >= 5.1, the glibc now use the new
    syscalls through sysdeps/unix/sysv/linux/syscalls.list. When it is then
    used with an older kernel, the corresponding 3 functions fail.
    
    A quick fix is to move the OSF1 wrappers under the
    sysdeps/unix/sysv/linux/alpha directory so they override the standard
    linux ones. A better fix would be to try the new syscalls and fallback
    to the old OSF1 in case the new ones fail. This can be implemented in
    a later commit.
    
    Changelog:
            [BZ #24986]
            * sysdeps/unix/alpha/getegid.S: Move to ...
            * sysdeps/unix/sysv/linux/alpha/getegid.S: ... here.
            * sysdeps/unix/alpha/geteuid.S: Move to ...
            * sysdeps/unix/sysv/linux/alpha/geteuid.S: ... here.
            * sysdeps/unix/alpha/getppid.S: Move to ...
            * sysdeps/unix/sysv/linux/alpha/getppid.S: ... here
    (cherry picked from commit 1a6566094d3097f4a3037ab5555cddc6cb11c3a3)

diff --git a/ChangeLog b/ChangeLog
index 8e29a549b9..3ea022b738 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-09-14  Aurelien Jarno  <aurelien@aurel32.net>
+
+	[BZ #24986]
+        * sysdeps/unix/alpha/getegid.S: Move to ...
+	* sysdeps/unix/sysv/linux/alpha/getegid.S: ... here.
+        * sysdeps/unix/alpha/geteuid.S: Move to ...
+	* sysdeps/unix/sysv/linux/alpha/geteuid.S: ... here.
+        * sysdeps/unix/alpha/getppid.S: Move to ...
+	* sysdeps/unix/sysv/linux/alpha/getppid.S: ... here
+
 2019-09-08  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
 	* sysdeps/hppa/fpu/libm-test-ulps: Update.
diff --git a/NEWS b/NEWS
index 09f2ce9752..5f1ade1c49 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ The following bugs are resolved with this release:
   [24682] localedata: zh_CN first weekday should be Monday per GB/T
     7408-2005
   [24867] malloc: Remove unwanted leading whitespace in malloc_info
+  [24986] alpha: new getegid, geteuid and getppid syscalls used
+    unconditionally
 
 
 Version 2.30
diff --git a/sysdeps/unix/alpha/getegid.S b/sysdeps/unix/sysv/linux/alpha/getegid.S
similarity index 100%
rename from sysdeps/unix/alpha/getegid.S
rename to sysdeps/unix/sysv/linux/alpha/getegid.S
diff --git a/sysdeps/unix/alpha/geteuid.S b/sysdeps/unix/sysv/linux/alpha/geteuid.S
similarity index 100%
rename from sysdeps/unix/alpha/geteuid.S
rename to sysdeps/unix/sysv/linux/alpha/geteuid.S
diff --git a/sysdeps/unix/alpha/getppid.S b/sysdeps/unix/sysv/linux/alpha/getppid.S
similarity index 100%
rename from sysdeps/unix/alpha/getppid.S
rename to sysdeps/unix/sysv/linux/alpha/getppid.S

commit a6aaabd036d735a1b412f441bf6c706832655598
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Sep 18 13:22:24 2019 +0000

    Fix RISC-V vfork build with Linux 5.3 kernel headers.
    
    Building glibc for RISC-V with Linux 5.3 kernel headers fails because
    <linux/sched.h>, included in vfork.S for CLONE_* constants, contains a
    structure definition not safe for inclusion in assembly code.
    
    All other architectures already avoid use of that header in vfork.S,
    either defining the CLONE_* constants locally or embedding the
    required values directly in the relevant instruction, where they
    implement vfork using the clone syscall (see the implementations for
    aarch64, ia64, mips and nios2).  This patch makes the RISC-V version
    define the constants locally like the other architectures.
    
    Tested build for all three RISC-V configurations in
    build-many-glibcs.py with Linux 5.3 headers.
    
            * sysdeps/unix/sysv/linux/riscv/vfork.S: Do not include
            <linux/sched.h>.
            (CLONE_VM): New macro.
            (CLONE_VFORK): Likewise.
    
    (cherry picked from commit 8cacbcf4a984ccac24efedb795d9c8a7f149d17b)

diff --git a/ChangeLog b/ChangeLog
index 3ea022b738..29c864868a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-09-20  Joseph Myers  <joseph@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/riscv/vfork.S: Do not include
+	<linux/sched.h>.
+	(CLONE_VM): New macro.
+	(CLONE_VFORK): Likewise.
+
 2019-09-14  Aurelien Jarno  <aurelien@aurel32.net>
 
 	[BZ #24986]
diff --git a/sysdeps/unix/sysv/linux/riscv/vfork.S b/sysdeps/unix/sysv/linux/riscv/vfork.S
index 67373f181b..dc173d6b47 100644
--- a/sysdeps/unix/sysv/linux/riscv/vfork.S
+++ b/sysdeps/unix/sysv/linux/riscv/vfork.S
@@ -21,9 +21,12 @@
 #include <sys/asm.h>
 #include <sysdep.h>
 #define __ASSEMBLY__
-#include <linux/sched.h>
 #include <asm/signal.h>
 
+#define CLONE_VM      0x00000100 /* Set if VM shared between processes.  */
+#define CLONE_VFORK   0x00004000 /* Set if the parent wants the child to
+				    wake it up on mm_release.  */
+
 	.text
 LEAF (__libc_vfork)
 

commit 5397c399f9604f4e0d0b17f5600e7bc756577549
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Fri Oct 18 14:57:14 2019 +0200

    S390: Add new s390 platform z15.
    
    The new IBM z15 is added to platform string array.
    The macro _DL_PLATFORMS_COUNT is incremented.
    
    (cherry picked from commit 2901743568452403849be7295c8732faa7732339)

diff --git a/sysdeps/s390/dl-procinfo.c b/sysdeps/s390/dl-procinfo.c
index 44c9901800..1307ec41de 100644
--- a/sysdeps/s390/dl-procinfo.c
+++ b/sysdeps/s390/dl-procinfo.c
@@ -63,11 +63,11 @@ PROCINFO_CLASS const char _dl_s390_cap_flags[19][9]
 #if !defined PROCINFO_DECL && defined SHARED
   ._dl_s390_platforms
 #else
-PROCINFO_CLASS const char _dl_s390_platforms[9][7]
+PROCINFO_CLASS const char _dl_s390_platforms[10][7]
 #endif
 #ifndef PROCINFO_DECL
 = {
-    "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14"
+    "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14", "z15"
   }
 #endif
 #if !defined SHARED || defined PROCINFO_DECL
diff --git a/sysdeps/s390/dl-procinfo.h b/sysdeps/s390/dl-procinfo.h
index 3b1f6a642b..689e961ced 100644
--- a/sysdeps/s390/dl-procinfo.h
+++ b/sysdeps/s390/dl-procinfo.h
@@ -23,7 +23,7 @@
 
 #define _DL_HWCAP_COUNT 19
 
-#define _DL_PLATFORMS_COUNT	9
+#define _DL_PLATFORMS_COUNT	10
 
 /* The kernel provides up to 32 capability bits with elf_hwcap.  */
 #define _DL_FIRST_PLATFORM	32

commit fca2d6186af873cb8355e216c07f4b4874ec5d3a
Author: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Date:   Tue Oct 8 14:32:17 2019 -0300

    Make tst-strftime2 and tst-strftime3 depend on locale generation
    
    Building the test cases in parallel might make tst-strftime2 and
    tst-strftime3 fail.  Simply re-running the test case (or building
    serially) makes the problem go away.  This patch adds the necessary
    dependency to allow parallel builds in the time subdirectory.
    
    Tested for powerpc64le.
    
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
    Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
    (cherry picked from commit 52151051b39293dac9fc3181cfd6240d7ce86ca1)

diff --git a/ChangeLog b/ChangeLog
index 29c864868a..4472d6c59d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-10-08  Gabriel F. T. Gomes  <gabrielftg@linux.ibm.com>
+
+	* Makefile: Fix locale dependency for a couple of tests.
+	($(objpfx)tst-strftime2.out): New rule.
+	($(objpfx)tst-strftime3.out): Likewise.
+
 2019-09-20  Joseph Myers  <joseph@codesourcery.com>
 
 	* sysdeps/unix/sysv/linux/riscv/vfork.S: Do not include
diff --git a/time/Makefile b/time/Makefile
index a428f55245..63b8d735ea 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -57,6 +57,8 @@ include ../gen-locales.mk
 
 $(objpfx)tst-ftime_l.out: $(gen-locales)
 $(objpfx)tst-strptime.out: $(gen-locales)
+$(objpfx)tst-strftime2.out: $(gen-locales)
+$(objpfx)tst-strftime3.out: $(gen-locales)
 endif
 
 tz-cflags = -DTZDIR='"$(zonedir)"' \

commit c347431fb5fd3f124c05e82fb7a661b396e86f82
Author: Dragan Mladjenovic <dmladjenovic@wavecomp.com>
Date:   Fri Aug 23 16:38:04 2019 +0000

    mips: Force RWX stack for hard-float builds that can run on pre-4.8 kernels
    
    Linux/Mips kernels prior to 4.8 could potentially crash the user
    process when doing FPU emulation while running on non-executable
    user stack.
    
    Currently, gcc doesn't emit .note.GNU-stack for mips, but that will
    change in the future. To ensure that glibc can be used with such
    future gcc, without silently resulting in binaries that might crash
    in runtime, this patch forces RWX stack for all built objects if
    configured to run against minimum kernel version less than 4.8.
    
            * sysdeps/unix/sysv/linux/mips/Makefile
            (test-xfail-check-execstack):
            Move under mips-has-gnustack != yes.
            (CFLAGS-.o*, ASFLAGS-.o*): New rules.
            Apply -Wa,-execstack if mips-force-execstack == yes.
            * sysdeps/unix/sysv/linux/mips/configure: Regenerated.
            * sysdeps/unix/sysv/linux/mips/configure.ac
            (mips-force-execstack): New var.
            Set to yes for hard-float builds with minimum_kernel < 4.8.0
            or minimum_kernel not set at all.
            (mips-has-gnustack): New var.
            Use value of libc_cv_as_noexecstack
            if mips-force-execstack != yes, otherwise set to no.
    
    (cherry picked from commit 33bc9efd91de1b14354291fc8ebd5bce96379f12)

diff --git a/ChangeLog b/ChangeLog
index 4472d6c59d..43c9a70ed1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2019-11-01  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>
+
+	* sysdeps/unix/sysv/linux/mips/Makefile
+	(test-xfail-check-execstack):
+	Move under mips-has-gnustack != yes.
+	(CFLAGS-.o*, ASFLAGS-.o*): New rules.
+	Apply -Wa,-execstack if mips-force-execstack == yes.
+	* sysdeps/unix/sysv/linux/mips/configure: Regenerated.
+	* sysdeps/unix/sysv/linux/mips/configure.ac
+	(mips-force-execstack): New var.
+	Set to yes for hard-float builds with minimum_kernel < 4.8.0
+	or minimum_kernel not set at all.
+	(mips-has-gnustack): New var.
+	Use value of libc_cv_as_noexecstack
+	if mips-force-execstack != yes, otherwise set to no.
+
 2019-10-08  Gabriel F. T. Gomes  <gabrielftg@linux.ibm.com>
 
 	* Makefile: Fix locale dependency for a couple of tests.
diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linux/mips/Makefile
index 8217f42e75..03044e7365 100644
--- a/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/sysdeps/unix/sysv/linux/mips/Makefile
@@ -63,14 +63,25 @@ sysdep-dl-routines += dl-static
 
 sysdep_routines += dl-vdso
 endif
-
-# Supporting non-executable stacks on MIPS requires changes to both
-# the Linux kernel and glibc.  See
-# <https://sourceware.org/ml/libc-alpha/2016-01/msg00567.html> and
-# <https://sourceware.org/ml/libc-alpha/2016-01/msg00719.html>.
+# If the compiler doesn't use GNU.stack note,
+# this test is expected to fail.
+ifneq ($(mips-has-gnustack),yes)
 test-xfail-check-execstack = yes
 endif
+endif
 
 ifeq ($(subdir),stdlib)
 gen-as-const-headers += ucontext_i.sym
 endif
+
+ifeq ($(mips-force-execstack),yes)
+CFLAGS-.o += -Wa,-execstack
+CFLAGS-.os += -Wa,-execstack
+CFLAGS-.op += -Wa,-execstack
+CFLAGS-.oS += -Wa,-execstack
+
+ASFLAGS-.o += -Wa,-execstack
+ASFLAGS-.os += -Wa,-execstack
+ASFLAGS-.op += -Wa,-execstack
+ASFLAGS-.oS += -Wa,-execstack
+endif
diff --git a/sysdeps/unix/sysv/linux/mips/configure b/sysdeps/unix/sysv/linux/mips/configure
index 1ee7f41a36..25f98e0c7b 100644
--- a/sysdeps/unix/sysv/linux/mips/configure
+++ b/sysdeps/unix/sysv/linux/mips/configure
@@ -475,3 +475,44 @@ if test -z "$arch_minimum_kernel"; then
     arch_minimum_kernel=4.5.0
   fi
 fi
+
+# Check if we are supposed to run on kernels older than 4.8.0. If so,
+# force executable stack to avoid potential runtime problems with fpu
+# emulation.
+# NOTE: The check below assumes that in absence of user-provided minumum_kernel
+# we will default to arch_minimum_kernel which is currently less than 4.8.0 for
+# all known configurations. If this changes, the check must be updated.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler must use executable stack" >&5
+$as_echo_n "checking whether the compiler must use executable stack... " >&6; }
+if ${libc_cv_mips_force_execstack+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  libc_cv_mips_force_execstack=no
+  if test $libc_mips_float = hard; then
+    if test -n "$minimum_kernel"; then
+
+       min_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
+
+       if test $min_version -lt 264192; then
+         libc_cv_mips_force_execstack=yes
+       fi
+    else
+      libc_cv_mips_force_execstack=yes
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mips_force_execstack" >&5
+$as_echo "$libc_cv_mips_force_execstack" >&6; }
+
+libc_mips_has_gnustack=$libc_cv_as_noexecstack
+
+if test $libc_cv_mips_force_execstack = yes; then
+  libc_mips_has_gnustack=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: forcing executable stack for pre-4.8.0 Linux kernels" >&5
+$as_echo "$as_me: WARNING: forcing executable stack for pre-4.8.0 Linux kernels" >&2;}
+fi
+
+config_vars="$config_vars
+mips-force-execstack = ${libc_cv_mips_force_execstack}"
+config_vars="$config_vars
+mips-has-gnustack = ${libc_mips_has_gnustack}"
diff --git a/sysdeps/unix/sysv/linux/mips/configure.ac b/sysdeps/unix/sysv/linux/mips/configure.ac
index 9147aa4582..3db1b32b08 100644
--- a/sysdeps/unix/sysv/linux/mips/configure.ac
+++ b/sysdeps/unix/sysv/linux/mips/configure.ac
@@ -134,3 +134,35 @@ if test -z "$arch_minimum_kernel"; then
     arch_minimum_kernel=4.5.0
   fi
 fi
+
+# Check if we are supposed to run on kernels older than 4.8.0. If so,
+# force executable stack to avoid potential runtime problems with fpu
+# emulation.
+# NOTE: The check below assumes that in absence of user-provided minumum_kernel
+# we will default to arch_minimum_kernel which is currently less than 4.8.0 for
+# all known configurations. If this changes, the check must be updated.
+AC_CACHE_CHECK([whether the compiler must use executable stack],
+        libc_cv_mips_force_execstack, [dnl
+libc_cv_mips_force_execstack=no
+  if test $libc_mips_float = hard; then
+    if test -n "$minimum_kernel"; then
+       changequote(,)
+       min_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
+       changequote([,])
+       if test $min_version -lt 264192; then
+         libc_cv_mips_force_execstack=yes
+       fi
+    else
+      libc_cv_mips_force_execstack=yes
+    fi
+  fi])
+
+libc_mips_has_gnustack=$libc_cv_as_noexecstack
+
+if test $libc_cv_mips_force_execstack = yes; then
+  libc_mips_has_gnustack=no
+  AC_MSG_WARN([forcing executable stack for pre-4.8.0 Linux kernels])
+fi
+
+LIBC_CONFIG_VAR([mips-force-execstack],[${libc_cv_mips_force_execstack}])
+LIBC_CONFIG_VAR([mips-has-gnustack],[${libc_mips_has_gnustack}])

commit 5f620768fbdae75f71af78852be228ad5577623d
Author: Niklas Hambüchen <mail@nh2.me>
Date:   Thu Aug 8 22:02:27 2019 +0200

    malloc: Fix missing accounting of top chunk in malloc_info [BZ #24026]
    
    Fixes `<total type="rest" size="..."> incorrectly showing as 0 most
    of the time.
    
    The rest value being wrong is significant because to compute the
    actual amount of memory handed out via malloc, the user must subtract
    it from <system type="current" size="...">. That result being wrong
    makes investigating memory fragmentation issues like
    <https://bugzilla.redhat.com/show_bug.cgi?id=843478> close to
    impossible.
    
    (cherry picked from commit b6d2c4475d5abc05dd009575b90556bdd3c78ad0)

diff --git a/ChangeLog b/ChangeLog
index 43c9a70ed1..e1d8fd3c66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-08  Niklas Hambüchen  <mail@nh2.me>
+	    Carlos O'Donell  <carlos@redhat.com>
+
+	[BZ #24026]
+	* malloc/malloc.c (__malloc_info): Account for top chunk.
+
 2019-11-01  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>
 
 	* sysdeps/unix/sysv/linux/mips/Makefile
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 343d89f489..0e65d636cd 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5406,6 +5406,12 @@ __malloc_info (int options, FILE *fp)
 
       __libc_lock_lock (ar_ptr->mutex);
 
+      /* Account for top chunk.  The top-most available chunk is
+	 treated specially and is never in any bin. See "initial_top"
+	 comments.  */
+      avail = chunksize (ar_ptr->top);
+      nblocks = 1;  /* Top always exists.  */
+
       for (size_t i = 0; i < NFASTBINS; ++i)
 	{
 	  mchunkptr p = fastbin (ar_ptr, i);

commit 09b81b2bab71c1a41872ba8de43115e3bdbe3d98
Author: DJ Delorie <dj@redhat.com>
Date:   Thu Aug 8 19:09:43 2019 -0400

    Add glibc.malloc.mxfast tunable
    
    * elf/dl-tunables.list: Add glibc.malloc.mxfast.
    * manual/tunables.texi: Document it.
    * malloc/malloc.c (do_set_mxfast): New.
    (__libc_mallopt): Call it.
    * malloc/arena.c: Add mxfast tunable.
    * malloc/tst-mxfast.c: New.
    * malloc/Makefile: Add it.
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    (cherry picked from commit c48d92b430c480de06762f80c104922239416826)

diff --git a/ChangeLog b/ChangeLog
index e1d8fd3c66..7a94be9097 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-08-09  DJ Delorie  <dj@redhat.com>
+
+	* elf/dl-tunables.list: Add glibc.malloc.mxfast.
+	* manual/tunables.texi: Document it.
+	* malloc/malloc.c (do_set_mxfast): New.
+	(__libc_mallopt): Call it.
+	* malloc/arena.c: Add mxfast tunable.
+	* malloc/tst-mxfast.c: New.
+	* malloc/Makefile: Add it.
+
 2019-08-08  Niklas Hambüchen  <mail@nh2.me>
 	    Carlos O'Donell  <carlos@redhat.com>
 
diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list
index 1fc2d8886b..525c3767b5 100644
--- a/elf/dl-tunables.list
+++ b/elf/dl-tunables.list
@@ -85,6 +85,11 @@ glibc {
     tcache_unsorted_limit {
       type: SIZE_T
     }
+    mxfast {
+      type: SIZE_T
+      minval: 0
+      security_level: SXID_IGNORE
+    }
   }
   cpu {
     hwcap_mask {
diff --git a/malloc/Makefile b/malloc/Makefile
index d2fba29953..94b74b5c45 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -39,6 +39,7 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
 	 tst-malloc-too-large \
 	 tst-malloc-stats-cancellation \
 	 tst-tcfree1 tst-tcfree2 tst-tcfree3 \
+	 tst-mxfast \
 
 tests-static := \
 	 tst-interpose-static-nothread \
@@ -196,6 +197,8 @@ tst-malloc-usable-static-ENV = $(tst-malloc-usable-ENV)
 tst-malloc-usable-tunables-ENV = GLIBC_TUNABLES=glibc.malloc.check=3
 tst-malloc-usable-static-tunables-ENV = $(tst-malloc-usable-tunables-ENV)
 
+tst-mxfast-ENV = GLIBC_TUNABLES=glibc.malloc.tcache_count=0:glibc.malloc.mxfast=0
+
 ifeq ($(experimental-malloc),yes)
 CPPFLAGS-malloc.c += -DUSE_TCACHE=1
 else
diff --git a/malloc/arena.c b/malloc/arena.c
index 8309c1334c..a32eb403ec 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -236,6 +236,7 @@ TUNABLE_CALLBACK_FNDECL (set_tcache_max, size_t)
 TUNABLE_CALLBACK_FNDECL (set_tcache_count, size_t)
 TUNABLE_CALLBACK_FNDECL (set_tcache_unsorted_limit, size_t)
 #endif
+TUNABLE_CALLBACK_FNDECL (set_mxfast, size_t)
 #else
 /* Initialization routine. */
 #include <string.h>
@@ -323,6 +324,7 @@ ptmalloc_init (void)
   TUNABLE_GET (tcache_unsorted_limit, size_t,
 	       TUNABLE_CALLBACK (set_tcache_unsorted_limit));
 # endif
+  TUNABLE_GET (mxfast, size_t, TUNABLE_CALLBACK (set_mxfast));
 #else
   const char *s = NULL;
   if (__glibc_likely (_environ != NULL))
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 0e65d636cd..fe973770a6 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5115,6 +5115,19 @@ do_set_tcache_unsorted_limit (size_t value)
 }
 #endif
 
+static inline int
+__always_inline
+do_set_mxfast (size_t value)
+{
+  if (value >= 0 && value <= MAX_FAST_SIZE)
+    {
+      LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ());
+      set_max_fast (value);
+      return 1;
+    }
+  return 0;
+}
+
 int
 __libc_mallopt (int param_number, int value)
 {
@@ -5134,13 +5147,7 @@ __libc_mallopt (int param_number, int value)
   switch (param_number)
     {
     case M_MXFAST:
-      if (value >= 0 && value <= MAX_FAST_SIZE)
-        {
-          LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ());
-          set_max_fast (value);
-        }
-      else
-        res = 0;
+      do_set_mxfast (value);
       break;
 
     case M_TRIM_THRESHOLD:
diff --git a/malloc/tst-mxfast.c b/malloc/tst-mxfast.c
new file mode 100644
index 0000000000..7a371d2f9d
--- /dev/null
+++ b/malloc/tst-mxfast.c
@@ -0,0 +1,50 @@
+/* Test that glibc.malloc.mxfast tunable works.
+   Copyright (C) 2018, 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This test verifies that setting the glibc.malloc.mxfast tunable to
+   zero results in free'd blocks being returned to the small bins, not
+   the fast bins.  */
+
+#include <malloc.h>
+#include <assert.h>
+
+int
+do_test(void)
+{
+  struct mallinfo m;
+  char * volatile p1;
+  char * volatile p2;
+
+  /* Arbitrary value; must be in default fastbin range.  */
+  p1 = malloc (3);
+  /* Something large so that p1 isn't a "top block" */
+  p2 = malloc (512);
+  free (p1);
+
+  m = mallinfo();
+
+  /* This will fail if there are any blocks in the fastbins.  */
+  assert (m.smblks == 0);
+
+  /* To keep gcc happy.  */
+  free (p2);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/manual/tunables.texi b/manual/tunables.texi
index ee0fdf28d1..1687f9c939 100644
--- a/manual/tunables.texi
+++ b/manual/tunables.texi
@@ -214,6 +214,18 @@ pre-fill the per-thread cache with.  The default, or when set to zero,
 is no limit.
 @end deftp
 
+@deftp Tunable glibc.malloc.mxfast
+One of the optimizations malloc uses is to maintain a series of ``fast
+bins'' that hold chunks up to a specific size.  The default and
+maximum size which may be held this way is 80 bytes on 32-bit systems
+or 160 bytes on 64-bit systems.  Applications which value size over
+speed may choose to reduce the size of requests which are serviced
+from fast bins with this tunable.  Note that the value specified
+includes malloc's internal overhead, which is normally the size of one
+pointer, so add 4 on 32-bit systems or 8 on 64-bit systems to the size
+passed to @code{malloc} for the largest bin size to enable.
+@end deftp
+
 @node Elision Tunables
 @section Elision Tunables
 @cindex elision tunables

commit 09abef31a59e6a524d1d4142ad4eb40ad0a41ccd
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Aug 15 11:37:18 2019 +0200

    malloc: Various cleanups for malloc/tst-mxfast
    
    (cherry picked from commit f9769a239784772453d595bc2f4bed8739810e06)

diff --git a/ChangeLog b/ChangeLog
index 7a94be9097..c4687dfd4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-08-15  Florian Weimer  <fweimer@redhat.com>
+
+	* malloc/Makefile (tests): Only add tst-mxfast for
+	$(have-tunables).
+	* malloc/tst-mxfast.c: Fix copyright year.
+	(do_test): Fix GNU style issues.  Use TEST_COMPARE instead of
+	assert for checks.
+
 2019-08-09  DJ Delorie  <dj@redhat.com>
 
 	* elf/dl-tunables.list: Add glibc.malloc.mxfast.
diff --git a/malloc/Makefile b/malloc/Makefile
index 94b74b5c45..742c515eb2 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -39,7 +39,6 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
 	 tst-malloc-too-large \
 	 tst-malloc-stats-cancellation \
 	 tst-tcfree1 tst-tcfree2 tst-tcfree3 \
-	 tst-mxfast \
 
 tests-static := \
 	 tst-interpose-static-nothread \
@@ -55,7 +54,7 @@ tests-internal += \
 	 tst-dynarray-at-fail \
 
 ifneq (no,$(have-tunables))
-tests += tst-malloc-usable-tunables
+tests += tst-malloc-usable-tunables tst-mxfast
 tests-static += tst-malloc-usable-static-tunables
 endif
 
diff --git a/malloc/tst-mxfast.c b/malloc/tst-mxfast.c
index 7a371d2f9d..7a7750bc71 100644
--- a/malloc/tst-mxfast.c
+++ b/malloc/tst-mxfast.c
@@ -1,5 +1,5 @@
 /* Test that glibc.malloc.mxfast tunable works.
-   Copyright (C) 2018, 2019 Free Software Foundation, Inc.
+   Copyright (C) 2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -21,14 +21,14 @@
    the fast bins.  */
 
 #include <malloc.h>
-#include <assert.h>
+#include <support/check.h>
 
 int
-do_test(void)
+do_test (void)
 {
   struct mallinfo m;
-  char * volatile p1;
-  char * volatile p2;
+  char *volatile p1;
+  char *volatile p2;
 
   /* Arbitrary value; must be in default fastbin range.  */
   p1 = malloc (3);
@@ -36,10 +36,10 @@ do_test(void)
   p2 = malloc (512);
   free (p1);
 
-  m = mallinfo();
+  m = mallinfo ();
 
   /* This will fail if there are any blocks in the fastbins.  */
-  assert (m.smblks == 0);
+  TEST_COMPARE (m.smblks, 0);
 
   /* To keep gcc happy.  */
   free (p2);

commit 919af705eef416f4469341dfdf4ca23450f30236
Author: DJ Delorie <dj@redhat.com>
Date:   Wed Oct 30 18:03:14 2019 -0400

    Base max_fast on alignment, not width, of bins (Bug 24903)
    
    set_max_fast sets the "impossibly small" value based on,
    eventually, MALLOC_ALIGNMENT.  The comparisons for the smallest
    chunk used is, eventually, MIN_CHUNK_SIZE.  Note that i386
    is the only platform where these are the same, so a smallest
    chunk *would* be put in a no-fastbins fastbin.
    
    This change calculates the "impossibly small" value
    based on MIN_CHUNK_SIZE instead, so that we can know it will
    always be impossibly small.
    
    (cherry picked from commit ff12e0fb91b9072800f031cb21fb2651ee7b6251)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index fe973770a6..8c68b21b2b 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1621,7 +1621,7 @@ static INTERNAL_SIZE_T global_max_fast;
 
 #define set_max_fast(s) \
   global_max_fast = (((s) == 0)						      \
-                     ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))
+                     ? MIN_CHUNK_SIZE / 2 : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))
 
 static inline INTERNAL_SIZE_T
 get_max_fast (void)

commit a4b3bbf71e8a608ac6ee4f423b5e2db50e06b846
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Tue Nov 12 19:18:32 2019 +0100

    Don't use a custom wrapper macro around __has_include (bug 25189).
    
    This causes issues when using clang with -frewrite-includes to e.g.,
    submit the translation unit to a distributed compiler.
    
    In my case, I was building Firefox using sccache.
    
    See [1] for a reduced test-case since I initially thought this was a
    clang bug, and [2] for more context.
    
    Apparently doing this is invalid C++ per [cpp.cond], which mentions [3]:
    
    > The #ifdef and #ifndef directives, and the defined conditional
    > inclusion operator, shall treat __has_include and __has_cpp_attribute
    > as if they were the names of defined macros.  The identifiers
    > __has_include and __has_cpp_attribute shall not appear in any context
    > not mentioned in this subclause.
    
    [1]: https://bugs.llvm.org/show_bug.cgi?id=43982
    [2]: https://bugs.llvm.org/show_bug.cgi?id=37990
    [3]: http://eel.is/c++draft/cpp.cond#7.sentence-2
    
    Change-Id: Id4b8ee19176a9e4624b533087ba870c418f27e60
    (cherry picked from commit bfa864e1645e140da2e1aae3cf0d0ba0674f6eb5)

diff --git a/NEWS b/NEWS
index 5f1ade1c49..c7dcb54bb2 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ The following bugs are resolved with this release:
   [24867] malloc: Remove unwanted leading whitespace in malloc_info
   [24986] alpha: new getegid, geteuid and getppid syscalls used
     unconditionally
+  [25189] Don't use a custom wrapper macro around __has_include
 
 
 Version 2.30
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index f1bd994a10..b1695376dc 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -412,14 +412,6 @@
 # define __glibc_has_attribute(attr)	0
 #endif
 
-#ifdef __has_include
-/* Do not use a function-like macro, so that __has_include can inhibit
-   macro expansion.  */
-# define __glibc_has_include __has_include
-#else
-# define __glibc_has_include(header)	0
-#endif
-
 #if (!defined _Noreturn \
      && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
      &&  !__GNUC_PREREQ (4,7))
diff --git a/sysdeps/unix/sysv/linux/bits/statx.h b/sysdeps/unix/sysv/linux/bits/statx.h
index 206878723f..aaccfdc2dc 100644
--- a/sysdeps/unix/sysv/linux/bits/statx.h
+++ b/sysdeps/unix/sysv/linux/bits/statx.h
@@ -26,11 +26,13 @@
 
 /* Use "" to work around incorrect macro expansion of the
    __has_include argument (GCC PR 80005).  */
-#if __glibc_has_include ("linux/stat.h")
-# include "linux/stat.h"
-# ifdef STATX_TYPE
-#  define __statx_timestamp_defined 1
-#  define __statx_defined 1
+#ifdef __has_include
+# if __has_include ("linux/stat.h")
+#  include "linux/stat.h"
+#  ifdef STATX_TYPE
+#   define __statx_timestamp_defined 1
+#   define __statx_defined 1
+#  endif
 # endif
 #endif
 

commit 37c90e117310728a4ad1eb998c0bbe7d79c4a398
Author: Marcin Kościelnicki <mwk@0x04.net>
Date:   Thu Nov 21 00:20:15 2019 +0100

    rtld: Check __libc_enable_secure before honoring LD_PREFER_MAP_32BIT_EXEC (CVE-2019-19126) [BZ #25204]
    
    The problem was introduced in glibc 2.23, in commit
    b9eb92ab05204df772eb4929eccd018637c9f3e9
    ("Add Prefer_MAP_32BIT_EXEC to map executable pages with MAP_32BIT").
    
    (cherry picked from commit d5dfad4326fc683c813df1e37bbf5cf920591c8e)

diff --git a/NEWS b/NEWS
index c7dcb54bb2..b0d2167a60 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,14 @@ using `glibc' in the "product" field.
 
 Version 2.30.1
 
+Security related changes:
+
+CVE-2019-19126: ld.so failed to ignore the LD_PREFER_MAP_32BIT_EXEC
+  environment variable during program execution after a security
+  transition, allowing local attackers to restrict the possible mapping
+  addresses for loaded libraries and thus bypass ASLR for a setuid
+  program.  Reported by Marcin Kościelnicki.
+
 The following bugs are resolved with this release:
 
   [24682] localedata: zh_CN first weekday should be Monday per GB/T
@@ -15,6 +23,7 @@ The following bugs are resolved with this release:
   [24986] alpha: new getegid, geteuid and getppid syscalls used
     unconditionally
   [25189] Don't use a custom wrapper macro around __has_include
+  [25204] Ignore LD_PREFER_MAP_32BIT_EXEC for SUID programs
 
 
 Version 2.30
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
index 975cbe2950..df2cdfdb6b 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
+++ b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
@@ -31,7 +31,8 @@
    environment variable, LD_PREFER_MAP_32BIT_EXEC.  */
 #define EXTRA_LD_ENVVARS \
   case 21:								  \
-    if (memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0)		  \
+    if (!__libc_enable_secure						  \
+	&& memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0)		  \
       GLRO(dl_x86_cpu_features).feature[index_arch_Prefer_MAP_32BIT_EXEC] \
 	|= bit_arch_Prefer_MAP_32BIT_EXEC;				  \
     break;

commit f4419b0d0181da28f18cba40068f2e75300f5020
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Wed Nov 27 12:35:40 2019 +0100

    S390: Fix handling of needles crossing a page in strstr z15 ifunc-variant. [BZ #25226]
    
    If the specified needle crosses a page-boundary, the s390-z15 ifunc variant of
    strstr truncates the needle which results in invalid results.
    
    This is fixed by loading the needle beyond the page boundary to v18 instead of v16.
    The bug is sometimes observable in test-strstr.c in check1 and check2 as the
    haystack and needle is stored on stack. Thus the needle can be on a page boundary.
    
    check2 is now extended to test haystack / needles located on stack, at end of page
    and on two pages.
    
    This bug was introduced with commit 6f47401bd5fc71209219779a0426170a9a7395b0
    ("S390: Add arch13 strstr ifunc variant.") and is already released in glibc 2.30.
    
    (cherry picked from commit bfdb731438206b0f70fe7afa890681155c30b419)

diff --git a/string/test-strstr.c b/string/test-strstr.c
index df6dbc251e..daed9a2705 100644
--- a/string/test-strstr.c
+++ b/string/test-strstr.c
@@ -139,16 +139,45 @@ check1 (void)
 static void
 check2 (void)
 {
-  const char s1[] = ", enable_static, \0, enable_shared, ";
+  const char s1_stack[] = ", enable_static, \0, enable_shared, ";
+  const size_t s1_byte_count = 18;
+  const char *s2_stack = &(s1_stack[s1_byte_count]);
+  const size_t s2_byte_count = 18;
   char *exp_result;
-  char *s2 = (void *) buf1 + page_size - 18;
+  const size_t page_size_real = getpagesize ();
 
-  strcpy (s2, s1);
-  exp_result = stupid_strstr (s1, s1 + 18);
+  /* Haystack at end of page.  The following page is protected.  */
+  char *s1_page_end = (void *) buf1 + page_size - s1_byte_count;
+  strcpy (s1_page_end, s1_stack);
+
+  /* Haystack which crosses a page boundary.
+     Note: page_size is at least 2 * getpagesize.  See test_init.  */
+  char *s1_page_cross = (void *) buf1 + page_size_real - 8;
+  strcpy (s1_page_cross, s1_stack);
+
+  /* Needle at end of page.  The following page is protected.  */
+  char *s2_page_end = (void *) buf2 + page_size - s2_byte_count;
+  strcpy (s2_page_end, s2_stack);
+
+  /* Needle which crosses a page boundary.
+     Note: page_size is at least 2 * getpagesize.  See test_init.  */
+  char *s2_page_cross = (void *) buf2 + page_size_real - 8;
+  strcpy (s2_page_cross, s2_stack);
+
+  exp_result = stupid_strstr (s1_stack, s2_stack);
   FOR_EACH_IMPL (impl, 0)
     {
-      check_result (impl, s1, s1 + 18, exp_result);
-      check_result (impl, s2, s1 + 18, exp_result);
+      check_result (impl, s1_stack, s2_stack, exp_result);
+      check_result (impl, s1_stack, s2_page_end, exp_result);
+      check_result (impl, s1_stack, s2_page_cross, exp_result);
+
+      check_result (impl, s1_page_end, s2_stack, exp_result);
+      check_result (impl, s1_page_end, s2_page_end, exp_result);
+      check_result (impl, s1_page_end, s2_page_cross, exp_result);
+
+      check_result (impl, s1_page_cross, s2_stack, exp_result);
+      check_result (impl, s1_page_cross, s2_page_end, exp_result);
+      check_result (impl, s1_page_cross, s2_page_cross, exp_result);
     }
 }
 
diff --git a/sysdeps/s390/strstr-arch13.S b/sysdeps/s390/strstr-arch13.S
index 929b026adf..faa969849e 100644
--- a/sysdeps/s390/strstr-arch13.S
+++ b/sysdeps/s390/strstr-arch13.S
@@ -164,7 +164,7 @@ ENTRY(STRSTR_ARCH13)
 	vfenezb	%v19,%v18,%v18	/* Search zero in loaded needle bytes.  */
 	veclb	%v19,%v21	/* Zero index <= max loaded byte index?  */
 	jle	.Lneedle_loaded	/* -> v18 contains full needle.  */
-	vl	%v16,0(%r3)	/* Load needle beyond page boundary.  */
+	vl	%v18,0(%r3)	/* Load needle beyond page boundary.  */
 	vfenezb	%v19,%v18,%v18
 	j	.Lneedle_loaded
 END(STRSTR_ARCH13)

commit 5a08bdb1e73e87afc1ada7b7b95d43ae470ce7e1
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Nov 28 14:18:12 2019 +0100

    libio: Disable vtable validation for pre-2.1 interposed handles [BZ #25203]
    
    Commit c402355dfa7807b8e0adb27c009135a7e2b9f1b0 ("libio: Disable
    vtable validation in case of interposition [BZ #23313]") only covered
    the interposable glibc 2.1 handles, in libio/stdfiles.c.  The
    parallel code in libio/oldstdfiles.c needs similar detection logic.
    
    Fixes (again) commit db3476aff19b75c4fdefbe65fcd5f0a90588ba51
    ("libio: Implement vtable verification [BZ #20191]").
    
    Change-Id: Ief6f9f17e91d1f7263421c56a7dc018f4f595c21
    (cherry picked from commit cb61630ed712d033f54295f776967532d3f4b46a)

diff --git a/NEWS b/NEWS
index b0d2167a60..1f60f3eb19 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,7 @@ The following bugs are resolved with this release:
   [24986] alpha: new getegid, geteuid and getppid syscalls used
     unconditionally
   [25189] Don't use a custom wrapper macro around __has_include
+  [25203] libio: Disable vtable validation for pre-2.1 interposed handles
   [25204] Ignore LD_PREFER_MAP_32BIT_EXEC for SUID programs
 
 
diff --git a/libio/oldstdfiles.c b/libio/oldstdfiles.c
index 2b861cd754..7503cdd62d 100644
--- a/libio/oldstdfiles.c
+++ b/libio/oldstdfiles.c
@@ -83,6 +83,11 @@ _IO_check_libio (void)
 	= stderr->_vtable_offset =
 	((int) sizeof (struct _IO_FILE)
 	 - (int) sizeof (struct _IO_FILE_complete));
+
+      if (_IO_stdin_.vtable != &_IO_old_file_jumps
+	  || _IO_stdout_.vtable != &_IO_old_file_jumps
+	  || _IO_stderr_.vtable != &_IO_old_file_jumps)
+	IO_set_accept_foreign_vtables (&_IO_vtable_check);
     }
 }
 

commit 761452f12781f2d15a50f2dcd9f40c53bc0ff040
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Dec 3 20:26:28 2019 +0100

    x86: Assume --enable-cet if GCC defaults to CET [BZ #25225]
    
    This links in CET support if GCC defaults to CET.  Otherwise, __CET__
    is defined, yet CET functionality is not compiled and linked into the
    dynamic loader, resulting in a linker failure due to undefined
    references to _dl_cet_check and _dl_open_check.

diff --git a/NEWS b/NEWS
index 1f60f3eb19..a02fa10df9 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ The following bugs are resolved with this release:
   [25189] Don't use a custom wrapper macro around __has_include
   [25203] libio: Disable vtable validation for pre-2.1 interposed handles
   [25204] Ignore LD_PREFER_MAP_32BIT_EXEC for SUID programs
+  [25225] ld.so fails to link on x86 if GCC defaults to -fcf-protection
 
 
 Version 2.30
diff --git a/configure b/configure
index c773c487b5..6d26b8246f 100755
--- a/configure
+++ b/configure
@@ -3777,11 +3777,32 @@ else
 fi
 
 
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+#ifndef __CET__
+#error no CET compiler support
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_cv_compiler_default_cet=yes
+else
+  libc_cv_compiler_default_cet=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 # Check whether --enable-cet was given.
 if test "${enable_cet+set}" = set; then :
   enableval=$enable_cet; enable_cet=$enableval
 else
-  enable_cet=no
+  enable_cet=$libc_cv_compiler_default_cet
 fi
 
 
diff --git a/configure.ac b/configure.ac
index 598ba6c4ae..7436485419 100644
--- a/configure.ac
+++ b/configure.ac
@@ -472,11 +472,18 @@ AC_ARG_ENABLE([mathvec],
 	      [build_mathvec=$enableval],
 	      [build_mathvec=notset])
 
+AC_TRY_COMPILE([], [
+#ifndef __CET__
+# error no CET compiler support
+#endif],
+	       [libc_cv_compiler_default_cet=yes],
+	       [libc_cv_compiler_default_cet=no])
+
 AC_ARG_ENABLE([cet],
 	      AC_HELP_STRING([--enable-cet],
 			     [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
 	      [enable_cet=$enableval],
-	      [enable_cet=no])
+	      [enable_cet=$libc_cv_compiler_default_cet])
 
 # We keep the original values in `$config_*' and never modify them, so we
 # can write them unchanged into config.make.  Everything else uses

commit 4719e1851cd1101e555f314497504a54ba3fb99a
Author: Kamlesh Kumar <kamleshbhalui@gmail.com>
Date:   Thu Dec 5 16:54:47 2019 +0100

    <string.h>: Define __CORRECT_ISO_CPP_STRING_H_PROTO for Clang [BZ #25232]
    
    Without the asm redirects, strchr et al. are not const-correct.
    
    libc++ has a wrapper header that works with and without
    __CORRECT_ISO_CPP_STRING_H_PROTO (using a Clang extension).  But when
    Clang is used with libstdc++ or just C headers, the overloaded functions
    with the correct types are not declared.
    
    This change does not impact current GCC (with libstdc++ or libc++).
    
    (cherry picked from commit 953ceff17a4a15b10cfdd5edc3c8cae4884c8ec3)

diff --git a/NEWS b/NEWS
index a02fa10df9..74826b9eb8 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ The following bugs are resolved with this release:
   [25203] libio: Disable vtable validation for pre-2.1 interposed handles
   [25204] Ignore LD_PREFER_MAP_32BIT_EXEC for SUID programs
   [25225] ld.so fails to link on x86 if GCC defaults to -fcf-protection
+  [25232] No const correctness for strchr et al. for Clang++
 
 
 Version 2.30
diff --git a/string/string.h b/string/string.h
index c38eea971f..608ed496b9 100644
--- a/string/string.h
+++ b/string/string.h
@@ -33,7 +33,8 @@ __BEGIN_DECLS
 #include <stddef.h>
 
 /* Tell the caller that we provide correct C++ prototypes.  */
-#if defined __cplusplus && __GNUC_PREREQ (4, 4)
+#if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
+			    || __glibc_clang_prereq (3, 5))
 # define __CORRECT_ISO_CPP_STRING_H_PROTO
 #endif
 

commit 50f20fe506abb8853641006a7b90a81af21d7b91
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Dec 5 17:29:42 2019 +0100

    misc/test-errno-linux: Handle EINVAL from quotactl
    
    In commit 3dd4d40b420846dd35869ccc8f8627feef2cff32 ("xfs: Sanity check
    flags of Q_XQUOTARM call"), Linux 5.4 added checking for the flags
    argument, causing the test to fail due to too restrictive test
    expectations.
    
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
    (cherry picked from commit 1f7525d924b608a3e43b10fcfb3d46b8a6e9e4f9)

diff --git a/sysdeps/unix/sysv/linux/test-errno-linux.c b/sysdeps/unix/sysv/linux/test-errno-linux.c
index cb979d44bd..aaa9eadc0a 100644
--- a/sysdeps/unix/sysv/linux/test-errno-linux.c
+++ b/sysdeps/unix/sysv/linux/test-errno-linux.c
@@ -160,8 +160,9 @@ do_test (void)
   fails |= test_wrp (EINVAL, poll, &pollfd, -1, 0);
   /* quotactl returns ENOSYS for kernels not configured with
      CONFIG_QUOTA, and may return EPERM if called within certain types
-     of containers.  */
-  fails |= test_wrp2 (LIST (ENODEV, ENOSYS, EPERM),
+     of containers.  Linux 5.4 added additional argument validation
+     and can return EINVAL.  */
+  fails |= test_wrp2 (LIST (ENODEV, ENOSYS, EPERM, EINVAL),
 		      quotactl, Q_GETINFO, NULL, -1, (caddr_t) &dqblk);
   fails |= test_wrp (EINVAL, sched_getparam, -1, &sch_param);
   fails |= test_wrp (EINVAL, sched_getscheduler, -1);
