about summary refs log tree commit diff
path: root/io
Commit message (Collapse)AuthorAgeFilesLines
* Update STATX_ATTR_DAX value from Linux 5.10.Joseph Myers2021-01-111-1/+1
| | | | | | | | This patch updates the value of STATX_ATTR_DAX in bits/statx-generic.h for a change made in Linux 5.10. (As with previous such changes, this only does anything if glibc is being used with old kernel headers.) Tested for x86_64.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-02135-135/+135
| | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
* nonstring: Enable __FORTIFY_LEVEL=3Siddhesh Poyarekar2020-12-311-8/+10
| | | | | Use __builtin_dynamic_object_size in the remaining functions that don't have compiler builtins as is the case for string functions.
* io: Remove xmknod{at} implementationsAdhemerval Zanella2020-12-295-106/+7
| | | | | | | | | | With xmknod wrapper functions removed (589260cef8), the mknod functions are now properly exported, and version is done using symbols versioning instead of the extra _MKNOD_* argument. It also allows us to consolidate Linux and Hurd mknod implementation. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* io: Remove xstat implementationsAdhemerval Zanella2020-12-2917-339/+39
| | | | | | | | With xstat wrapper functions removed (8ed005daf0), the stat functions are now properly exported, and version is done using symbols versioning instead of the extra _STAT_* argument. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* io: nftw/ftw: Fix stack overflow with large nopenfd [BZ #26353]Xiaoming Ni2020-11-263-8/+81
| | | | | | | | | | | The nopenfd value is used as argument for the internal buffer on ftw_statup, which is allocated with alloca and might trigger a stack overflow for large values. This patch replaces the memory allocation to use malloc instead. Checked on x86_64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Remove tls.h inclusion from internal errno.hAdhemerval Zanella2020-11-131-3/+1
| | | | | | | | | | | | The tls.h inclusion is not really required and limits possible definition on more arch specific headers. This is a cleanup to allow inline functions on sysdep.h, more specifically on i386 and ia64 which requires to access some tls definitions its own. No semantic changes expected, checked with a build against all affected ABIs.
* Remove mknod wrapper functions, move them to symbolsAdhemerval Zanella2020-10-095-96/+6
| | | | | | | | | | | | | | | | | | | This patch removes the mknod and mknodat static wrapper and add the symbols on the libc with the expected names. Both the prototypes of the internal symbol linked by the static wrappers and the inline redirectors are also removed from the installed sys/stat.h header file. The wrapper implementation license LGPL exception is also removed since it is no longer statically linked to binaries. Internally the _STAT_VER* definitions are moved to the arch-specific xstatver.h file. Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Remove stat wrapper functions, move them to exported symbolsAdhemerval Zanella2020-10-0911-363/+30
| | | | | | | | | | | | | | | | | | | | | | | | This patch removes the stat, stat64, lstat, lstat64, fstat, fstat64, fstatat, and fstatat64 static wrapper and add the symbol on the libc with the expected names. Both the prototypes of the internal symbol linked by the static wrappers and the inline redirectors are also removed from the installed sys/stat.h header file. The wrapper implementation license LGPL exception is also removed since it is no longer statically linked to binaries. Internally the _STAT_VER* definitions are moved to a arch-specific xstatver.h file. The internal defines that redirects internals {f}stat{at} to their {f}xstat{at} counterparts are removed for Linux (!NO_RTLD_HIDDEN). Hurd still requires them since {f}stat{at} pulls extra objects that makes the loader build fail otherwise (I haven't dig into why exactly). Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Add missing cancellation flags on lockfAdhemerval Zanella2020-10-081-2/+2
| | | | | It also removes CFLAGS-lockf.c duplicate rule. It fixes nptl/tst-cancelx16 on mips64-linux-gnu.
* Remove internal usage of extensible stat functionsAdhemerval Zanella2020-09-1111-45/+47
| | | | | | | | | | | | It replaces the internal usage of __{f,l}xstat{at}{64} with the __{f,l}stat{at}{64}. It should not change the generate code since sys/stat.h explicit defines redirections to internal calls back to xstat* symbols. Checked with a build for all affected ABIs. I also check on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Remove __ASSUME_ATFCTSAdhemerval Zanella2020-09-021-5/+0
| | | | | | The __have_atfcts is not used anywhere. Checked on x86_64-linux-gnu.
* io/lockf: Include bits/types.h before __OFF_T_MATCHES_OFF64_T checkAlistair Francis2020-08-271-0/+2
| | | | | | | | | It's possible that although __OFF_T_MATCHES_OFF64_T is defined the included the relevent header file. This results in a io/tst-lockf failure for RV32 by calling the non 64-bit version of lockf. This patch fixes the failure by including bits/types.h. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Fix namespace violation in stdio.h and sys/stat.h if build with ↵Stefan Liebler2020-08-201-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | optimization. [BZ #26376] If build with optimization, stdio.h and sys/stat.h are defining some inlining functions. This leads to test fails if glibc is build with the following commands. (Note that the conformtests usually builds without optimization or other CFLAGS): <glibc>/configure CC="gcc -O3" --prefix=/usr make make subdirs=conform check - FAIL: conform/XPG4/stdio.h/conform - FAIL: conform/XPG42/stdio.h/conform out-files: ... PASSCOMBINED: Availability of variable optopt PASSCOMBINED: Type of variable optopt Namespace violation: "getc_unlocked" Namespace violation: "getchar_unlocked" Namespace violation: "putc_unlocked" Namespace violation: "putchar_unlocked" FAIL: Namespace of <stdio.h> ---------------------------------------------------------------------------- Total number of tests : 168 Number of failed tests : 1 Number of xfailed tests : 0 Number of skipped tests : 0 - FAIL: conform/POSIX2008/sys/stat.h/conform out-file: ... PASSCOMBINED: Availability of function utimensat PASSCOMBINED: Type of function utimensat Namespace violation: "mknodat" FAIL: Namespace of <sys/stat.h> ---------------------------------------------------------------------------- Total number of tests : 97 Number of failed tests : 1 Number of xfailed tests : 0 Number of skipped tests : 0 For getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked in stdio.h, those are defined "# ifdef __USE_POSIX" instead of "#ifdef __USE_POSIX199506" for the non-inlining declaration. See also "Bug 20014 - stdio.h namespace for pre-threads POSIX" (https://sourceware.org/bugzilla/show_bug.cgi?id=20014). For mknodat in sys/stat.h, those are defined "# ifdef __USE_ATFILE" instead of the additional guard "# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED".
* Add new STATX_* constants from Linux 5.8 to bits/statx-generic.h.Joseph Myers2020-08-191-0/+3
| | | | | | | | | | | | This patch adds the new STATX_MNT_ID, STATX_ATTR_MOUNT_ROOT and STATX_ATTR_DAX macros from Linux 5.8 to glibc's bits/statx-generic.h. (As with previous such changes, this only does anything if glibc is being used with old kernel headers.) A comment in the Linux kernel headers indicates that STATX_ALL is deliberately not being changed. Tested for x86_64.
* Suppress GCC 10 true positive warnings [BZ #25967]Martin Sebor2020-05-111-2/+19
| | | | | | | | | Suppress or avoid warnings in tests that exercise failure modes by making calls with invalid arguments. Reviewed-by: DJ Delorie <dj@redhat.com> Reviewed-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: Joseph Myers <joseph@codesourcery.com>
* Linux: Work around kernel bugs in chmod on /proc/self/fd paths [BZ #14578]Florian Weimer2020-02-181-59/+21
| | | | | | | | | | It appears that the ability to change symbolic link modes through such paths is unintended. On several file systems, the operation fails with EOPNOTSUPP, even though the symbolic link permissions are updated. The expected behavior is a failure to update the permissions, without file system changes. Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
* Move implementation of <file_change_detection.h> into a C fileFlorian Weimer2020-02-184-31/+150
| | | | | | | | | | | file_change_detection_for_stat partially initialize struct file_change_detection in some cases, when the size member alone determines the outcome of all comparisons. This results in maybe-uninitialized compiler warnings in case of sufficiently aggressive inlining. Once the implementation is moved into a separate C file, this kind of inlining is no longer possible, so the compiler warnings are gone.
* Add STATX_ATTR_VERITY from Linux 5.5 to bits/statx-generic.h.Joseph Myers2020-02-131-0/+1
| | | | | | | | This patch adds the new STATX_ATTR_VERITY macro from Linux 5.5 to glibc's bits/statx-generic.h. (This only does anything if glibc is being used with old kernel headers.) Tested for x86_64.
* io: Add io/tst-lchmod covering lchmod and fchmodatFlorian Weimer2020-02-122-1/+315
|
* io: Implement lchmod using fchmodat [BZ #14578]Florian Weimer2020-02-122-6/+5
|
* Add internal <file_change_detection.h> header fileFlorian Weimer2020-02-122-1/+207
| | | | | | | | | | | The code started out with bits form resolv/resolv_conf.c, but it was enhanced to deal with directories and FIFOs in a more predictable manner. A test case is included as well. This will be used to implement the /etc/resolv.conf change detection. This currently lives in a header file only. Once there are multiple users, the implementations should be moved into C files.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-01141-141/+141
|
* hurd: Fix ld.so __access override from libcSamuel Thibault2019-12-011-0/+1
| | | | | | ld.so symbols to be overriden by libc need to be extern to really get overriden. __access happens to have never been exposed, putting it to GLIBC_PRIVATE.
* hurd: Fix ld.so __getcwd override from libcSamuel Thibault2019-12-011-0/+1
| | | | | | ld.so symbols to be overriden by libc need to be extern to really get overriden. __getcwd happens to have never been exposed, putting it to GLIBC_PRIVATE.
* time: Introduce function to check correctness of nanoseconds valueLukasz Majewski2019-10-271-2/+2
| | | | | | | | | | | | | | | The valid_nanoseconds () static inline function has been introduced to check if nanoseconds value is in the correct range - greater or equal to zero and less than 1000000000. The explicit #include <time.h> has been added to files where it was missing. The __syscall_slong_t type for ns has been used to avoid issues on x32. Tested with: - scripts/build-many-glibcs.py - make PARALLELMFLAGS="-j12" && make PARALLELMFLAGS="-j12" xcheck on x86_64
* Prefer https to http for gnu.org and fsf.org URLsPaul Eggert2019-09-07140-140/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
* Add AT_RECURSIVE from Linux 5.2 to fcntl.h.Joseph Myers2019-08-061-0/+1
| | | | | | | | | | This patch adds the AT_RECURSIVE constant from Linux 5.2 to glibc's fcntl.h. (Existing practice in glibc is that the AT_* constants go directly in io/fcntl.h rather than somewhere OS-specific.) Tested for x86_64. * io/fcntl.h [__USE_GNU] (AT_RECURSIVE): New macro.
* nftw: fill in stat buf for dangling links [BZ #23501]DJ Delorie2019-07-083-3/+245
| | | | | | | As per Austin Group interpretation, "the object" wrt a dangling symlink is the symlink itself, despite FTW_PHYS. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* io: Remove copy_file_range emulation [BZ #24744]Florian Weimer2019-06-285-750/+21
| | | | | | | | | | The kernel is evolving this interface (e.g., removal of the restriction on cross-device copies), and keeping up with that is difficult. Applications which need the function should run kernels which support the system call instead of relying on the imperfect glibc emulation. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* <sys/stat.h>: Use Linux UAPI header for statx if available and usefulFlorian Weimer2019-06-126-71/+165
| | | | | This will automatically import new STATX_* constants. It also avoids a conflict between <sys/stat.h> and <linux/stat.h>.
* io: Consolidate lockf implementationAdhemerval Zanella2019-02-154-84/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With internal fcntl64 internal (commit 06ab719d), it is possible to consolidate lockf implementation by using the LFS fcntl interface instead of using arch and system-specific implementations. For Linux, the i386 implementation is used as generic implementation by replacing the direct syscall with fcntl64 call. The LFS symbol alias for default LFS ABI (__OFF_T_MATCHES_OFF64_T) is used to avoid the duplicate symbol (instead of overriding the implementation with an empty file). For Hurd lockf64 semantic is changed: previous generic lockf64 implementation returned EOVERFLOW if LEN input is larger than 32-bit off_t. However, Hurd fcntl64 implementation for F_GETLK64, F_SETLK64, and F_SETLKW64 do accept off64_t inputs (__f_setlk accepts only off64_t inputs). Checked on i686-linux-gnu and x86_64-linux-gnu along with a i686-gnu build. * io/Makefile (tests): Add tst-lockf. * io/lockf.c (lockf): Use __fcntl and only define for !__OFF_T_MATCHES_OFF64_T. * io/lockf64.c (__lockf64): Call __fcntl64 and alias to lockf for __OFF_T_MATCHES_OFF64_T case. * io/tst-lockf.c: New file. * sysdeps/unix/sysv/linux/i386/lockf64.c: Remove file. * sysdeps/unix/sysv/linux/arm/lockf64.c: Likewise. * sysdeps/unix/sysv/linux/m68k/lockf64.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/lockf64.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/lockf64.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/lockf64.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/lockf64.c: Likewise. * sysdeps/unix/sysv/linux/sh/lockf64.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/lockf64.c: Likewise.
* nptl: Remove tst-cancel-wrappers test and related macrosAdhemerval Zanella2019-01-032-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | With upcoming BZ#12683 fix, syscall cancellation is not more handled by {libc,pthread,librt}_{enable,disable}_asynccancel symbols. This renders both LIBC_CANCEL_HANDLED and empty declaration and tst-cancel-wrappers.sh unrequired. This patch removes both the macro and the nptl test. Checked on x86_64-linux-gnu. * io/creat.c (LIBC_CANCEL_HANDLED): Remove macro. * io/ppoll.c (LIBC_CANCEL_HANDLED): Likewise. * misc/pselect.c (LIBC_CANCEL_HANDLED): Likewise. * nptl/pthreadP.h (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/generic/sysdep-cancel.h (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/mach/hurd/sysdep-cancel.h (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/posix/pause.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/posix/sigpause.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/creat.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/creat64.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/sigwait.c (LIBC_CANCEL_HANDLED): Likewise. * sysdeps/unix/sysv/linux/sigwaitinfo.c (LIBC_CANCEL_HANDLED): Likewise. * nptl/Makefile [$(run-built-tests) = yes] (tests-special): Remove tst-cancel-wrappers.sh. (generated): Remove tst-cancel-wrappers.out. (tst-cancel-wrappers.out): Remove rule. * nptl/tst-cancel-wrappers.sh: Remove file.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-01138-138/+138
| | | | | | | * 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.
* Don't reduce test timeout to less than defaultAndreas Schwab2018-10-171-3/+0
| | | | | This removes all overrides of TIMEOUT that are less than or equal to the default timeout.
* Avoid running some tests if the file system does not support holesFlorian Weimer2018-08-212-1/+9
| | | | | Otherwise, these tests fills up the entire disk (or just run very slowly and eventually time out).
* Avoid insecure usage of tmpnam in tests.Joseph Myers2018-07-181-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various glibc testcases use tmpnam in ways subject to race conditions (generate a temporary file name, then later open that file without O_EXCL). This patch fixes those tests to use mkstemp - generally a minimal local fix to use mkstemp instead of tmpnam, rather than a larger fix to use other testsuite infrastructure for temporary files. The unchanged use of tmpnam in posix/wordexp-test.c would fail safe in the event of a race (it's generating a name for use with mkdir rather than for a file to be opened for writing). Tested for x86_64. * grp/tst_fgetgrent.c: Include <unistd.h>. (main): Use mkstemp instead of tmpnam. * io/test-utime.c (main): Likewise. * posix/annexc.c (macrofile): Change to modifiable array. (get_null_defines): Use mkstemp instead of tmpnam. Do not remove macrofile here. * posix/bug-getopt1.c: Include <stdlib.h>. (do_test): Use mkstemp instead of tmpnam. * posix/bug-getopt2.c: Include <stdlib.h>. (do_test): Use mkstemp instead of tmpnam. * posix/bug-getopt3.c: Include <stdlib.h>. (do_test): Use mkstemp instead of tmpnam. * posix/bug-getopt4.c: Include <stdlib.h>. (do_test): Use mkstemp instead of tmpnam. * posix/bug-getopt5.c: Include <stdlib.h>. (do_test): Use mkstemp instead of tmpnam. * stdio-common/bug7.c: Include <stdlib.h> and <unistd.h>. (main): Use mkstemp instead of tmpnam. * stdio-common/tst-fdopen.c: Include <stdlib.h>. (main): Use mkstemp instead of tmpnam. * stdio-common/tst-ungetc.c: Include <stdlib.h>. (main): use mkstemp instead of tmpnam. * stdlib/isomac.c (macrofile): Change to modifiable array. (get_null_defines): Use mkstemp instead of tmpnam. Do not remove macrofile here.
* Install <bits/statx.h> headerFlorian Weimer2018-07-111-1/+1
|
* Add the statx functionFlorian Weimer2018-07-108-1/+371
|
* Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)Adhemerval Zanella2018-06-264-2/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Avoid cancellable I/O primitives in ld.so.Zack Weinberg2018-06-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Revert __dirfd PLT avoidance for nowSamuel Thibault2018-04-021-1/+1
| | | | * io/fts.c (fts_build): Call dirfd instead of __dirfd.
* hurd: Avoid some PLTs in libc and librtSamuel Thibault2018-04-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Add missing start-of-file descriptive comment.Samuel Thibault2018-03-062-2/+3
| | | | | | | | | | | | | | | * 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.
* Fix a typo in a comment.Rical Jasan2018-02-211-1/+1
| | | | * io/fcntl.h: Fix a typo in a comment.
* Revert "hurd: Fix building io/tst-fchownat.c"Samuel Thibault2018-01-281-1/+1
| | | | This reverts commit fc221145a734d128d8f56f40d40fd4bb70a1d151.
* hurd: Fix building io/tst-copy_file_range.cSamuel Thibault2018-01-281-1/+3
| | | | | * io/tst-copy_file_range.c [!defined CLONE_NEWNS]: Do not include <sys/mount.h>.
* hurd: Fix building io/tst-fchownat.cSamuel Thibault2018-01-281-1/+1
| | | | | * io/tst-fchownat.c [!defined _POSIX_CHOWN_RESTRICTED]: Act like when _POSIX_CHOWN_RESTRICTED is defined to 0.
* linux: make getcwd(3) fail if it cannot obtain an absolute path [BZ #22679]Dmitry V. Levin2018-01-122-1/+67
| | | | | | | | | | | | | | | | | | | | | | | | | Currently getcwd(3) can succeed without returning an absolute path because the underlying getcwd syscall, starting with linux commit v2.6.36-rc1~96^2~2, may succeed without returning an absolute path. This is a conformance issue because "The getcwd() function shall place an absolute pathname of the current working directory in the array pointed to by buf, and return buf". This is also a security issue because a non-absolute path returned by getcwd(3) causes a buffer underflow in realpath(3). Fix this by checking the path returned by getcwd syscall and falling back to generic_getcwd if the path is not absolute, effectively making getcwd(3) fail with ENOENT. The error code is chosen for consistency with the case when the current directory is unlinked. [BZ #22679] CVE-2018-1000001 * sysdeps/unix/sysv/linux/getcwd.c (__getcwd): Fall back to generic_getcwd if the path returned by getcwd syscall is not absolute. * io/tst-getcwd-abspath.c: New test. * io/Makefile (tests): Add tst-getcwd-abspath.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-01132-132/+132
| | | | | | | * 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.