about summary refs log tree commit diff
path: root/io/bits
Commit message (Collapse)AuthorAgeFilesLines
* Always define __USE_TIME_BITS64 when 64 bit time_t is usedAdhemerval Zanella2024-04-021-1/+1
| | | | | | | | | | | | | | | | | | | | It was raised on libc-help [1] that some Linux kernel interfaces expect the libc to define __USE_TIME_BITS64 to indicate the time_t size for the kABI. Different than defined by the initial y2038 design document [2], the __USE_TIME_BITS64 is only defined for ABIs that support more than one time_t size (by defining the _TIME_BITS for each module). The 64 bit time_t redirects are now enabled using a different internal define (__USE_TIME64_REDIRECTS). There is no expected change in semantic or code generation. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, and arm-linux-gnueabi [1] https://sourceware.org/pipermail/libc-help/2024-January/006557.html [2] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign Reviewed-by: DJ Delorie <dj@redhat.com>
* Add STATX_MNT_ID_UNIQUE from Linux 6.8 to bits/statx-generic.hJoseph Myers2024-03-151-0/+1
| | | | | | | Linux 6.8 adds a new STATX_MNT_ID_UNIQUE constant. Add it to glibc's bits/statx-generic.h. Tested for x86_64.
* debug: Improve fcntl.h fortify warnings with clangAdhemerval Zanella2024-02-271-0/+92
| | | | | | | | | It improves open, open64, openat, and openat64. The compile and runtime checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* socket: Improve fortify with clangAdhemerval Zanella2024-02-271-8/+21
| | | | | | | | | It improve fortify checks recv, recvfrom, poll, and ppoll. The compile and runtime hecks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Update copyright dates with scripts/update-copyrightsPaul Eggert2024-01-016-6/+6
|
* Add STATX_DIOALIGN from Linux 6.1 to bits/statx-generic.hJoseph Myers2023-01-171-0/+1
| | | | | | | Linux 6.1 adds a new STATX_DIOALIGN constant. Add it to glibc's bits/statx-generic.h. Tested for x86_64.
* Update copyright dates with scripts/update-copyrightsJoseph Myers2023-01-066-6/+6
|
* Linux: Add ppoll fortify symbol for 64 bit time_t (BZ# 29746)Adhemerval Zanella2022-11-081-0/+25
| | | | | | | | | | | | | | | | | | | | Similar to ppoll, the poll.h header needs to redirect the poll call to a proper fortified ppoll with 64 bit time_t support. The implementation is straightforward, just need to add a similar check as __poll_chk and call the 64 bit time_t ppoll version. The debug fortify tests are also extended to cover 64 bit time_t for affected ABIs. Unfortunately it requires an aditional symbol, which makes backport tricky. One possibility is to add a static inline version if compiler supports is and call abort instead of __chk_fail, so fortified version will call __poll64 in the end. Another possibility is to just remove the fortify support for _TIME_BITS=64. Checked on i686-linux-gnu.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-016-6/+6
| | | | | | | | | | | | | | | | | | | | | | | 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 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
* Make sure that the fortified function conditionals are constantSiddhesh Poyarekar2021-10-201-21/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In _FORTIFY_SOURCE=3, the size expression may be non-constant, resulting in branches in the inline functions remaining intact and causing a tiny overhead. Clang (and in future, gcc) make sure that the -1 case is always safe, i.e. any comparison of the generated expression with (size_t)-1 is always false so that bit is taken care of. The rest is avoidable since we want the _chk variant whenever we have a size expression and it's not -1. Rework the conditionals in a uniform way to clearly indicate two conditions at compile time: - Either the size is unknown (-1) or we know at compile time that the operation length is less than the object size. We can call the original function in this case. It could be that either the length, object size or both are non-constant, but the compiler, through range analysis, is able to fold the *comparison* to a constant. - The size and length are known and the compiler can see at compile time that operation length > object size. This is valid grounds for a warning at compile time, followed by emitting the _chk variant. For everything else, emit the _chk variant. This simplifies most of the fortified function implementations and at the same time, ensures that only one call from _chk or the regular function is emitted. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Don't add access size hints to fortifiable functionsSiddhesh Poyarekar2021-10-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the context of a function definition, the size hints imply that the size of an object pointed to by one parameter is another parameter. This doesn't make sense for the fortified versions of the functions since that's the bit it's trying to validate. This is harmless with __builtin_object_size since it has fairly simple semantics when it comes to objects passed as function parameters. With __builtin_dynamic_object_size we could (as my patchset for gcc[1] already does) use the access attribute to determine the object size in the general case but it misleads the fortified functions. Basically the problem occurs when access attributes are present on regular functions that have inline fortified definitions to generate _chk variants; the attributes get inherited by these definitions, causing problems when analyzing them. For example with poll(fds, nfds, timeout), nfds is hinted using the __attr_access as being the size of fds. Now, when analyzing the inline function definition in bits/poll2.h, the compiler sees that nfds is the size of fds and tries to use that information in the function body. In _FORTIFY_SOURCE=3 case, where the object size could be a non-constant expression, this information results in the conclusion that nfds is the size of fds, which defeats the purpose of the implementation because we're trying to check here if nfds does indeed represent the size of fds. Hence for this case, it is best to not have the access attribute. With the attributes gone, the expression evaluation should get delayed until the function is actually inlined into its destinations. Disable the access attribute for fortified function inline functions when building at _FORTIFY_SOURCE=3 to make this work better. The access attributes remain for the _chk variants since they can be used by the compiler to warn when the caller is passing invalid arguments. [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581125.html Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Annotate additional APIs with GCC attribute access.Martin Sebor2021-05-061-4/+6
| | | | | | | | | | | | | | | | This change continues the improvements to compile-time out of bounds checking by decorating more APIs with either attribute access, or by explicitly providing the array bound in APIs such as tmpnam() that expect arrays of some minimum size as arguments. (The latter feature is new in GCC 11.) The only effects of the attribute and/or the array bound is to check and diagnose calls to the functions that fail to provide a sufficient number of elements, and the definitions of the functions that access elements outside the specified bounds. (There is no interplay with _FORTIFY_SOURCE here yet.) Tested with GCC 7 through 11 on x86_64-linux.
* 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-026-6/+6
| | | | | | | | | | | | | | | | 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.
* 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.
* 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.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-016-6/+6
|
* Prefer https to http for gnu.org and fsf.org URLsPaul Eggert2019-09-076-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* <sys/stat.h>: Use Linux UAPI header for statx if available and usefulFlorian Weimer2019-06-124-69/+152
| | | | | This will automatically import new STATX_* constants. It also avoids a conflict between <sys/stat.h> and <linux/stat.h>.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-013-3/+3
| | | | | | | * 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.
* Add the statx functionFlorian Weimer2018-07-101-0/+91
|
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-012-2/+2
| | | | | | | * 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.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2017-01-012-2/+2
|
* Update copyright dates with scripts/update-copyrights.Joseph Myers2016-01-042-2/+2
|
* linux: open and openat ignore 'mode' with O_TMPFILE in flagsEric Rannaud2015-02-241-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both open and openat load their last argument 'mode' lazily, using va_arg() only if O_CREAT is found in oflag. This is wrong, mode is also necessary if O_TMPFILE is in oflag. By chance on x86_64, the problem wasn't evident when using O_TMPFILE with open, as the 3rd argument of open, even when not loaded with va_arg, is left untouched in RDX, where the syscall expects it. However, openat was not so lucky, and O_TMPFILE couldn't be used: mode is the 4th argument, in RCX, but the syscall expects its 4th argument in a different register than the glibc wrapper, in R10. Introduce a macro __OPEN_NEEDS_MODE (oflag) to test if either O_CREAT or O_TMPFILE is set in oflag. Tested on Linux x86_64. [BZ #17523] * io/fcntl.h (__OPEN_NEEDS_MODE): New macro. * io/bits/fcntl2.h (open): Use it. (openat): Likewise. * io/open.c (__libc_open): Likewise. * io/open64.c (__libc_open64): Likewise. * io/open64_2.c (__open64_2): Likewise. * io/open_2.c (__open_2): Likewise. * io/openat.c (__openat): Likewise. * io/openat64.c (__openat64): Likewise. * io/openat64_2.c (__openat64_2): Likewise. * io/openat_2.c (__openat_2): Likewise. * sysdeps/mach/hurd/open.c (__libc_open): Likewise. * sysdeps/mach/hurd/openat.c (__openat): Likewise. * sysdeps/posix/open64.c (__libc_open64): Likewise. * sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise. * sysdeps/unix/sysv/linux/generic/open.c (__libc_open): Likewise. (__open_nocancel): Likewise. * sysdeps/unix/sysv/linux/generic/open64.c (__libc_open64): Likewise. * sysdeps/unix/sysv/linux/open64.c (__libc_open64): Likewise. * sysdeps/unix/sysv/linux/openat.c (__OPENAT): Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2015-01-022-2/+2
|
* Update copyright notices with scripts/update-copyrightsAllan McRae2014-01-012-2/+2
|
* Update copyright notices with scripts/update-copyrights.Joseph Myers2013-01-022-2/+2
|
* Fix attributes for fortify functions.Marek Polacek2012-04-292-6/+6
|
* Replace FSF snail mail address with URLs.Paul Eggert2012-02-092-6/+4
|
* bits/poll2.h needs __BEGIN/__END_DECLSUlrich Drepper2012-01-081-0/+4
|
* Add checking versions of poll and ppollUlrich Drepper2012-01-081-0/+78
|
* Remove pre-ISO C supportUlrich Drepper2012-01-071-17/+17
| | | | No more __const.
* * rt/Versions (librt): Export __mq_open_2@@GLIBC_2.7.Ulrich Drepper2007-09-151-130/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * rt/Makefile (headers): Add bits/mqueue2.h. * rt/mqueue.h: Include bits/mqueue2.h if -D_FORTIFY_SOURCE=2, optimizing with GCC and __va_arg_pack_len is defined. * rt/bits/mqueue2.h: New file. * rt/mq_open.c (__mq_open): Renamed from mq_open. (mq_open): New strong_alias. (__mq_open_2): New function. * sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Renamed from mq_open. (mq_open): New strong_alias. (__mq_open_2): New function. * debug/Versions (libc): Export __fortify_fail@@GLIBC_PRIVATE. * Versions.def (librt): Add GLIBC_2.7 version. * debug/fortify_fail.c (__fortify_fail): Add libc_hidden_def. * include/stdio.h (__fortify_fail): Add libc_hidden_proto. * misc/sys/cdefs.h (__errordecl, __va_arg_pack_len): Define. * io/fcntl.h: Include bits/fcntl2.h when __va_arg_pack_len is defined rather than when not C++. * io/bits/fcntl2.h (__open_alias, __open64_alias, __openat_alias, __openat64_alias): New redirects. (__open_too_many_args, __open_missing_mode, __open64_too_many_args, __open64_missing_mode, __openat_too_many_args, __openat_missing_mode, __openat64_too_many_args, __openat64_missing_mode): New __errordecls. (open, open64, openat, openat64): Rewrite as __extern_always_inline functions instead of function-like macros.
* * io/bits/fcntl2.h (open, open64, openat, openat64): Add Jakub Jelinek2007-08-041-116/+124
| | | | | | | | __extension__ around the whole statement expression. 2007-08-04 Jakub Jelinek <jakub@redhat.com> * io/bits/fcntl2.h (open, open64, openat, openat64): Add __extension__ around the whole statement expression.
* * io/bits/fcntl2.h (__open_2): Add nonnull attribute.Ulrich Drepper2007-05-251-26/+48
| | | | | | | | | | | | | | | | (open): Fix comment typos. Don't call __open_2 if flags is a compile time constant without O_CREAT. (__open64_2): Add nonnull attribute. (open64): Fix comment typos. Don't call __open64_2 if flags is a compile time constant without O_CREAT. (__openat_2): Add nonnull attribute, fix nonnull attribute on redirect. (openat): Fix comment typos. Don't call __openat_2 if flags is a compile time constant without O_CREAT. (__openat64_2): Add nonnull attribute, fix nonnull attribute on redirect. (openat64): Fix comment typos. Don't call __openat64_2 if flags is a compile time constant without O_CREAT.
* * sysdeps/powerpc/tls.h (tcbhead_t): Add gscope_flag.Ulrich Drepper2007-05-251-9/+9
| | | | | | | | | | | | | (THREAD_GSCOPE_FLAG_UNUSED, THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT): Define. (THREAD_GSCOPE_GET_FLAG, THREAD_GSCOPE_SET_FLAG, THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_WAIT): Define. * sysdeps/i386/tls.h (THREAD_GSCOPE_WAIT): Don't use PTR_DEMANGLE. (THREAD_GSCOPE_GET_FLAG): Define. * sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Define. * allocatestack.c (__wait_lookup_done): Use THREAD_GSCOPE_GET_FLAG instead of ->header.gscope_flag directly.
* * Makerules (sysd-rules): Define PTW for ptw-* files.Ulrich Drepper2007-05-241-0/+155
* Versions: Define GLIBC_2.7 for libc. * include/stdio.h: Declare __fortify_fail. * debug/fortify_fail.c: New file. * debug/Makefile (routines): Add fortify_fail. * debug/chk_fail.c: Use __fortify_fail. * debug/stack_chk_fail.c: Likewise. * io/Versions: Export __open_2, __open64_2, __openat_2, and __openat64_2 for GLIBC_2.7. * io/fcntl.h: When compiling with fortification, include bits/fcntl2.h. * io/open.c: Define *_2 variant of function which checks for O_CREAT and fails if necessary. * io/open64.c: Likewise. * io/openat.c: Likewise. * io/openat64.c: Likewise. * sysdeps/unix/sysv/linux/open64.c: Likewise. * sysdeps/unix/sysv/linux/openat.c: Likewise. * sysdeps/unix/sysv/linux/openat64.c: Likewise. * io/bits/fcntl2.h: New file. * include/fcntl.h: Declare __open_2, __open64_2, __openat_2, and __openat64_2. * include/bits/fcntl2.h: New file. * sysdeps/unix/sysv/linux/Makefile [subdir=io] (sysdep_routines): Add open_2. * sysdeps/unix/sysv/linux/open_2.c: New file.