Auto-sync with upstream branch master

Upstream commit: bd60ce86520b781ca24b99b2555e2ad389bbfeaa
This commit is contained in:
Florian Weimer 2018-03-01 08:34:12 +01:00
parent 0e84fd763d
commit 890cc4ed1d
4 changed files with 40 additions and 198 deletions

View File

@ -1,91 +0,0 @@
#
# Posted upstream:
# https://sourceware.org/ml/libc-alpha/2013-10/msg00065.html
#
# This is related to bug 1013801 in that it fixes the problem
# by modifying the runtime. In bug 1013801 we have libselinux
# using pthread_atfork which pulls in libpthread, but we don't
# want that, we want libpthread to be pulled in only when
# actually needed by the application. This patch makes it
# possible to avoid requiring libpthread and still use
# pthread_atfork.
#
# The general idea for the design is in the leading comment
# in the source code.
#
diff --git a/nptl/Makefile b/nptl/Makefile
index 59295e413a2fa8bf..a62c939a01c200a5 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -31,7 +31,9 @@ install-lib-ldscripts := libpthread.so
routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \
libc-cleanup libc_pthread_init libc_multiple_threads \
- register-atfork unregister-atfork pthread_self
+ register-atfork unregister-atfork pthread_self \
+ libc_pthread_atfork
+static-only-routines += libc_pthread_atfork
shared-only-routines = forward
# We need to provide certain routines for compatibility with existing
diff --git a/nptl/libc_pthread_atfork.c b/nptl/libc_pthread_atfork.c
new file mode 100644
index 0000000000000000..667049aa38f6b390
--- /dev/null
+++ b/nptl/libc_pthread_atfork.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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/>. */
+
+/* The standard design pattern for making it optional to link against
+ libpthread is to mark the function weak, test if the function
+ address is non-zero and call the function, otherwise use a fallback.
+ The problem with pthread_atfork is that there is no viable
+ fallback. If you need to do something during fork it has to be done
+ via pthread_atfork. This makes having libpthread optional and using
+ pthread_atfork impossible. We make it possible by providing
+ pthread_atfork in libc_nonshared.a. The real work of pthread_atfork
+ is done by __register_atfork which is already provided in
+ libc_nonshared.a. It's included in libc_nonshared.a because
+ __dso_handle has to be unique to each DSO such that unloading the DSO
+ can unregister the atfork handlers. We build pthread_atfork again
+ under a different file name and include it into libc_nonshared.a and
+ libc.a. We keep pthread_atfork in libpthread_nonshared.a and
+ libpthread.a for compatibility and completeness.
+
+ Applications that can't rely on a new glibc should use the following
+ code to optionally include libpthread and still register a function
+ via pthread_atfork i.e. use __register_atfork directly:
+
+ extern void *__dso_handle __attribute__ ((__weak__, __visibility__ ("hidden")));
+ extern int __register_atfork (void (*) (void), void (*) (void), void (*) (void), void *);
+
+ static int __app_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void))
+ {
+ return __register_atfork (prepare, parent, child,
+ &__dso_handle == NULL ? NULL : __dso_handle);
+ }
+
+ This code requires glibc 2.3.2 or newer. Previous to 2.3.2 no such
+ interfaces exist and at that point is is impossible to have an
+ optional libpthread and call pthread_atfork.
+
+ This code adds no more ABI requirements than already exist since
+ __dso_handle and __register_atfork are already part of the ABI. */
+#include <pthread_atfork.c>

View File

@ -133,19 +133,6 @@ Date: Sun Mar 1 19:11:55 2015 +0100
* sysdeps/unix/sysv/linux/gethostid.c (gethostid): Use struct
scratch_buffer instead of extend_alloca.
commit 6de00dd8a3a76d0b7586393451e65ad6c2721a71
Author: Florian Weimer <fweimer@redhat.com>
Date: Sun Mar 1 19:14:29 2015 +0100
getlogin_r (Linux variant): Switch to struct scratch_buffer
This corrects the alloca accounting as a side effect. It was not off
if extend_alloca failed to merge allocations.
[BZ #18023]
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Use struct scratch_buffer instead of extend_alloca.
commit 488063238ee5c87b66c6982b1b6d508e30e44386
Author: Florian Weimer <fweimer@redhat.com>
Date: Sun Mar 1 19:48:31 2015 +0100
@ -241,7 +228,7 @@ Date: Sun Mar 1 23:22:45 2015 +0100
extend_alloca_account): Remove.
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 35cad364b7dfdf0d..0fae87a0bb976335 100644
index c975fcffd7735f9e..df7fc442ae1a80aa 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -27,6 +27,7 @@
@ -370,7 +357,7 @@ index fd90664f0a17cd6d..c0b83954436ed4c1 100644
# endif /* !_ISOMAC */
diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c
index 3784c101f7ee31aa..c872b32e15f55e3d 100644
index a47b4d7ada0fe37b..d6ab289b291861c5 100644
--- a/nis/nss_nis/nis-initgroups.c
+++ b/nis/nss_nis/nis-initgroups.c
@@ -16,7 +16,6 @@
@ -467,7 +454,7 @@ index 3784c101f7ee31aa..c872b32e15f55e3d 100644
return status;
}
diff --git a/nscd/aicache.c b/nscd/aicache.c
index a3de792cc429b546..7064d12a15b3e19d 100644
index 6f7b038021746e22..c2ac71f2b9647caa 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -28,6 +28,7 @@
@ -636,10 +623,10 @@ index a3de792cc429b546..7064d12a15b3e19d 100644
}
diff --git a/nscd/connections.c b/nscd/connections.c
index cc1ed72077640a8b..2f69800ee5ca83b4 100644
index 5f91985859b3026a..49e4bf0f54daa5d8 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -1324,64 +1324,83 @@ request from '%s' [%ld] not handled due to missing permission"),
@@ -1331,64 +1331,83 @@ request from '%s' [%ld] not handled due to missing permission"),
}
}
@ -761,7 +748,7 @@ index cc1ed72077640a8b..2f69800ee5ca83b4 100644
{
argv[argc++] = cp;
cp = (char *) rawmemchr (cp, '\0') + 1;
@@ -1398,6 +1417,7 @@ cannot change to old UID: %s; disabling paranoia mode"),
@@ -1405,6 +1424,7 @@ cannot change to old UID: %s; disabling paranoia mode"),
strerror (errno));
paranoia = 0;
@ -769,7 +756,7 @@ index cc1ed72077640a8b..2f69800ee5ca83b4 100644
return;
}
@@ -1409,6 +1429,7 @@ cannot change to old GID: %s; disabling paranoia mode"),
@@ -1416,6 +1436,7 @@ cannot change to old GID: %s; disabling paranoia mode"),
ignore_value (setuid (server_uid));
paranoia = 0;
@ -777,7 +764,7 @@ index cc1ed72077640a8b..2f69800ee5ca83b4 100644
return;
}
}
@@ -1426,6 +1447,7 @@ cannot change to old working directory: %s; disabling paranoia mode"),
@@ -1433,6 +1454,7 @@ cannot change to old working directory: %s; disabling paranoia mode"),
ignore_value (setgid (server_gid));
}
paranoia = 0;
@ -785,7 +772,7 @@ index cc1ed72077640a8b..2f69800ee5ca83b4 100644
return;
}
@@ -1474,6 +1496,7 @@ cannot change to old working directory: %s; disabling paranoia mode"),
@@ -1481,6 +1503,7 @@ cannot change to old working directory: %s; disabling paranoia mode"),
dbg_log (_("cannot change current working directory to \"/\": %s"),
strerror (errno));
paranoia = 0;
@ -794,7 +781,7 @@ index cc1ed72077640a8b..2f69800ee5ca83b4 100644
/* Reenable the databases. */
time_t now = time (NULL);
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index d2ad53509db97bdf..a71036512048dd81 100644
index 0ed8e656b2ae8ff9..3515971ea02d4192 100644
--- a/nscd/grpcache.c
+++ b/nscd/grpcache.c
@@ -16,7 +16,6 @@
@ -889,7 +876,7 @@ index d2ad53509db97bdf..a71036512048dd81 100644
}
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index 9f6ce979ac333265..d0af99893dd17b9f 100644
index 344a2b3052cc6ee0..95bff9b390495920 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -34,6 +34,7 @@
@ -979,7 +966,7 @@ index 9f6ce979ac333265..d0af99893dd17b9f 100644
}
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index 721f4c617b0bb74a..9349b54df4241ad5 100644
index 4c3ab660211f2b28..3f816ee0b06ae385 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -16,7 +16,6 @@
@ -1075,7 +1062,7 @@ index 721f4c617b0bb74a..9349b54df4241ad5 100644
}
diff --git a/nscd/servicescache.c b/nscd/servicescache.c
index 131ba6ddcc1a5f7a..549e9a446816d760 100644
index 49d9d0dece186c1b..53868c97b56af367 100644
--- a/nscd/servicescache.c
+++ b/nscd/servicescache.c
@@ -16,7 +16,6 @@
@ -1169,7 +1156,7 @@ index 131ba6ddcc1a5f7a..549e9a446816d760 100644
}
diff --git a/nss/getent.c b/nss/getent.c
index 8f8c3fe80a2cfea6..5654c5f67c4f118c 100644
index e609e5f9bb62a70f..f8cee703e337c4b2 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -39,6 +39,7 @@
@ -1232,7 +1219,7 @@ index 8f8c3fe80a2cfea6..5654c5f67c4f118c 100644
}
diff --git a/nss/nss_compat/compat-initgroups.c b/nss/nss_compat/compat-initgroups.c
index c1a9301a3b0c3ee0..bae8765afbd109e9 100644
index 74414f4622880b31..540eee863c85dea3 100644
--- a/nss/nss_compat/compat-initgroups.c
+++ b/nss/nss_compat/compat-initgroups.c
@@ -261,7 +261,6 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
@ -1303,7 +1290,7 @@ index c1a9301a3b0c3ee0..bae8765afbd109e9 100644
}
diff --git a/nss/nss_files/files-initgroups.c b/nss/nss_files/files-initgroups.c
index 27cd8ece40434f5c..8a88f1b62357d3bd 100644
index 8af0d4d36a400f0e..b441d8345f8a7a24 100644
--- a/nss/nss_files/files-initgroups.c
+++ b/nss/nss_files/files-initgroups.c
@@ -16,7 +16,6 @@
@ -1378,7 +1365,7 @@ index 27cd8ece40434f5c..8a88f1b62357d3bd 100644
fclose (stream);
diff --git a/posix/wordexp.c b/posix/wordexp.c
index e4cfce946013dc78..a751fb32b286aec2 100644
index 0b669a8f5e05ed15..7548e0329fdeafaa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -17,7 +17,6 @@
@ -1486,7 +1473,7 @@ index e4cfce946013dc78..a751fb32b286aec2 100644
}
return *word ? 0 : WRDE_NOSPACE;
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index ca0387723873aa8c..9a9346c2189acf7a 100644
index 73c56e57e5aa4422..ec1c8c5bfcd57077 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -63,13 +63,12 @@ sethostid (long int id)
@ -1539,62 +1526,3 @@ index ca0387723873aa8c..9a9346c2189acf7a 100644
/* For the return value to be not exactly the IP address we do some
bit fiddling. */
return (int32_t) (in.s_addr << 16 | in.s_addr >> 16);
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 45c468f5a13529d8..fea3e18b1bc30ee7 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -18,6 +18,7 @@
#include <pwd.h>
#include <unistd.h>
#include <not-cancel.h>
+#include <scratch_buffer.h>
#define STATIC static
static int getlogin_r_fd0 (char *name, size_t namesize);
@@ -54,28 +55,19 @@ __getlogin_r_loginuid (char *name, size_t namesize)
endp == uidbuf || *endp != '\0'))
return -1;
- size_t buflen = 1024;
- char *buf = alloca (buflen);
- bool use_malloc = false;
struct passwd pwd;
struct passwd *tpwd;
int result = 0;
int res;
+ struct scratch_buffer tmpbuf;
+ scratch_buffer_init (&tmpbuf);
- while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) == ERANGE)
- if (__libc_use_alloca (2 * buflen))
- buf = extend_alloca (buf, buflen, 2 * buflen);
- else
+ while ((res = __getpwuid_r (uid, &pwd,
+ tmpbuf.data, tmpbuf.length, &tpwd)) == ERANGE)
+ if (!scratch_buffer_grow (&tmpbuf))
{
- buflen *= 2;
- char *newp = realloc (use_malloc ? buf : NULL, buflen);
- if (newp == NULL)
- {
- result = ENOMEM;
- goto out;
- }
- buf = newp;
- use_malloc = true;
+ result = ENOMEM;
+ goto out;
}
if (res != 0 || tpwd == NULL)
@@ -95,9 +87,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
memcpy (name, pwd.pw_name, needed);
out:
- if (use_malloc)
- free (buf);
-
+ scratch_buffer_free (&tmpbuf);
return result;
}

View File

@ -88,10 +88,10 @@ index 80f7f1487947f578..b29efe01084af28c 100644
Copyright (C) 1998 WIDE Project.
diff --git a/config.h.in b/config.h.in
index d928e7dd867c68ce..d55a3c3834f91a0d 100644
index b0b7cf26cb4b3aa0..141db213a9046eb4 100644
--- a/config.h.in
+++ b/config.h.in
@@ -119,9 +119,6 @@
@@ -124,9 +124,6 @@
/* Mach/i386 specific: define if the `i386_set_gdt' RPC is available. */
#undef HAVE_I386_SET_GDT
@ -19463,10 +19463,10 @@ index c7e67ca563f87627..0000000000000000
- return stringprep_convert (str, stringprep_locale_charset (), "UTF-8");
-}
diff --git a/manual/contrib.texi b/manual/contrib.texi
index fbf42db31df08e3b..f2a38459856a67ae 100644
index 0da6dcbb596f7608..2be9122469bd91c8 100644
--- a/manual/contrib.texi
+++ b/manual/contrib.texi
@@ -176,7 +176,7 @@ software floating-point support and for
@@ -178,7 +178,7 @@ software floating-point support and for
his direction as part of @theglibc{} steering committee.
@item
@ -19476,10 +19476,10 @@ index fbf42db31df08e3b..f2a38459856a67ae 100644
@item
Geoffrey Keating for the port to Linux on PowerPC
diff --git a/nscd/gai.c b/nscd/gai.c
index d00a184c46cc0dd7..eb53bd7889ca3fea 100644
index d0817477976c0bdf..3825f929ca5529d5 100644
--- a/nscd/gai.c
+++ b/nscd/gai.c
@@ -40,6 +40,3 @@
@@ -42,6 +42,3 @@
/* Support code. */
#include <check_pf.c>
#include <check_native.c>
@ -20309,7 +20309,7 @@ index c5e00e516a8279f7..56dc7a9e0cbe92f3 100644
#undef FLAG
int remaining = ai->ai_flags & ~flags_printed;
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index c15f76e547e29533..593a718266557cf5 100644
index 740bdd1ed7e7e896..c0787b4288d66d0f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -85,9 +85,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@ -20323,9 +20323,9 @@ index c15f76e547e29533..593a718266557cf5 100644
+ flags, now ignored. */
+#define DEPRECATED_AI_IDN 0x300
struct gaih_service
{
@@ -474,35 +474,15 @@ gaih_inet (const char *name, const struct gaih_service *service,
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
@@ -478,35 +478,15 @@ gaih_inet (const char *name, const struct gaih_service *service,
at->scopeid = 0;
at->next = NULL;
@ -20367,7 +20367,7 @@ index c15f76e547e29533..593a718266557cf5 100644
if (__inet_aton (name, (struct in_addr *) at->addr) != 0)
{
@@ -1028,40 +1008,17 @@ gaih_inet (const char *name, const struct gaih_service *service,
@@ -1032,40 +1012,17 @@ gaih_inet (const char *name, const struct gaih_service *service,
the passed in string. */
canon = orig_name;
@ -20411,7 +20411,7 @@ index c15f76e547e29533..593a718266557cf5 100644
if (canonbuf != NULL)
/* We already allocated the string using malloc, but
the buffer is now owned by canon. */
@@ -2222,10 +2179,7 @@ getaddrinfo (const char *name, const char *service,
@@ -2226,10 +2183,7 @@ getaddrinfo (const char *name, const char *service,
if (hints->ai_flags
& ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|AI_ADDRCONFIG|AI_V4MAPPED

View File

@ -1,6 +1,6 @@
%define glibcsrcdir glibc-2.27-5-g56170e064e
%define glibcversion 2.27
%define glibcrelease 5%{?dist}
%define glibcsrcdir glibc-2.27.9000-143-gbd60ce8652
%define glibcversion 2.27.9000
%define glibcrelease 6%{?dist}
# Pre-release tarballs are pulled in from git using a command that is
# effectively:
#
@ -175,7 +175,6 @@ Patch0028: glibc-fedora-localedata-rh61908.patch
Patch0031: glibc-fedora-__libc_multiple_libcs.patch
# Allow applications to call pthread_atfork without libpthread.so.
Patch0046: glibc-rh1013801.patch
Patch0047: glibc-nscd-sysconfig.patch
@ -736,7 +735,6 @@ microbenchmark tests on the system.
%patch2027 -p1
%patch0028 -p1
%patch0031 -p1
%patch0046 -p1
%patch2031 -p1
%patch0047 -p1
%patch0053 -p1
@ -1931,6 +1929,13 @@ fi
%endif
%changelog
* Thu Mar 01 2018 Florian Weimer <fweimer@redhat.com> - 2.27.9000-6
- Switch back to upstream master branch
- Drop glibc-rh1013801.patch, applied upstream.
- Drop glibc-fedora-nptl-linklibc.patch, no longer needed.
- Auto-sync with upstream branch master,
commit bd60ce86520b781ca24b99b2555e2ad389bbfeaa.
* Wed Feb 28 2018 Florian Weimer <fweimer@redhat.com> - 2.27-5
- Inherit as many flags as possible from redhat-rpm-config