summaryrefslogtreecommitdiff
path: root/sysdeps/posix
AgeCommit message (Collapse)Author
2018-06-26Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)Adhemerval Zanella
This patch fixes the OFD ("file private") locks for architectures that support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and F_{SET,GET}L{W}K64 expects a flock64 argument and when using old F_OFD_* flags with a non LFS flock argument the kernel might interpret the underlying data wrongly. Kernel idea originally was to avoid using such flags in non-LFS syscall, but since GLIBC uses fcntl with LFS semantic as default it is possible to provide the functionality and avoid the bogus struct kernel passing by adjusting the struct manually for the required flags. The idea follows other LFS interfaces that provide two symbols: 1. A new LFS fcntl64 is added on default ABI with the usual macros to select it for FILE_OFFSET_BITS=64. 2. The Linux non-LFS fcntl use a stack allocated struct flock64 for F_OFD_{GETLK,SETLK,SETLKW} copy the results on the user provided struct. 3. Keep a compat symbol with old broken semantic for architectures that do not define __OFF_T_MATCHES_OFF64_T. So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will aliased to fcntl and no adjustment would be required. So to actually use F_OFD_* with LFS support the source must be built with LFS support (_FILE_OFFSET_BITS=64). Also F_OFD_SETLKW command is handled a cancellation point, as for F_SETLKW{64}. Checked on x86_64-linux-gnu and i686-linux-gnu. [BZ #20251] * NEWS: Mention fcntl64 addition. * csu/check_fds.c: Replace __fcntl_nocancel by __fcntl64_nocancel. * login/utmp_file.c: Likewise. * sysdeps/posix/fdopendir.c: Likewise. * sysdeps/posix/opendir.c: Likewise. * sysdeps/unix/pt-fcntl.c: Likewise. * include/fcntl.h (__libc_fcntl64, __fcntl64, __fcntl64_nocancel_adjusted): New prototype. (__fcntl_nocancel_adjusted): Remove prototype. * io/Makefile (routines): Add fcntl64. (CFLAGS-fcntl64.c): New rule. * io/Versions [GLIBC_2.28] (fcntl64): New symbol. [GLIBC_PRIVATE] (__libc_fcntl): Rename to __libc_fcntl64. * io/fcntl.h (fcntl64): Add prototype and redirect if __USE_FILE_OFFSET64 is defined. * io/fcntl64.c: New file. * manual/llio.text: Add a note for which commands fcntl acts a cancellation point. * nptl/Makefile (CFLAGS-fcntl64.c): New rule. * sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols. * sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl, fcntl64): New symbols. * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64, F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for non-LFS case. * sysdeps/unix/sysv/linux/fcntl64.c: New file. * sysdeps/unix/sysv/linux/fcntl_nocancel.c (__fcntl_nocancel): Rename to __fcntl64_nocancel. (__fcntl_nocancel_adjusted): Rename to __fcntl64_nocancel_adjusted. * sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): Rename to __fcntl64_nocancel. * sysdeps/unix/sysv/linux/tst-ofdlocks.c: New file. * sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise. * sysdeps/unix/sysv/linux/Makefile (tests): Add tst-ofdlocks. (tests-internal): Add tst-ofdlocks-compat. * sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28] (fcntl64): New symbol. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libc.abilist [GLIBC_2.28] (fcntl, fcntl64): Likewise. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
2018-06-12Avoid cancellable I/O primitives in ld.so.Zack Weinberg
Neither the <dlfcn.h> entry points, nor lazy symbol resolution, nor initial shared library load-up, are cancellation points, so ld.so should exclusively use I/O primitives that are not cancellable. We currently achieve this by having the cancellation hooks compile as no-ops when IS_IN(rtld); this patch changes to using exclusively _nocancel primitives in the source code instead, which makes the intent clearer and significantly reduces the amount of code compiled under IS_IN(rtld) as well as IS_IN(libc) -- in particular, elf/Makefile no longer thinks we require a copy of unwind.c in rtld-libc.a. (The older mechanism is preserved as a backstop.) The bulk of the change is splitting up the files that define the _nocancel I/O functions, so they don't also define the variants that *are* cancellation points; after which, the existing logic for picking out the bits of libc that need to be recompiled as part of ld.so Just Works. I did this for all of the _nocancel functions, not just the ones used by ld.so, for consistency. fcntl was a little tricky because it's only a cancellation point for certain opcodes (F_SETLKW(64), which can block), and the existing __fcntl_nocancel wasn't applying the FCNTL_ADJUST_CMD hook, which strikes me as asking for trouble, especially as the only nontrivial definition of FCNTL_ADJUST_CMD (for powerpc64) changes F_*LK* opcodes. To fix this, fcntl_common moves to fcntl_nocancel.c along with __fcntl_nocancel, and changes its name to the extern (but hidden) symbol __fcntl_nocancel_adjusted, so that regular fcntl can continue calling it. __fcntl_nocancel now applies FCNTL_ADJUST_CMD; so that both both fcntl.c and fcntl_nocancel.c can see it, the only nontrivial definition moves from sysdeps/u/s/l/powerpc/powerpc64/fcntl.c to .../powerpc64/sysdep.h and becomes entirely a macro, instead of a macro that calls an inline function. The nptl version of libpthread also changes a little, because its "compat-routines" formerly included files that defined all the _nocancel functions it uses; instead of continuing to duplicate them, I exported the relevant ones from libc.so as GLIBC_PRIVATE. Since the Linux fcntl.c calls a function defined by fcntl_nocancel.c, it can no longer be used from libpthread.so; instead, introduce a custom forwarder, pt-fcntl.c, and export __libc_fcntl from libc.so as GLIBC_PRIVATE. The nios2-linux ABI doesn't include a copy of vfork() in libpthread, and it was handling that by manipulating libpthread-routines in .../linux/nios2/Makefile; it is cleaner to do what other such ports do, and have a pt-vfork.S that defines no symbols. Right now, it appears that Hurd does not implement _nocancel I/O, so sysdeps/generic/not-cancel.h will forward everything back to the regular functions. This changed the names of some of the functions that sysdeps/mach/hurd/dl-sysdep.c needs to interpose. * elf/dl-load.c, elf/dl-misc.c, elf/dl-profile.c, elf/rtld.c * sysdeps/unix/sysv/linux/dl-sysdep.c Include not-cancel.h. Use __close_nocancel instead of __close, __open64_nocancel instead of __open, __read_nocancel instead of __libc_read, and __write_nocancel instead of __libc_write. * csu/check_fds.c (check_one_fd) * sysdeps/posix/fdopendir.c (__fdopendir) * sysdeps/posix/opendir.c (__alloc_dir): Use __fcntl_nocancel instead of __fcntl and/or __libc_fcntl. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np) * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np) * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Use __open64_nocancel instead of __open_nocancel. * sysdeps/unix/sysv/linux/not-cancel.h: Move all of the hidden_proto declarations to the end and issue them if either IS_IN(libc) or IS_IN(rtld). * sysdeps/unix/sysv/linux/Makefile [subdir=io] (sysdep_routines): Add close_nocancel, fcntl_nocancel, nanosleep_nocancel, open_nocancel, open64_nocancel, openat_nocancel, pause_nocancel, read_nocancel, waitpid_nocancel, write_nocancel. * io/Versions [GLIBC_PRIVATE]: Add __libc_fcntl, __fcntl_nocancel, __open64_nocancel, __write_nocancel. * posix/Versions: Add __nanosleep_nocancel, __pause_nocancel. * nptl/pt-fcntl.c: New file. * nptl/Makefile (pthread-compat-wrappers): Remove fcntl. (libpthread-routines): Add pt-fcntl. * include/fcntl.h (__fcntl_nocancel_adjusted): New function. (__libc_fcntl): Remove attribute_hidden. * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Call __fcntl_nocancel_adjusted, not fcntl_common. (__fcntl_nocancel): Move to new file fcntl_nocancel.c. (fcntl_common): Rename to __fcntl_nocancel_adjusted; also move to fcntl_nocancel.c. * sysdeps/unix/sysv/linux/fcntl_nocancel.c: New file. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file. * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Define FCNTL_ADJUST_CMD here, as a self-contained macro. * sysdeps/unix/sysv/linux/close.c: Move __close_nocancel to... * sysdeps/unix/sysv/linux/close_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/nanosleep.c: Move __nanosleep_nocancel to... * sysdeps/unix/sysv/linux/nanosleep_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/open.c: Move __open_nocancel to... * sysdeps/unix/sysv/linux/open_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/open64.c: Move __open64_nocancel to... * sysdeps/unix/sysv/linux/open64_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/openat.c: Move __openat_nocancel to... * sysdeps/unix/sysv/linux/openat_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/openat64.c: Move __openat64_nocancel to... * sysdeps/unix/sysv/linux/openat64_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/pause.c: Move __pause_nocancel to... * sysdeps/unix/sysv/linux/pause_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/read.c: Move __read_nocancel to... * sysdeps/unix/sysv/linux/read_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/waitpid.c: Move __waitpid_nocancel to... * sysdeps/unix/sysv/linux/waitpid_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/write.c: Move __write_nocancel to... * sysdeps/unix/sysv/linux/write_nocancel.c: ...this new file. * sysdeps/unix/sysv/linux/nios2/Makefile: Don't override libpthread-routines. * sysdeps/unix/sysv/linux/nios2/pt-vfork.S: New file which defines nothing. * sysdeps/mach/hurd/dl-sysdep.c: Define __read instead of __libc_read, and __write instead of __libc_write. Define __open64 in addition to __open.
2018-06-08posix: Fix posix_spawnp to not execute invalid binaries in non compat mode ↵Adhemerval Zanella
(BZ#23264) Current posix_spawnp implementation wrongly tries to execute invalid binaries (for instance script without shebang) as a shell script in non compat mode. It was a regression introduced by 9ff72da471a509a8c19791efe469f47fa6977410 when __spawni started to use __execvpe instead of __execve (glibc __execvpe try to execute ENOEXEC as shell script regardless). This patch fixes it by using an internal symbol (__execvpex) with the faulty semantic (since compat mode is handled by spawni.c itself). It was reported by Daniel Drake on libc-help [1]. Checked on x86_64-linux-gnu and i686-linux-gnu. [BZ #23264] * include/unistd.h (__execvpex): New prototype. * posix/Makefile (tests): Add tst-spawn4. (tests-internal): Add tst-spawn4-compat. * posix/execvpe.c (__execvpe_common, __execvpex): New functions. * posix/tst-spawn4-compat.c: New file. * posix/tst-spawn4.c: Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni): Do not interpret invalid binaries as shell scripts. * sysdeps/posix/spawni.c (__spawni): Likewise. [1] https://sourceware.org/ml/libc-help/2018-06/msg00012.html
2018-05-23Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247]Florian Weimer
This provides an implementation of the IDNA2008 standard and fixes CVE-2016-6261, CVE-2016-6263, CVE-2017-14062.
2018-04-06Consolidate Linux readdir{64}{_r} implementationAdhemerval Zanella
This patch consolidates Linux readdir{64}{_r} implementation on just the default sysdeps/unix/sysv/linux/readdir{64}{_r}.c ones. The default implementation handle the Linux requirements: * readdir{_r} is only built for _DIRENT_MATCHES_DIRENT64 being 0. * readdir64{_r} is always built and aliased to readdir{_r} for ABI that define _DIRENT_MATCHES_DIRENT64. * A compat symbol is added for readdir64{_r} for ABI that used to export the old non-LFS version. Checked on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, sparcv9-linux-gnu, sparc64-linux-gnu, powerpc-linux-gnu, and powerpc64le-linux-gnu. * sysdeps/posix/readdir.c (__READDIR, __GETDENTS, DIRENTY_TYPE, __READDIR_ALIAS): Undefine after usage. * sysdeps/posix/readdir_r.c (__READDIR_R, __GETDENTS, DIRENT_TYPE, __READDIR_R_ALIAS): Likewise. * sysdeps/unix/sysv/linux/arm/readdir64.c: Remove file. * sysdeps/unix/sysv/linux/arm/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/m68k/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/m68k/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/i386/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/i386/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/readdir.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c: Likewise. * sysdeps/unix/sysv/linux/readdir.c: New file. * sysdeps/unix/sysv/linux/readdir_r.c: Likewise. * sysdeps/unix/sysv/linux/readdir64.c: Add compat symbol if required. * sysdeps/unix/sysv/linux/readdir64_r.c: Likewise.
2018-04-05hurd: Avoid PLT for dirfdSamuel Thibault
* include/dirent.h (dirfd): Add hidden proto. * dirent/dirfd.c (dirfd): Add hidden def. * sysdeps/mach/hurd/dirfd.c (dirfd): Add hidden def. * sysdeps/posix/dirfd.c (dirfd): Add hidden def.
2018-04-03Filter out NPTL internal signals (BZ #22391)Adhemerval Zanella
This patch filters out the internal NPTL signals (SIGCANCEL/SIGTIMER and SIGSETXID) from signal functions. GLIBC on Linux requires both signals to proper implement pthread cancellation, posix timers, and set*id posix thread synchronization. And not filtering out the internal signal is troublesome: - A conformant program on a architecture that does not filter out the signals might inadvertently disable pthread asynchronous cancellation, set*id synchronization or posix timers. - It might also to security issues if SIGSETXID is masked and set*id functions are called (some threads might have effective user or group id different from the rest). The changes are basically: - Change __is_internal_signal to bool and used on all signal function that has a signal number as input. Also for signal function which accepts signals sets (sigset_t) it assumes that canonical function were used to add/remove signals which lead to some input simplification. - Fix tst-sigset.c to avoid check for SIGCANCEL/SIGTIMER and SIGSETXID. It is rewritten to check each signal indidually and to check realtime signals using canonical macros. - Add generic __clear_internal_signals and __is_internal_signal version since both symbols are used on generic implementations. - Remove superflous sysdeps/nptl/sigfillset.c. - Remove superflous SIGTIMER handling on Linux __is_internal_signal since it is the same of SIGCANCEL. - Remove dangling define and obvious comment on nptl/sigaction.c. Checked on x86_64-linux-gnu. [BZ #22391] * nptl/sigaction.c (__sigaction): Use __is_internal_signal to check for internal nptl signals. * nptl/sigaction.c (__sigaction): Likewise. * signal/sigaddset.c (sigaddset): Likewise. * signal/sigdelset.c (sigdelset): Likewise. * sysdeps/posix/signal.c (__bsd_signal): Likewise. * sysdeps/posix/sigset.c (sigset): Call and check sigaddset return value. * signal/sigfillset.c (sigfillset): User __clear_internal_signals to filter out internal nptl signals. * signal/tst-sigset.c (do_test): Check ech signal indidually and also check realtime signals using standard macros. * sysdeps/generic/internal-signals.h (__clear_internal_signals, __is_internal_signal, __libc_signal_block_all, __libc_signal_block_app, __libc_signal_restore_set): New functions. * sysdeps/nptl/sigfillset.c: Remove file. * sysdeps/unix/sysv/linux/internal-signals.h (__is_internal_signal): Change return to bool. (__clear_internal_signals): Remove SIGTIMER clean since it is equal to SIGCANEL on Linux. * sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Assume signal set was constructed using standard functions. Reported-by: Yury Norov <ynorov@caviumnetworks.com>
2018-04-03Assume O_DIRECTORY for opendirAdhemerval Zanella
This patch assumes O_DIRECTORY works as defined by POSIX on opendir implementation (aligning with other glibc code, for instance pwd). This allows remove both the fallback code to handle system with missing or broken O_DIRECTORY along with the Linux specific opendir.c which just advertise the working flag. Checked on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu, sparcv9-linux-gnu, sparc64-linux-gnu, powerpc-linux-gnu, and powerpc64le-linux-gnu. * sysdeps/posix/opendir.c (o_directory_works, tryopen_o_directory): Remove definitions. (opendir_oflags): Use O_DIRECTORY regardless. (__opendir, __opendirat): Remove need_isdir_precheck usage. * sysdeps/unix/sysv/linux/opendir.c: Remove file.
2018-04-02hurd: Avoid some PLTs in libc and librtSamuel Thibault
* hurd/hurdauth.c (_S_msg_add_auth): Call __vm_allocate and __vm_deallocate instead of vm_allocate and vm_deallocate. * hurd/hurdmsg.c (_S_msg_set_env_variable): Call __setenv instead of setenv. * hurd/hurdprio.c (_hurd_priority_which_map): Call __geteuid instead of geteuid. * hurd/path-lookup.c (file_name_path_scan): Call __strdup instead of strdup. * hurd/siginfo.c: Include <libioP.h>. (_hurd_siginfo_handler): Call _IO_puts instead of puts. * hurd/xattr.c (_hurd_xattr_get, _hurd_xattr_set): Call __munmap instead of munmap. * io/fts.c (fts_build): Call __dirfd instead of dirfd. * mach/devstream.c: Include <libioP.h>. (dealloc_ref): Call __mach_port_deallocate instead of mach_port_deallocate. (mach_open_devstream): Call _IO_fopencookie instead of fopencookie. Call __mach_port_deallocate instead of mach_port_deallocate. * stdlib/canonicalize.c (__realpath): Call __pathconf instead of pathconf. * sysdeps/mach/hurd/ifreq.c (__ifreq): Call __munmap instead of munmap. * sysdeps/mach/hurd/ifreq.h (__if_freereq): Likewise. * sysdeps/mach/hurd/ptrace.c (ptrace): Call __kill instead of kill. * sysdeps/mach/hurd/sendfile64.c (sendfile64): Call __munmap instead of munmap. * sysdeps/mach/hurd/socketpair.c (__socketpair): Call __close instead of close. * sysdeps/posix/clock_getres.c (realtime_getres): Call __sysconf instead of sysconf. * sysdeps/pthread/timer_gettime.c (timer_gettime): Call __clock_gettime instead of clock_gettime. * sysdeps/pthread/timer_routines.c (thread_func): Likewise. * sysdeps/pthread/timer_settime.c (timer_settime): Likewise. * sysdeps/unix/bsd/gtty.c (gtty): Call __ioctl instead of ioctl. * sysdeps/unix/bsd/stty.c (stty): Likewise. * sysdeps/unix/bsd/tcflow.c (tcflow): Call __tcgetattr instead of tcgetattr. * sysdeps/unix/clock_nanosleep.c (__clock_nanosleep): Call __clock_gettime and __nanosleep instead of clock_gettime and nanosleep.
2018-03-06Add missing start-of-file descriptive comment.Samuel Thibault
* io/futimens.c: Add missing start-of-file descriptive comment. * io/utime.c: Likewise. * misc/futimesat.c: Likewise. * misc/utimes.c: Likewise. * sysdeps/mach/hurd/futimesat.c: Likewise. * sysdeps/mach/hurd/utimes.c: Likewise. * sysdeps/posix/utime.c: Likewise. * sysdeps/posix/utimes.c: Likewise. * sysdeps/unix/sysv/linux/futimesat.c: Likewise. * sysdeps/unix/sysv/linux/generic/futimesat.c: Likewise. * sysdeps/unix/sysv/linux/generic/utimes.c: Likewise. * sysdeps/unix/sysv/linux/utimes.c: Likewise.
2018-02-15Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).Joseph Myers
Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for feof_unlocked. The usual approach is followed of adding __feof_unlocked (inlined when feof_unlocked is), making calls use it when required for namespace reasons, and using libc_hidden_proto / libc_hidden_weak for the feof_unlocked weak alias when only localplt but not namespace issues are involved. In the case of getaddrinfo.c, use of __feof_unlocked needs to be conditional since that code is also used in nscd (where __feof_unlocked is not available). Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). Because of other such failures that remain after this patch, neither of the bugs can yet be closed. [BZ #15105] [BZ #19463] * libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and define as weak alias of __feof_unlocked. Use libc_hidden_weak. * include/stdio.h (feof_unlocked): Use libc_hidden_proto. (__feof_unlocked): New declaration, and inline function if [__USE_EXTERN_INLINES]. * iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked instead of feof_unlocked. * intl/localealias.c [_LIBC] (FEOF): Likewise. * nss/nsswitch.c (nss_parse_file): Likewise. * sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area): Likewise. * time/getdate.c (__getdate_r): Likewise. * sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked): Define as macro to call __feof_unlocked.
2018-02-02preadv2/pwritev2: Handle offset == -1 [BZ #22753]Florian Weimer
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-01-29Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, ↵Andreas Schwab
_POSIX_VDISABLE POSIX requires that the constants _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, and _POSIX_VDISABLE are always defined to a value other than -1.
2018-01-07hurd: Fix pwritev*Samuel Thibault
This follows c45d78aac ('posix: Fix generic p{read,write}v buffer allocation (BZ#22457)'), which made pwritev to use __mmap instead of __posix_memalign, but didn't pass PROT_READ to it, while the pwrite() call does need to read the data we have just copied over. * sysdeps/posix/pwritev_common.c: Add PROT_READ to __mmap prot.
2018-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
* All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
2017-11-24posix: Fix generic p{read,write}v buffer allocation (BZ#22457)Adhemerval Zanella
As described in BZ#22457 an interpose malloc can free an invalid pointer for fallback preadv implementation. Fortunately this is just and issue on microblaze-linux-gnu running kernels older than 3.15. This patch fixes it by calling mmap/unmap instead of posix_memalign/ free. Checked on microblaze-linux-gnu check with run-built-tests=no and by using the sysdeps/posix implementation on x86_64-linux-gnu (just for sanity test where it shown no regression). [BZ #22457] * sysdeps/posix/preadv_common.c (PREADV): Use mmap/munmap instead of posix_memalign/free. * sysdeps/posix/pwritev_common.c (PWRITEV): Likewise.
2017-11-15Cleanup sigpause implementationAdhemerval Zanella
This patch simplify sigpause by remobing the single thread optimization since it will be handled already by the __sigsuspend call. Checked on x86_64-linux-gnu. * sysdeps/posix/sigpause.c (do_sigpause): Remove. (__sigpause): Rely on __sigsuspend to implement single thread optimization. Add LIBC_CANCEL_HANDLED for cancellation marking. Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Zack Weinberg <zackw@panix.com>
2017-10-20sysconf: Fix missing definition of UIO_MAXIOV on Linux [BZ #22321]Florian Weimer
After commit 37f802f86400684c8d13403958b2c598721d6360 (Remove __need_IOV_MAX and __need_FOPEN_MAX), UIO_MAXIOV is no longer supplied (indirectly) through <bits/stdio_lim.h>, so sysdeps/posix/sysconf.c no longer sees the definition.
2017-10-01Hide internal idna functions [BZ #18822]H.J. Lu
Hide internal idna functions to allow direct access within libc.so and libc.a without using GOT nor PLT. [BZ #18822] * include/idna.h: New file. * inet/getnameinfo.c: Include <idna.h> instead of <libidn/idna.h>. (__idna_to_unicode_lzlz): Removed. * sysdeps/posix/getaddrinfo.c: Include <idna.h> instead of <libidn/idna.h>. (__idna_to_ascii_lz): Removed. (__idna_to_unicode_lzlz): Likewise.
2017-10-01Hide internal signal functions [BZ #18822]H.J. Lu
Hide internal signal functions to allow direct access within libc.so and libc.a without using GOT nor PLT. __GI___kill and __GI___sigaltstack are defined when syscalls.list is used to generate them. Otherwise libc_hidden_def is needed explicitly. [BZ #18822] * include/signal.h (__kill): Add libc_hidden_proto. (__sigblock): Likewise. (__sigprocmask): Likewise. (__sigaltstack): Likewise. * signal/kill.c (__kill): Add libc_hidden_def. * signal/sigblock.c (__sigblock): Likewise. * signal/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/mach/hurd/kill.c (__kill): Likewise. * sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise. * sysdeps/mach/hurd/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/posix/sigblock.c (__sigblock): Likewise. * sysdeps/unix/sysv/linux/alpha/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/ia64/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/sigprocmask.c (__sigprocmask): Likewise. * /sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/x86_64/sigprocmask.c (__sigprocmask): Likewise.
2017-10-01Hide __readv and __writev [BZ #18822]H.J. Lu
Hide internal __readv and __writev functions to allow direct access within libc.so and libc.a without using GOT nor PLT. [BZ #18822] * include/sys/uio.h (__readv): Add libc_hidden_proto. (__writev): Likewise. * misc/readv.c (__readv): Add libc_hidden_def. * misc/writev.c (__writev): Likewise. * sysdeps/posix/readv.c (__readv): Likewise. * sysdeps/posix/writev.c (__writev): Likewise. * sysdeps/unix/sysv/linux/readv.c: Include <sys/uio.h>. (__readv): Likewise. * sysdeps/unix/sysv/linux/writev.c: Include <sys/uio.h>. (__writev): Likewise.
2017-09-28hurd: Fix dirfd symbol exposition from ftwSamuel Thibault
dirfd is XOPEN2K8 only, it should not be exposed along ftw which is earlier. * include/dirent.h (__dirfd): New declaration. * dirent/dirfd.c (dirfd): Rename to __dirfd, and redefine as weak alias. * sysdeps/posix/dirfd/dirfd.c (dirfd): Likewise. * sysdeps/mach/hurd/dirfd.c (dirfd): Likewise. * io/ftw.c (open_dir_stream, ftw_dir): Use __dirfd instead of dirfd.
2017-09-17Add missing libc_hidden_weak/def callsSamuel Thibault
* io/read.c (read): Add libc_hidden_weak. * sysdeps/mach/hurd/read.c (read): Likewise. * io/write.c (write): Likewise. * sysdeps/mach/hurd/write.c (write): Likewise. * io/pread64.c (__pread64): Likewise. * sysdeps/mach/hurd/pread64.c (__pread64): Likewise. * posix/pread64.c (__pread64): Add libc_hidden_def.
2017-09-03hurd: Fix libc linkSamuel Thibault
* sysdeps/posix/pause.c: Include <sigsetops.h>. * sysdeps/posix/system.c: Include <sigsetops.h>.
2017-09-03hurd: Fix p{read,write}{,v64}v2.c buildSamuel Thibault
* misc/preadv2.c: Include <errno.h>. * misc/preadv64v2.c: Include <errno.h>. * misc/pwritev2.c: Include <errno.h>. * misc/pwritev64v2.c: Include <errno.h>. * sysdeps/posix/preadv2.c: Include <errno.h>. * sysdeps/posix/preadv64v2.c: Include <errno.h>. Fix <unistd.h> inclusion. * sysdeps/posix/pwritev2.c: Include <errno.h>. * sysdeps/posix/pwritev64v2.c: Include <errno.h>.
2017-09-03hurd: Fix p{read,write}v64v2.c buildSamuel Thibault
* sysdeps/posix/preadv64v2.c: Use off64_t instead of off_t. * sysdeps/posix/pwritev64v2.c: Use off64_t instead of off_t.
2017-09-03hurd: Fix p{read,write}{,v64}v2.c buildSamuel Thibault
* sysdeps/posix/preadv2.c: Use off_t instead of OFF_T. * sysdeps/posix/preadv64v2.c: Use off_t instead of OFF_T. * sysdeps/posix/pwritev2.c: Use off_t instead of OFF_T. * sysdeps/posix/pwritev64v2.c: Use off_t instead of OFF_T.
2017-09-01getaddrinfo: Fix error handling in gethosts [BZ #21915] [BZ #21922]Florian Weimer
The old code uses errno as the primary indicator for success or failure. This is wrong because errno is only set for specific combinations of the status return value and the h_errno variable.
2017-09-01getaddrinfo: Return EAI_NODATA if gethostbyname2_r reports NO_DATA [BZ #21922]Florian Weimer
2017-09-01getaddrinfo: In gaih_inet, use h_errno for certain status values onlyFlorian Weimer
h_errno is not set for NSS_STATUS_SUCCESS, so its value might not be accurate at this point.
2017-09-01getaddrinfo: Properly set errno for NSS function lookup failureFlorian Weimer
2017-09-01getaddrinfo: Use &h_errno has the h_errno pointerFlorian Weimer
This simplifies the code because it is not necessary to propagate the temporary h_errno value to the thread-local variable. It also increases compatibility with NSS modules which update only one of the two places.
2017-09-01getaddrinfo: Use &errno has the errno pointerFlorian Weimer
Similar code in nss/getXXbyYY_r.c is already using &errno as the argument.
2017-08-31posix: Remove internal_function attributeFlorian Weimer
2017-08-31dirent: Remove internal_function attributeFlorian Weimer
2017-08-22Consolidate non cancellable pause callAdhemerval Zanella
This patch consolidates all the non cancellable pause calls to use the __pause_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace pause_not_cancel with __pause_nocancel. * sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro. (__pause_nocancel): New macro. * sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove macro. (__pause_nocancel): New prototype. * sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function.
2017-08-21Mark internal nss symbols with attribute_hidden [BZ #18822]H.J. Lu
Mark internal nss symbols with attribute_hidden to allow direct access within libc.so and libc.a without using GOT nor PLT. Tested on x86-64 with and without --disable-nscd. [BZ #18822] * grp/initgroups.c (__nss_group_database): Removed. (__nss_initgroups_database): Likewise. * nscd/gai.c (__nss_hosts_database): Likewise. * nss/XXX-lookup.c (DATABASE_NAME_SYMBOL): Likewise. * posix/tst-rfc3484-2.c (__nss_hosts_database): Likewise. * posix/tst-rfc3484-3.c (__nss_hosts_database): Likewise. * posix/tst-rfc3484.c (__nss_hosts_database): Likewise. * sysdeps/posix/getaddrinfo.c (__nss_hosts_database): Likewise. * nss/getXXent.c (INTERNAL (REENTRANT_GETNAME)): Add attribute_hidden. * nss/nsswitch.c (__nss_database_custom): Define only if USE_NSCD is defined. (__nss_configure_lookup): Use __nss_database_custom only if USE_NSCD is defined. * nss/nsswitch.h (__nss_database_custom): Declare only if USE_NSCD is defined. Add attribute_hidden. (__nss_setent): Add attribute_hidden. (__nss_endent): Likewise. (__nss_getent_r): Likewise. (__nss_getent): Likewise. (DEFINE_DATABASE): Declare __nss_##arg##_database.
2017-08-18Consolidate non cancellable close callAdhemerval Zanella
This patch consolidates all the non cancellable close calls to use the __close_nocancel{_nostatus} identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Also, since it is used on libcrypto it is also exported in GLIBC_PRIVATE namespace. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro. (close_not_cancel_no_status): Likewise. (__close_nocancel): New macro. (__close_nocancel_no_status): Likewise. * sysdeps/unix/sysv/linux/not-cancel.h (__close_nocancel): Remove macro. (close_not_cancel): Likewise. (close_not_cancel_no_status): Likewise. (__close_nocancel): New prototype. (__close_nocancel_no_status): New function. * sysdeps/unix/sysv/linux/close.c (__close_nocancel): New function. * catgets/open_catalog.c (__open_catalog): Replace close_not_cancel{_no_status) with __close_nocancel{_nostatus}. * gmon/gmon.c (write_gmon): Likewise. * iconv/gconv_cache.c (__gconv_load_cache): Likewise. * intl/loadmsgcat.c (close): Likewise. * io/ftw.c (open_dir_stream): Likewise. (ftw_startup): Likewise. * libio/fileops.c (_IO_file_open): Likewise. (_IO_file_close_mmap): Likewise. (_IO_file_close): Likewise. * libio/iopopen.c (_IO_dup2): Likewise. * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise. * locale/loadlocale.c (_nl_load_locale): Likewise. * login/utmp_file.c (pututline_file): Likewise. (endutent_file): Likewise. * misc/daemon.c (daemon): Likewise. * nscd/nscd_getai.c (__nscd_getai): Likewise. * nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise. * nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise. * nscd/nscd_getpw_r.c (nscd_getpw_r): Likewise. * nscd/nscd_getserv_r.c (nscd_getserv_r): Likewise. * nscd/nscd_helper.c (open_socket): Likewise. (__nscd_open_socket): Likewise. * nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise. * nscd/nscd_netgroup.c (__nscd_setnetgrent): Likewise. (__nscd_innetgr): Likewise. * nss/nss_db/db-open.c (internal_setent): Likewise. * resolv/res-close.c (__res_iclose): Likewise. * sunrpc/pm_getmaps.c (pmap_getmaps): Likewise. * sysdeps/posix/closedir.c (__closedir): Likewise. * sysdeps/posix/getaddrinfo.c (getaddrinfo): Likewise. * sysdeps/posix/getcwd.c (__getcwd): Likewise. * sysdeps/posix/opendir.c (tryopen_o_directory): Likewise. (opendir_tail): Likewise. * sysdeps/posix/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/check_native.c (__check_native): Likewise. * sysdeps/unix/sysv/linux/check_pf.c (__check_pf): Likewise. * sysdeps/unix/sysv/linux/fips-private.h (fips_enabled_p): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise. (gethostid): Likewise. * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise. * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise. * sysdeps/unix/sysv/linux/grantpt.c (close_all_fds): Likewise. * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise. * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock): Likewise. * sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap): Likewise. * sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Likewise. * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
2017-08-18Consolidate non cancellable openat callAdhemerval Zanella
This patch consolidates all the non cancellable openat{64} calls to use the __openat{64}_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (openat_not_cancel): Remove macro. (openat_not_cancel_3): Likewise. (openat64_not_cancel_3): Likewise). (openat_not_cancel_3): Likewise). * sysdeps/unix/sysv/linux/not-cancel.h (openat_not_cancel): Remove macro. (openat_not_cancel_3): Likewise. (openat64_not_cancel): Likewise. (openat64_not_cancel_3): Likewise. * sysdeps/unix/sysv/linux/openat.c (__openat_nocancel): New function. * sysdeps/unix/sysv/linux/openat64.c (__openat64_nocancel): Likewise. * io/ftw.c (open_dir_stream): Replace openat{64}_not_cancel{_3} with __open{64}_nocancel. * sysdeps/mach/hurd/opendir.c (__opendirat): Likewise. * sysdeps/posix/getcwd.c (__getcwd): Likewise. * sysdeps/posix/opendir.c (__opendirat): Likewise.
2017-08-18Consolidate non cancellable write callAdhemerval Zanella
This patch consolidates all the non cancellable write calls to use the __write_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (write_not_cancel): Remove macro. (__write_nocancel): New macro. * sysdeps/unix/sysv/linux/not-cancel.h (__write_nocancel): Rewrite as a function prototype. (write_not_cancel): Remove macro. * sysdeps/unix/sysv/linux/write.c (__write_nocancel): New function. * gmon/gmon.c (ERR): Replace write_not_cancel with __write_nocancel. (write_gmon): Likewise. * libio/fileops.c (_IO_new_file_write): Likewise. * login/utmp_file.c (pututline_file): Likewise. (updwtmp_file): Likewise. * stdio-common/psiginfo.c (psiginfo): Likewise. * sysdeps/posix/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise.
2017-08-17Consolidate non cancellable open callAdhemerval Zanella
This patch consolidates all the non cancellable open calls to use the __open_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. To be consistent with the following non cancellable openat call, a new __open64_nocancel is also added (although not currently used). Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (open_not_cancel): Remove macro. (open_not_cancel_2): Likewise. (open_nocancel): New macro. (open64_nocancel): Likewise. * sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Remove macro. (open_not_cancel_2): Likewise. (__open_nocancel): New prototype. (__open64_nocancel): Likewise. * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add __open_nocancel. * sysdeps/unix/sysv/linux/open.c (__open_nocancel): New function. * sysdeps/unix/sysv/linux/open64.c (__open64_nocancel): Likewise. * catgets/open_catalog.c (__open_catalog): Replace open_not_cancel{_2} with __open_nocancel. * csu/check_fds.c (check_one_fd): Likewise. * gmon/gmon.c (write_gmon): Likewise. * iconv/gconv_cache.c (__gconv_load_cached): Likewise. * intl/loadmsgcat.c (open): Likewise. * libio/fileops.c (_IO_file_open): Likewise. * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise. * locale/loadlocale.c (_nl_load_locale): Likewise. * login/utmp_file.c (setutent_file): Likewise. * misc/daemon.c (daemon): Likewise. * nss/nss_db/db-open.c (internal_setent): Likewise. * sysdeps/mach/hurd/opendir.c (__opendirat): Likewise. * sysdeps/posix/libc_fatal.c (__libc_message): Likewise. * sysdeps/posix/opendir.c (tryopen_o_directory): Likewise. (__opendir): Likewise. * sysdeps/posix/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise. (gethostid): Likewise. * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise. * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise. * sysdeps/unix/sysv/linux/grantpt.c (__close_all_fds): Likewise. * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise. * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap): Likewise. * sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c (__get_clockfreq): Likewise. * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
2017-08-08Do not use __ptr_t.Joseph Myers
sys/cdefs.h has a macro __ptr_t, which a few places in glibc use instead of void *. void * is a well-understood standard type for that purpose and in a post-C89 context there is no need for a macro for it; this patch changes those places to use void * directly instead. Unlike __long_double_t, __ptr_t is widely used outside glibc (or at least has many hits on codesearch.debian.net). I don't know how many of those uses would break if sys/cdefs.h ceased to define the macro, but there's enough risk that this patch leaves the definition and just removes the uses within glibc; removal of the definition can be considered separately if desired. Tested for x86_64, and with build-many-glibcs.py. * malloc/mcheck.c (old_free_hook): Use void * instead of __ptr_t. (old_malloc_hook): Likewise. (old_memalign_hook): Likewise. (old_realloc_hook): Likewise. (struct hdr): Likewise. (flood): Likewise. (freehook): Likewise. (mallochook): Likewise. (memalignhook): Likewise. (reallochook): Likewise. (mprobe): Likewise. * malloc/mtrace.c (mallwatch): Likewise. (tr_old_free_hook): Likewise. (tr_old_malloc_hook): Likewise. (tr_old_realloc_hook): Likewise. (tr_old_memalign_hook): Likewise. (tr_where): Likewise. (lock_and_info): Likewise. (tr_freehook): Likewise. (tr_mallochook): Likewise. (tr_reallochook): Likewise. (tr_memalignhook): Likewise. * misc/err.h [!__GNUC_VA_LIST] (__gnuc_va_list): Likewise. * misc/mmap.c (__mmap): Likewise. * misc/mmap64.c (__mmap64): Likewise. * misc/mprotect.c (__mprotect): Likewise. * misc/msync.c (msync): Likewise. * misc/munmap.c (__munmap): Likewise. * posix/posix_madvise.c (posix_madvise): Likewise. * socket/send.c (__send): Likewise. * socket/sendto.c (__sendto): Likewise. * socket/setsockopt.c (__setsockopt): Likewise. * string/memcmp.c (__ptr_t): Remove macro. (MEMCMP): Use void * instead of ptr_t. * string/memrchr.c (__ptr_t): Remove macro. (__memrchr): Use void * instead of ptr_t. * sysdeps/mach/hurd/dl-sysdep.c (__mmap): Likewise. * sysdeps/mach/hurd/mmap.c (__mmap): Likewise. * sysdeps/mach/hurd/mmap64.c (__mmap64): Likewise. * sysdeps/mach/mprotect.c (__mprotect): Likewise. * sysdeps/mach/msync.c (msync): Likewise. * sysdeps/mach/munmap.c (__munmap): Likewise. * sysdeps/mips/bits/setjmp.h (struct __jmp_buf_internal_tag): Likewise. * sysdeps/posix/getcwd.c (__getcwd): Likewise. * sysdeps/powerpc/powerpc32/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc32/power4/memcpy.S (memcpy): Likewise. * sysdeps/powerpc/powerpc32/power4/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc32/power6/memcpy.S (memcpy): Likewise. * sysdeps/powerpc/powerpc32/power6/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc32/power7/memcpy.S (memcpy): Likewise. * sysdeps/powerpc/powerpc32/power7/mempcpy.S (__mempcpy): Likewise. * sysdeps/powerpc/powerpc32/power7/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc64/memcpy.S (memcpy): Likewise. * sysdeps/powerpc/powerpc64/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc64/power4/memcpy.S (memcpy): Likewise. * sysdeps/powerpc/powerpc64/power4/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc64/power6/memcpy.S (memcpy): Likewise. * sysdeps/powerpc/powerpc64/power6/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc64/power7/memcpy.S (memcpy): Likewise. * sysdeps/powerpc/powerpc64/power7/mempcpy.S (__mempcpy): Likewise. * sysdeps/powerpc/powerpc64/power7/memset.S (memset): Likewise. * sysdeps/powerpc/powerpc64/power8/memset.S (memset): Likewise. * sysdeps/tile/memcmp.c (__ptr_t): Remove macro. (MEMCMP): Use void * instead of ptr_t. * sysdeps/unix/sysv/linux/alpha/oldglob.c (old_glob_t): Likewise. * sysdeps/unix/sysv/linux/mmap.c (__mmap): Likewise.
2017-08-08getaddrinfo: Remove unreachable return statement from gaih_inetFlorian Weimer
2017-08-08posix: Set p{read,write}v2 to return ENOTSUP (BZ#21780)Adhemerval Zanella
Different than other architectures hppa-linux-gnu define different values for ENOTSUP and EOPNOTSUPP, where the later is a Linux specific one. This leads to tst-preadwritev{64}v2 tests failures: $ ./testrun.sh misc/tst-preadvwritev2 error: tst-preadvwritev2-common.c:35: preadv2 failure did not set errno to ENOTSUP (223) error: 1 test failures The straightforward fix is to return the POSIX defined ENOTSUP on all p{read,write}v{64}v2 implementations instead of Linux specific one. Checked on x86_64-linux-gnu and the tst-preadwritev{64}v2 on hppa-linux-gnu (although due the installed kernel on my testing system the pwritev{64}v2 with an invalid flag still fails due a known kernel issue [1]). [BZ #21780] * sysdeps/posix/preadv2.c (preadv2): Use ENOTSUP instead of EOPNOTSUPP. * sysdeps/posix/preadv64v2.c (preadv64v2): Likewise. * sysdeps/posix/pwritev2.c (pwritev2): Likewise. * sysdeps/posix/pwritev64v2.c (pwritev64v2): Likewise. * sysdeps/unix/sysv/linux/preadv2.c (preadv2): Likewise. * sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise. * sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise. * sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise. [1] https://sourceware.org/ml/libc-alpha/2017-06/msg00726.html
2017-08-03getaddrinfo: Release resolver context on error in gethosts [BZ #21885]Florian Weimer
2017-08-03Add missing include for pthread_setcancelstateSamuel Thibault
* sysdeps/posix/shm_open.c: Include <pthread.h>.
2017-07-24Avoid accessing corrupted stack from __stack_chk_fail [BZ #21752]H.J. Lu
__libc_argv[0] points to address on stack and __libc_secure_getenv accesses environment variables which are on stack. We should avoid accessing stack when stack is corrupted. This patch also renames function argument in __fortify_fail_abort from do_backtrace to need_backtrace to avoid confusion with do_backtrace from enum __libc_message_action. [BZ #21752] * debug/fortify_fail.c (__fortify_fail_abort): Don't pass down __libc_argv[0] if we aren't doing backtrace. Rename do_backtrace to need_backtrace. * sysdeps/posix/libc_fatal.c (__libc_message): Don't call __libc_secure_getenv if we aren't doing backtrace.
2017-07-11Avoid backtrace from __stack_chk_fail [BZ #12189]H.J. Lu
__stack_chk_fail is called on corrupted stack. Stack backtrace is very unreliable against corrupted stack. __libc_message is changed to accept enum __libc_message_action and call BEFORE_ABORT only if action includes do_backtrace. __fortify_fail_abort is added to avoid backtrace from __stack_chk_fail. [BZ #12189] * debug/Makefile (CFLAGS-tst-ssp-1.c): New. (tests): Add tst-ssp-1 if -fstack-protector works. * debug/fortify_fail.c: Include <stdbool.h>. (_fortify_fail_abort): New function. (__fortify_fail): Call _fortify_fail_abort. (__fortify_fail_abort): Add a hidden definition. * debug/stack_chk_fail.c: Include <stdbool.h>. (__stack_chk_fail): Call __fortify_fail_abort, instead of __fortify_fail. * debug/tst-ssp-1.c: New file. * include/stdio.h (__libc_message_action): New enum. (__libc_message): Replace int with enum __libc_message_action. (__fortify_fail_abort): New hidden prototype. * malloc/malloc.c (malloc_printerr): Update __libc_message calls. * sysdeps/posix/libc_fatal.c (__libc_message): Replace int with enum __libc_message_action. Call BEFORE_ABORT only if action includes do_backtrace. (__libc_fatal): Update __libc_message call.
2017-07-05posix: Fix default posix_spawn return valueAdhemerval Zanella
This patch fix the return value for error conditions for default posix_spawn (where the errno is expected). It also avoid clobber errno on fork call. Checked on x86_64 (with Linux implementation removed). [BZ# 21697] * sysdeps/posix/spawni.c (__spawni_child): Fix return value. (__spawnix): Do not clober errno.
2017-07-03resolv: Introduce struct resolv_context [BZ #21668]Florian Weimer
struct resolv_context objects provide a temporary resolver context which does not change during a name lookup operation. Only when the outmost context is created, the stub resolver configuration is verified to be current (at present, only against previous res_init calls). Subsequent attempts to obtain the context will reuse the result of the initial verification operation. struct resolv_context can also be extended in the future to store data which needs to be deallocated during thread cancellation.