about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* X86: Add cache info to _dl_x86_cpu_features hjl/ld.so/masterH.J. Lu2016-05-142-1/+29
| | | | | | | | | | | | | | This patch adds cache info to _dl_x86_cpu_features to allow a processor to override cache info derived from CPUID. Tested on x86 and x86-64. * sysdeps/x86/cacheinfo.c: Skip if not in libc. (init_cacheinfo): Use raw_data_size, raw_shared_size and shared_non_temporal_threshold from _dl_x86_cpu_features if not zero. * sysdeps/x86/cpu-features.h (cache_info): New. (cpu_features): Add cache.
* Add sysdeps/x86/dl-procinfo.cH.J. Lu2016-05-145-38/+62
| | | | | | | | | | | | | | | | | | linux/x86_64/dl-procinfo.[ch] includes i386 dl-procinfo.[ch] when building ldconfig since sysdeps/x86_64/dl-procinfo.c doesn't support ldconfig. Add sysdeps/x86/dl-procinfo.c to support ldconfig. This also removes the unnecessary _dl_procinfo from x86-64 ldconfig. No code changes in i686. No code changes in x86-64 libc.so and libc.a. * sysdeps/i386/dl-procinfo.c (_SYSDEPS_DL_PROCINFO_C): New. (_dl_x86_cpu_features): Removed. Include <sysdeps/x86/dl-procinfo.c>. * sysdeps/unix/sysv/linux/x86_64/dl-procinfo.c: Removed. * sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h: Likewise. * sysdeps/x86/dl-procinfo.c: New file. * sysdeps/x86_64//dl-procinfo.c (_SYSDEPS_DL_PROCINFO_C): New. (_dl_x86_cpu_features): Removed. Include <sysdeps/x86/dl-procinfo.c>.
* Call init_cpu_features only if SHARED is definedH.J. Lu2016-05-133-0/+15
| | | | | | | | | | In static executable, since init_cpu_features is called early from __libc_start_main, there is no need to call it again in dl_platform_init. [BZ #20072] * sysdeps/i386/dl-machine.h (dl_platform_init): Call init_cpu_features only if SHARED is defined. * sysdeps/x86_64/dl-machine.h (dl_platform_init): Likewise.
* Support non-inclusive caches on Intel processorsH.J. Lu2016-05-132-1/+16
| | | | | * sysdeps/x86/cacheinfo.c (init_cacheinfo): Check and support non-inclusive caches on Intel processors.
* malloc: Rewrite dumped heap for compatibility in __malloc_set_stateFlorian Weimer2016-05-133-109/+110
| | | | | | | | | | | | | | | | | This will allow us to change many aspects of the malloc implementation while preserving compatibility with existing Emacs binaries. As a result, existing Emacs binaries will have a larger RSS, and Emacs needs a few more milliseconds to start. This overhead is specific to Emacs (and will go away once Emacs switches to its internal malloc). The new checks to make free and realloc compatible with the dumped heap are confined to the mmap paths, which are already quite slow due to the munmap overhead. This commit weakens some security checks, but only for heap pointers in the dumped main arena. By default, this area is empty, so those checks are as effective as before.
* conformtest: Correct time.h XPG3 expectations.Joseph Myers2016-05-123-3/+8
| | | | | | | | | | | | | | | This patch corrects spurious conformtest expectations of getdate and getdate_err for XPG3. (This is not based on a full review of the expectations, so there may be other issues where the header and tests agree but are both incorrect.) Tested for x86_64 and x86. * conform/data/time.h-data (getdate_err): Do not expect for [XPG3]. (getdate): Likewise. * conform/Makefile (test-xfail-XPG3/time.h/conform): Remove variable.
* conformtest: Correct some unistd.h expectations for XPG3, XPG4.Joseph Myers2016-05-123-22/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The conformtest tests of unistd.h fail for XPG3 because of various expectations that are incorrect for XPG3. This patch corrects those bogus expectations, and one bogus expectation for XPG4. (This is not based on a full review of the standards so there may well still be other bugs in the expectations for this header.) Tested for x86_64 and x86. * conform/data/unistd.h-data (F_LOCK): Do not expect for [XPG3]. (F_ULOCK): Likewise. (F_TEST): Likewise. (F_TLOCK): Likewise. (useconds_t): Likewise. (intptr_t): Do not expect for [XPG3] or [XPG4]. (brk): Do not expect for [XPG3] (fchown): Likewise. (fchdir): Likewise. (ftruncate): Likewise. (getdtablesize): Likewise. (gethostid): Likewise. (getpagesize): Likewise. (getpgid): Likewise. (getsid): Likewise. (getwd): Likewise. (lchown): Likewise. (lockf): Likewise. (readlink): Likewise. (sbrk): Likewise. (setpgrp): Likewise. (setregid): Likewise. (setreuid): Likewise. (symlink): Likewise. (sync): Likewise. (truncate): Likewise. (ualarm): Likewise. (usleep): Likewise. (vfork): Likewise. * conform/Makefile (test-xfail-XPG3/unistd.h/conform): Remove variable.
* Declare gethostname for XPG4 (bug 20054).Joseph Myers2016-05-123-2/+8
| | | | | | | | | | | | | | | | unistd.h declares gethostname for __USE_UNIX98 || __USE_XOPEN2K. But it's also in XPG4 (XNS volume - C438 - not the main definitions of system interfaces and headers in C435). This patch corrects the condition. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #20054] * posix/unistd.h (gethostname): Declare if [__USE_XOPEN_EXTENDED], not [__USE_UNIX98]. * conform/data/unistd.h-data (gethostname): Do not expect for [XPG3].
* conformtest: Do not expect S_IF* in fcntl.h.Joseph Myers2016-05-123-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The conform/ tests for fcntl.h are failing for XPG3 and XPG4 because of missing S_IFSOCK. This is a case of a bogus test. The relevant wording requiring such constants is, in current POSIX (and this requirement dates back as far as XPG4), "The <fcntl.h> header shall define the symbolic constants for file modes for use as values of mode_t as described in <sys/stat.h>.". Note that this is *file modes* not *file types*. That makes sense, since the point is presumably for use with functions such as open that are declared in fcntl.h, where file modes are relevant but file types aren't. So this patch removes all those spurious S_IF* expectations for fcntl.h (the macros are generally still *allowed* through the permission to make everything from sys/stat.h visible). Tested for x86_64 and x86. * conform/data/fcntl.h-data [!POSIX] (S_IFMT): Do not expect. [!POSIX] (S_IFBLK): Likewise. [!POSIX] (S_IFCHR): Likewise. [!POSIX] (S_IFIFO): Likewise. [!POSIX] (S_IFREG): Likewise. [!POSIX] (S_IFDIR): Likewise. [!POSIX] (S_IFLNK): Likewise. [!POSIX] (S_IFSOCK): Likewise. * conform/Makefile (test-xfail-XPG3/fcntl.h/conform): Remove variable. (test-xfail-XPG4/fcntl.h/conform): Likewise.
* This is an optimized memset for AArch64. Memset is split into 4 main cases:Wilco Dijkstra2016-05-122-198/+166
| | | | | | | | | | | | | | small sets of up to 16 bytes, medium of 16..96 bytes which are fully unrolled. Large memsets of more than 96 bytes align the destination and use an unrolled loop processing 64 bytes per iteration. Memsets of zero of more than 256 use the dc zva instruction, and there are faster versions for the common ZVA sizes 64 or 128. STP of Q registers is used to reduce codesize without loss of performance. The speedup on test-memset is 1% on Cortex-A57 and 8% on Cortex-A53. * sysdeps/aarch64/memset.S (__memset): Rewrite of optimized memset.
* Increase fork signal safety for single-threaded processes [BZ #19703]Florian Weimer2016-05-124-16/+262
| | | | | | | | | This provides a band-aid and addresses the scenario where fork is called from a signal handler while the process is in the malloc subsystem (or has acquired the libio list lock). It does not address the general issue of async-signal-safety of fork; multi-threaded processes are not covered, and some glibc subsystems have fork handlers which are not async-signal-safe.
* getaddrinfo: Convert from extend_alloca to struct scratch_bufferFlorian Weimer2016-05-122-92/+68
|
* Declare tcgetsid for XPG4 (bug 20055).Joseph Myers2016-05-114-5/+16
| | | | | | | | | | | | | | | | | | | | | | termios.h should declare tcgetsid for XPG4, but only does so for __USE_UNIX98 || __USE_XOPEN2K8 at present. This patch fixes the declaration conditions. A spurious conformtest expectation of this declaration for XPG3 is removed, and two XFAILs that are fixed by these changes are also removed. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #20055] * termios/termios.h (pid_t): Define for [__USE_XOPEN_EXTENDED] instead of [__USE_UNIX98]. (tcgetsid): Declare for [__USE_XOPEN_EXTENDED] instead of [__USE_UNIX98]. * conform/data/termios.h-data (tcgetsid): Do not expect for [XPG3]. * conform/Makefile (test-xfail-XPG3/termios.h/conform): Remove variable. (test-xfail-XPG4/termios.h/conform): Likewise.
* localedef: Do not compile with mcheckFlorian Weimer2016-05-112-12/+6
| | | | __malloc_initialize_hook is deprecated.
* S390: Use fPIC to avoid R_390_GOT12 relocation in gcrt1.o.Stefan Liebler2016-05-113-4/+5
| | | | | | | | | | | | | | | | | | | if glibc is build with -march=z900 | -march=z990, the startup file gcrt1.o (used if you link with gcc -pg) contains R_390_GOT12 | R_390_GOT20 relocations. Thus, an entry in the GOT can be addressed relative to the GOT pointer with a 12 | 20 bit displacement value. The startup files should not contain R_390_GOT12, R_390_GOT20 relocations, but R_390_GOTENT ones. This patch removes the overrides of pic-ccflag and the default pic-ccflag = -fPIC in Makeconfig is used instead to get the R_390_GOTENT relocations in gcrt1.o. ChangeLog: * sysdeps/s390/s390-32/Makefile (pic-ccflag): Remove. * sysdeps/s390/s390-64/Makefile: Likewise.
* Remove x86 ifunc-defines.sym and rtld-global-offsets.symH.J. Lu2016-05-119-51/+34
| | | | | | | | | | | | | | | | | | | | Merge x86 ifunc-defines.sym with x86 cpu-features-offsets.sym. Remove x86 ifunc-defines.sym and rtld-global-offsets.sym. No code changes on i686 and x86-64. * sysdeps/i386/i686/multiarch/Makefile (gen-as-const-headers): Remove ifunc-defines.sym. * sysdeps/x86_64/multiarch/Makefile (gen-as-const-headers): Likewise. * sysdeps/i386/i686/multiarch/ifunc-defines.sym: Removed. * sysdeps/x86/rtld-global-offsets.sym: Likewise. * sysdeps/x86_64/multiarch/ifunc-defines.sym: Likewise. * sysdeps/x86/Makefile (gen-as-const-headers): Remove rtld-global-offsets.sym. * sysdeps/x86_64/multiarch/ifunc-defines.sym: Merged with ... * sysdeps/x86/cpu-features-offsets.sym: This. * sysdeps/x86/cpu-features.h: Include <cpu-features-offsets.h> instead of <ifunc-defines.h> and <rtld-global-offsets.h>.
* Fix sys/stat.h fchmod namespace (bug 20073).Joseph Myers2016-05-103-2/+7
| | | | | | | | | | | | | | | sys/stat.h declares fchmod if __USE_POSIX (i.e. POSIX.1:1990). But it was actually added in 1993 and also in XPG4. This patch changes the conditions to the correct __USE_POSIX199309 || __USE_XOPEN_EXTENDED. Tested for x86_64 and x86 (testsuite, and that installed shared libraries are unchanged by the patch). [BZ #20073] * io/sys/stat.h (fchmod): Declare for [__USE_POSIX199309 || __USE_XOPEN_EXTENDED], not [__USE_POSIX]. * conform/Makefile (test-xfail-XPG3/sys/stat.h/conform): Remove variable.
* conformtest: Correct some sys/stat.h expectations for XPG3.Joseph Myers2016-05-102-4/+17
| | | | | | | | | | | | | | | | | | | | This patch fixes various conformtest sys/stat.h expectations that were incorrect for XPG3 (not based on a full review, so not necessarily an exhaustive set of such corrections). Most of these corrections fix spurious failures shown in testing (but that for fchmod introduces a correct failure, as that function is wrongly declared for XPG3, so this doesn't eliminate any XFAILs). Tested for x86_64 and x86. * conform/data/sys/stat.h-data [XPG3] (S_IFLNK): Do not expect. [XPG3] (S_IFSOCK): Likewise. [XPG3] (S_ISVTX): Likewise. [XPG3] (S_ISLNK): Likewise. [XPG3] (S_ISSOCK): Likewise. [XPG3] (fchmod): Likewise. [XPG3] (lstat): Likewise. [XPG3] (mknod): Likewise.
* conformtest: Fix st_blksize, st_blocks expectations for XPG3, XPG4.Joseph Myers2016-05-102-1/+13
| | | | | | | | | | | | | | | The conformtest expectations expect the struct stat fields st_blksize and st_blocks to be of types blksize_t and blkcnt_t. But XPG4 does not have those types, using long instead, and XPG3 does not have these fields at all. This patch adjusts the expectations for those standards, XFAILing them for XPG4 to allow for systems where the typedefs don't correspond to long. Tested for x86_64 and x86. * conform/data/sys/stat.h-data (st_blksize): Do not expect for [XPG3]. Expect type long and XFAIL for [XPG4]. (st_blocks): Likewise.
* Declare pthread_atfork in unistd.h for UNIX98 (bug 20044).Joseph Myers2016-05-103-1/+15
| | | | | | | | | | | | | | For UNIX98 (only), unistd.h should declare pthread_atfork, but that declaration is missing. This patch adds it. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #20044] * posix/unistd.h [__USE_UNIX98 && !__USE_XOPEN2K] (pthread_atfork): New prototype. * conform/Makefile (test-xfail-UNIX98/unistd.h/conform): Remove variable.
* Declare cuserid in unistd.h for UNIX98 and before (bug 20043).Joseph Myers2016-05-102-2/+12
| | | | | | | | | | | | | For UNIX98 and older X/Open standards, unistd.h should have a declaration of the legacy cuserid function, but such a declaration is missing. This patch adds that missing declaration. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #20043] * posix/unistd.h [__USE_XOPEN && !__USE_XOPEN2K] (cuserid): New prototype.
* resolv: Call gmtime_r instead of gmtime in p_secstodate [BZ #20017]Florian Weimer2016-05-102-6/+7
|
* getaddrinfo: Restore RES_USE_INET6 flag on error path [BZ #19994]Florian Weimer2016-05-102-0/+7
|
* conformtest: Remove some bogus sys/types.h expectations for XPG3 and XPG4.Joseph Myers2016-05-093-2/+14
| | | | | | | | | | | | | | | | | | The conformtest tests for sys/types.h for XPG3 and XPG4 fail because of missing blksize_t. This is a bug in the expectations; that type is not part of those standards. This patch stops the tests from expecting it, and some other types that also are not part of XPG3 and XPG4. Tested for x86_64 and x86. * conform/data/sys/types.h-data (blkcnt_t): Do not expect for [XPG3 || XPG4]. (blksize_t): Likewise. (clockid_t): Likewise. * conform/Makefile (test-xfail-XPG3/sys/types.h/conform): Remove variable. (test-xfail-XPG4/sys/types.h/conform): Likewise.
* S390: Add support for vdso getcpu symbol.Stefan Liebler2016-05-095-0/+21
| | | | | | | | This patch adds support for symbol __kernel_getcpu in vDSO, which is available with kernel 4.5. Now sched_getcpu is using this symbol if available in mapped vDSO by defining macro HAVE_GETCPU_VSYSCALL. If not available at runtime, the former syscall is used.
* Move sysdeps/x86_64/cacheinfo.c to sysdeps/x86H.J. Lu2016-05-083-1/+8
| | | | | | | | | | Move sysdeps/x86_64/cacheinfo.c to sysdeps/x86. No code changes on x86 and x86_64. * sysdeps/i386/cacheinfo.c: Include <sysdeps/x86/cacheinfo.c> instead of <sysdeps/x86_64/cacheinfo.c>. * sysdeps/x86_64/cacheinfo.c: Moved to ... * sysdeps/x86/cacheinfo.c: Here.
* localedata: chr_US: new Cherokee locale [BZ #12143]Neskie Manuel2016-05-073-0/+148
|
* charmaps: IBM875: fix mapping of iota/upsilon variants [BZ #18453]Dimitris Pappas2016-05-072-4/+9
| | | | | The letters ΐ/ϊ and ΰ/ϋ are swapped in the EBCDIC 875 map. Verified against the original IBM spec.
* Revert "aio: fix newp->running data race"Samuel Thibault2016-05-042-12/+3
| | | | This reverts commit fd67a9cf7b733da082e4b6a5f25c19ea7921b4cd.
* malloc: Adjust header file guard in malloc-internal.hFlorian Weimer2016-05-042-3/+7
|
* aio: fix newp->running data raceSamuel Thibault2016-05-042-3/+12
| | | | | | | * sysdeps/pthread/aio_misc.c (__aio_enqueue_request): Do not write `running` field of `newp` when a thread was started to process it, since that thread will not take `__aio_requests_mutex`, and the field already has the proper value actually.
* getnameinfo: Return EAI_OVERFLOW in more cases [BZ #19787]Florian Weimer2016-05-042-52/+63
| | | | | | | The AF_LOCAL and AF_INET/AF_INET6 non-numerci service conversion did not return EAI_OVERFLOW if the supplied buffer was too small, silently returning truncated data. In the AF_INET/AF_INET6 numeric cases, the snprintf return value checking was incorrect.
* getnameinfo: Avoid calling strnlen on uninitialized bufferFlorian Weimer2016-05-042-7/+11
| | | | | | In the numeric AF_INET/AF_INET6 case, if inet_ntop fails as the result of a short host buffer, we used to call strnlen on the uninitialized host buffer.
* getnameinfo: Reduce line length and add missing commentsFlorian Weimer2016-05-042-21/+27
|
* powerpc: Fix operand prefixesGabriel F. T. Gomes2016-05-042-4/+10
| | | | | | | | | | | | | | The file sysdeps/powerpc/sysdeps.h defines aliases for condition register operands. E.g.: 'cr7' means condition register 7. On the one hand, this increases readability, as it makes it easier for readers to know whether the operand is a condition register, a general purpose register or an immediate. On the other hand, this permits that condition registers be written as if they were general purpose, and vice-versa, thus reducing the readability of the code. This commit removes some of these unintentional misuses. The changes have no effect on the final code. Checked with objdump.
* CVE-2016-1234: glob: Do not copy d_name field of struct dirent [BZ #19779]Florian Weimer2016-05-045-100/+184
| | | | | | Instead, we store the data we need from the return value of readdir in an object of the new type struct readdir_result. This type is independent of the layout of struct dirent.
* Fix sys/time.h timespec namespace (bug 20041).Joseph Myers2016-05-033-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | For UNIX98 and older standards, sys/time.h should not define struct timespec, but does so via the inclusion of sys/select.h (which is a new header in the 2001 edition of POSIX, and defines struct timespec because of the declaration of pselect, a new function in the 2001 edition of POSIX). In turn, this affects some other headers that themselves include sys/time.h. This patch fixes this by conditioning the __need_timespec definition in sys/select.h on __USE_XOPEN2K, the same condition used there for the declaration of pselect (this has no effect on direct uses of sys/select.h with feature test macros for any standard that includes that header, since such standards result in __USE_XOPEN2K being defined). Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #20041] * misc/sys/select.h (__need_timespec): Only define if [__USE_XOPEN2K]. * conform/Makefile (test-xfail-XPG4/sys/time.h/conform): Remove variable. (test-xfail-XPG4/utmpx.h/conform): Likewise. (test-xfail-UNIX98/sys/time.h/conform): Likewise. (test-xfail-UNIX98/utmpx.h/conform): Likewise.
* powerpc: Add missing insn in swapcontext [BZ #20004]Paul E. Murphy2016-05-032-0/+8
| | | | | A missing instruction was discovered in the compat version of swapcontext while running the GCC test suite.
* Fix fcntl.h timespec namespace (bug 20023).Joseph Myers2016-05-023-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | fcntl.h defines struct timespec if __USE_XOPEN || __USE_XOPEN2K8. But (a) the subsequent bits/stat.h include only needs it if __USE_XOPEN2K8 and (b) older standards did not allow struct timespec here. (It's allowed for newer standards by virtue of the permission to include symbols from sys/stat.h. But sys/stat.h is only required to provide struct timespec from the 2008 edition of POSIX onwards, and permitted by the 2004 TC to the 2001 edition in anticipation of the addition of nanosecond timestamp support to struct stat in the 2008 edition.) This patch limits the timespec definition to the __USE_XOPEN2K8 case, that being the only case where it is actually needed for the <bits/stat.h> include. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #20023] * io/fcntl.h [__USE_XOPEN && !__USE_XOPEN2K8]: Do not include <time.h>. * conform/Makefile (test-xfail-UNIX98/fcntl.h/conform): Remove variable. (test-xfail-XOPEN2K/fcntl.h/conform): Likewise.
* powerpc: Fix clone CLONE_VM compareAdhemerval Zanella2016-05-022-1/+6
| | | | | | | | | | | | This patch fixes the clone CLONE_VM change from 0cb313f (BZ#19957) where the commit changed the register that contains the save flags argument to compare with (from r28 to r29). This patch changes back to correct register. Tested on powerpc32 (thanks to Tulio Magno Quites Machado Filho). * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S (__clone): Fix flags CLONE_VM compare.
* hesiod: Avoid heap overflow in get_txt_records [BZ #20031]Florian Weimer2016-05-022-1/+7
|
* hesiod: Always use thread-local resolver state [BZ #19573]Florian Weimer2016-05-0211-156/+89
| | | | | | | | | | | | | | | | The Hesiod implementation imported into glibc was enhanced to support caller-supplied resolver states. But its only consumer is nss_hesiod, and it supplies the thread-local resolver state. Therefore, this commit changes the Hesiod implementation to use the thread-local resolver state (_res) directly. This fixes bug 19573 because the Hesiod implementation no longer has to initialize and free any resolver state. To avoid any risk of interposition of ABI-incompatible Hesiod function implementations, this commit marks the Hesiod functions as hidden. (They were already hidden using a linker version script.)
* hesiod: Remove DEF_RHSFlorian Weimer2016-05-023-14/+6
| | | | No functional change because DEF_RHS was already disabled before.
* hesiod: Remove RCS keywordsFlorian Weimer2016-05-024-12/+6
|
* localedata: sgs_LT: new locale [BZ #12450]Arnas Udovičius2016-05-015-1/+168
| | | | Need to also update the database to include the new code.
* m68k: use large PIC model for gcrt1.oAndreas Schwab2016-04-302-0/+7
|
* m68k: avoid local labels in symbol tableAndreas Schwab2016-04-302-4/+8
|
* NSS: Implement group merging support.Stephen Gallagher2016-04-2916-9/+475
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://sourceware.org/glibc/wiki/Proposals/GroupMerging == Justification == It is common today for users to rely on centrally-managed user stores for handling their user accounts. However, much software existing today does not have an innate understanding of such accounts. Instead, they commonly rely on membership in known groups for managing access-control (for example the "wheel" group on Fedora and RHEL systems or the "adm" group on Debian-derived systems). In the present incarnation of nsswitch, the only way to have such groups managed by a remote user store such as FreeIPA or Active Directory would be to manually remove the groups from /etc/group on the clients so that nsswitch would then move past nss_files and into the SSSD, nss-ldap or other remote user database. == Solution == With this patch, a new action is introduced for nsswitch: NSS_ACTION_MERGE. To take advantage of it, one will add [SUCCESS=merge] between two database entries in the nsswitch.conf file. When a group is located in the first of the two group entries, processing will continue on to the next one. If the group is also found in the next entry (and the group name and GID are an exact match), the member list of the second entry will be added to the group object to be returned. == Implementation == After each DL_LOOKUP_FN() returns, the next action is checked. If the function returned NSS_STATUS_SUCCESS and the next action is NSS_ACTION_MERGE, a copy of the result buffer is saved for the next pass through the loop. If on this next pass through the loop the database returns another instance of a group matching both the group name and GID, the member list is added to the previous list and it is returned as a single object. If the following database does not contain the same group, then the original is copied back into the destination buffer. This patch implements merge functionality only for the group database. For other databases, there is a default implementation that will return the EINVAL errno if a merge is requested. The merge functionality can be implemented for other databases at a later time if such is needed. Each database must provide a unique implementation of the deep-copy and merge functions. If [SUCCESS=merge] is present in nsswitch.conf for a glibc version that does not support it, glibc will process results up until that operation, at which time it will return results if it has found them or else will simply return an error. In practical terms, this ends up behaving like the remainder of the nsswitch.conf line does not exist. == Iterators == This feature does not modify the iterator functionality from its current behavior. If getgrnam() or getgrgid() is called, glibc will iterate through all entries in the `group` line in nsswitch.conf and display the list of members without attempting to merge them. This is consistent with the behavior of nss_files where if two separate lines are specified for the same group in /etc/groups, getgrnam()/getgrgid() will display both. Clients are already expected to handle this gracefully. == No Premature Optimizations == The following is a list of places that might be eligible for optimization, but were not overengineered for this initial contribution: * Any situation where a merge may occur will result in one malloc() of the same size as the input buffer. * Any situation where a merge does occur will result in a second malloc() to hold the list of pointers to member name strings. * The list of members is simply concatenated together and is not tested for uniqueness (which is identical to the behavior for nss_files, which will simply return identical values if they both exist on the line in the file. This could potentially be optimized to reduce space usage in the buffer, but it is both complex and computationally expensive to do so. == Testing == I performed testing by running the getent utility against my newly-built glibc and configuring /etc/nsswitch.conf with the following entry: group: group: files [SUCCESS=merge] sss In /etc/group I included the line: wheel:x:10:sgallagh I then configured my local SSSD using the id_provider=local to respond with: wheel:*:10:localuser,localuser2 I then ran `getent group wheel` against the newly-built glibc in multiple situations and received the expected output as described above: * When SSSD was running. * When SSSD was configured in nsswitch.conf but the daemon was not running. * When SSSD was configured in nsswitch.conf but nss_sss.so.2 was not installed on the system. * When the order of 'sss' and 'files' was reversed. * All of the above with the [SUCCESS=merge] removed (to ensure no regressions). * All of the above with `getent group 10`. * All of the above with `getent group` with and without `enumerate=true` set in SSSD. * All of the above with and without nscd enabled on the system.
* libio: Fix fmemopen append mode failure (BZ# 20012)Adhemerval Zanella2016-04-293-14/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fmemopen implementation does not account the file position correctly in append mode. The following example shows the failure: === int main () { char buf[10] = "test"; FILE *fp = fmemopen (buf, 10, "a+"); fseek (fp, 0, SEEK_SET); int gr; if ((gr = getc (fp)) != 't' || (gr = getc (fp)) != 'e' || (gr = getc (fp)) != 's' || (gr = getc (fp)) != 't' || (gr = getc (fp)) != EOF) { printf ("%s: getc failed returned %i\n", __FUNCTION__, gr); return 1; } return 0; } === This is due both how read and write operation update the buffer position, taking in consideration buffer lenght instead of maximum position defined by the open mode. This patch fixes it and also fixes fseek not returning EINVAL for invalid whence modes. Tested on x86_64 and i686. [BZ #20012] * libio/fmemopen.c (fmemopen_read): Use buffer maximum position, not length to calculate the buffer to read. (fmemopen_write): Set the buffer position based on bytes written. (fmemopen_seek): Return EINVAL for invalid whence modes.
* Fix clone (CLONE_VM) pid/tid reset (BZ#19957)Adhemerval Zanella2016-04-2922-141/+250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in libc-alpha [1] current clone with CLONE_VM (without CLONE_THREAD set) will reset the pthread pid/tid fields to -1. The issue is since memory is shared between the parent and child it will clobber parent's cached pid/tid leading to internal inconsistencies if the value is not restored. And even it is restored it may lead to racy conditions when between set/restore a thread might invoke pthread function that validate the pthread with INVALID_TD_P/INVALID_NOT_TERMINATED_TD_P and thus get wrong results. As stated in BZ19957, previously reports of this behaviour was close with EWONTFIX due the fact usage of clone outside glibc is tricky since glibc requires consistent internal pthread, while using clone directly may not provide it. However since now posix_spawn uses clone (CLONE_VM) to fixes various issues related to previous vfork usage this issue requires fixing. The vfork implementation also does something similar, but instead it negates and restores only the *pid* field and functions that might access its value know to handle such case (getpid, raise and pthread ones that uses INVALID_TD_P/INVALID_NOT_TERMINATED_TD_P macros that check only *tid* field). Also vfork does not call __clone directly, instead calling either __NR_vfork or __NR_clone directly. So this patch removes this clone behavior by avoiding setting the pthread pid/tid field for CLONE_VM. There is no need to check for CLONE_THREAD, since the minimum supported kernel in all architecture implies that CLONE_VM must be used with CLONE_THREAD, otherwise clone returns EINVAL. Instead of current approach of: int clone(int (*fn)(void *), void *child_stack, int flags, ...) [...] if (flags & CLONE_THREAD) goto do_syscall; pid_t new_value; if (flags & CLONE_VM) new_value = -1; else new_value = getpid (); THREAD_SETMEM (THREAD_SELF, pid, new_value); THREAD_SETMEM (THREAD_SELF, tid, new_value); do_syscall: [...] The new approach uses: int clone(int (*fn)(void *), void *child_stack, int flags, ...) [...] if (flags & CLONE_VM) goto do_syscall; pid_t new_value = getpid (); THREAD_SETMEM (THREAD_SELF, pid, new_value); THREAD_SETMEM (THREAD_SELF, tid, new_value); do_syscall: [...] It also removes the linux tst-getpid2.c test which expects the previous behavior and instead add another clone test. Tested on x86_64, i686, x32, powerpc64le, aarch64, armhf, s390, and s390x. I also did limited check on mips32 and sparc64 (using the new added test). I also got reviews from both m68k, hppa, and tile. So I presume for these architecture the patch works. The fixes for alpha, microblaze, sh, ia64, and nio2 have not been tested. [1] https://sourceware.org/ml/libc-alpha/2016-04/msg00307.html * sysdeps/unix/sysv/linux/Makefile [$(subdir) == nptl] (test): Remove tst-getpid2. (test): Add tst-clone2. * sysdeps/unix/sysv/linux/tst-clone2.c: New file. * sysdeps/unix/sysv/linux/aarch64/clone.S (__clone): Do not change pid/tid fields for CLONE_VM. * sysdeps/unix/sysv/linux/arm/clone.S: Likewise. * sysdeps/unix/sysv/linux/i386/clone.S: Likewise. * sysdeps/unix/sysv/linux/mips/clone.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise. * sysdeps/unix/sysv/linux/tst-getpid2.c: Remove file.