about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* Update syscall lists for Linux 6.4Joseph Myers2023-06-285-2/+7
| | | | | | | | Linux 6.4 adds the riscv_hwprobe syscall on riscv and enables memfd_secret on s390. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
* linux: Return unsupported if procfs can not be mount on tst-ttyname-namespaceAdhemerval Zanella2023-06-281-12/+16
| | | | | | | | | | | | | | | | Trying to mount procfs can fail due multiples reasons: proc is locked due the container configuration, mount syscall is filtered by a Linux Secuirty Module, or any other security or hardening mechanism that Linux might eventually add. The tests does require a new procfs without binding to parent, and to fully fix it would require to change how the container was created (which is out of the scope of the test itself). Instead of trying to foresee any possible scenario, if procfs can not be mount fail with unsupported. Checked on aarch64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* linux: Split tst-ttynameAdhemerval Zanella2023-06-284-206/+259
| | | | | | | | | | The tst-ttyname-direct.c checks the ttyname with procfs mounted in bind mode (MS_BIND|MS_REC), while tst-ttyname-namespace.c checks with procfs mount with MS_NOSUID|MS_NOEXEC|MS_NODEV in a new namespace. Checked on x86_64-linux-gnu and aarch64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Use Linux 6.4 in build-many-glibcs.pyJoseph Myers2023-06-271-1/+1
| | | | | | | This patch makes build-many-glibcs.py use Linux 6.4. Tested with build-many-glibcs.py (host-libraries, compilers and glibcs builds).
* x86: Adjust Linux x32 dl-cache inclusion pathAdhemerval Zanella2023-06-261-1/+1
| | | | | | It fixes the x32 build failure introduced by 45e2483a6c. Checked on a x86_64-linux-gnu-x32 build.
* elf: Update list of RISC-V relocationsAndreas Schwab2023-06-261-1/+4
|
* Fix tests-clean Makefile target (bug 30545)Maxim Kuvyrkov2023-06-262-19/+9
| | | | | | | | | | This patch improves tests-clean Makefile target to reliably clean test artifacts from a build directory. Before this patch tests-clean missed around 3k (out of total 9k) .out and .test-result files. Signed-off-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* check_native: Get rid of allocaJoe Simmons-Talbott2023-06-261-24/+11
| | | | | | Use malloc rather than alloca to avoid potential stack overflow. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ifaddrs: Get rid of allocaJoe Simmons-Talbott2023-06-261-26/+20
| | | | | | Use scratch_buffer and malloc rather than alloca to avoid potential stack overflows. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* x86: Make dl-cache.h and readelflib.c not Linux-specificSergey Bugaev2023-06-262-0/+0
| | | | | | | These files could be useful to any port that wants to use ld.so.cache. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Port ldconfig away from stack-allocated pathsSergey Bugaev2023-06-261-37/+22
| | | | | | | | | | | | | | | | | | ldconfig was allocating PATH_MAX bytes on the stack for the library file name. The issues with PATH_MAX usage are well documented [0][1]; even if a program does not rely on paths being limited to PATH_MAX bytes, allocating 4096 bytes on the stack for paths that are typically rather short (strlen ("/lib64/libc.so.6") is 16) is wasteful and dangerous. [0]: https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html [1]: https://eklitzke.org/path-max-is-tricky Instead, make use of asprintf to dynamically allocate memory of just the right size on the heap. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Florian Weimer <fweimer@redhat.com> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* Call "CST" a time zone abbreviation, not a namePaul Eggert2023-06-228-21/+21
| | | | | | In documentation, call strings like "CST" time zone abbreviations, not time zone names. This terminology is more precise, and is what tzdb uses. A string like "CST" is ambiguous and does not fully name a time zone.
* benchtests: fix warn unused resultFrederic Berat2023-06-222-2/+7
| | | | | | | Few tests needed to properly check for asprintf and system calls return values with _FORTIFY_SOURCE enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c: Fix warn unused resultFrederic Berat2023-06-221-1/+3
| | | | | | | The fread routine return value needs to be checked when fortification is enabled, hence use xfread helper. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* rt/tst-mqueue4.c: Fix wrong number of argument for mq_openFrederic Berat2023-06-221-2/+2
| | | | | | | The mq_open routine should only get either 2 or 4 arguments, this test wrongly passed 3. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* debug/readlink{, at}_chk.c: Harmonize declaration and definitionFrederic Berat2023-06-222-2/+4
| | | | | | | | | | The declaration and definition of these routines aren't consistent. Make the definition of __readlink_chk and __readlinkat_chk match the declaration of the routines they fortify. While there are no problems today this avoids any future potential problems related to the mismatch. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* wcsmbs/bits/wchar2{, -decl}.h: Clearly separate declaration from definitionsFrederic Berat2023-06-223-192/+173
| | | | | | | | | | | | This will enable __REDIRECT_FORTIFY* macros to be used when _FORTIFY_SOURCE is set. Routine declarations that were in bits/wchar2.h are moved into the bits/wchar2-decl.h file. The file is now included into include/wchar.h irrespectively from fortification. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* stdio-common: tests: Incorrect maxlen parameter for swprintfFrederic Berat2023-06-222-11/+12
| | | | | | | Few tests using swprintf are passing incorrect maxlen parameter. This triggers an abort when _FORTIFY_SOURCE is enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* sysdeps/{i386, x86_64}/mempcpy_chk.S: fix linknamespace for __mempcpy_chkFrederic Berat2023-06-222-2/+2
| | | | | | | | | | | | | On i386 and x86_64, for libc.a specifically, __mempcpy_chk calls mempcpy which leads POSIX routines to call non-POSIX mempcpy indirectly. This leads the linknamespace test to fail when glibc is built with __FORTIFY_SOURCE=3. Since calling mempcpy doesn't bring any benefit for libc.a, directly call __mempcpy instead. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* hurd: readv: Get rid of allocaJoe Simmons-Talbott2023-06-201-16/+12
| | | | | | | Replace alloca with a scratch_buffer to avoid potential stack overflows. Checked on i686-gnu and x86_64-linux-gnu Message-Id: <20230619144334.2902429-1-josimmon@redhat.com>
* hurd: writev: Add back cleanup handlerJoe Simmons-Talbott2023-06-201-3/+7
| | | | | | | | | There is a potential memory leak for large writes due to writev being a "shall occur" cancellation point. Add back the cleanup handler removed in cf30aa43a5917f441c9438aaee201c53c8e1d76b. Checked on i686-gnu and x86_64-linux-gnu. Message-Id: <20230619143842.2901522-1-josimmon@redhat.com>
* Fix misspellings -- BZ 25337Paul Pluzhnikov2023-06-192-2/+2
|
* C2x scanf %b supportJoseph Myers2023-06-195-9/+248
| | | | | | | | | | | | ISO C2x defines scanf %b for input of binary integers (with an optional 0b or 0B prefix). Implement such support, along with the corresponding SCNb* macros in <inttypes.h>. Unlike the support for binary integers with 0b or 0B prefix with scanf %i, this is supported in all versions of scanf (independent of the standards mode used for compilation), because there are no backwards compatibility concerns (%b wasn't previously a supported format) the way there were for %i. Tested for x86_64 and x86.
* C2x printf %wN, %wfN support (bug 24466)Joseph Myers2023-06-1911-15/+851
| | | | | | | | | | | | | | | | | | ISO C2x defines printf length modifiers wN (for intN_t / int_leastN_t / uintN_t / uint_leastN_t) and wfN (for int_fastN_t / uint_fastN_t). Add support for those length modifiers (such a feature was previously requested in bug 24466). scanf support is to be added separately. GCC 13 has format checking support for these modifiers. When used with the support for registering format specifiers, these modifiers are translated to existing flags in struct printf_info, rather than trying to add some way of distinguishing them without breaking the printf_info ABI. C2x requires an error to be returned for unsupported values of N; this is implemented for printf-family functions, but the parse_printf_format interface doesn't support error returns, so such an error gets discarded by that function. Tested for x86_64 and x86.
* tests: replace system by xsystemFrédéric Bérat2023-06-198-6/+85
| | | | | | With fortification enabled, system calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: replace read by xreadFrédéric Bérat2023-06-1911-10/+56
| | | | | | | | | | | | | | | With fortification enabled, read calls return result needs to be checked, has it gets the __wur macro enabled. Note on read call removal from sysdeps/pthread/tst-cancel20.c and sysdeps/pthread/tst-cancel21.c: It is assumed that this second read call was there to overcome the race condition between pipe closure and thread cancellation that could happen in the original code. Since this race condition got fixed by d0e3ffb7a58854248f1d5e737610d50cd0a60f46 the second call seems superfluous. Hence, instead of checking for the return value of read, it looks reasonable to simply remove it. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* hurd: writev: Get rid of allocaJoe Simmons-Talbott2023-06-191-23/+14
| | | | | | | | Use a scratch_buffer rather than alloca to avoid potential stack overflows. Checked on i686-gnu and x86_64-linux-gnu Message-Id: <20230608155844.976554-1-josimmon@redhat.com>
* grantpt: Get rid of allocaJoe Simmons-Talbott2023-06-181-1/+11
| | | | | Replace alloca with a scratch_buffer to avoid potential stack overflows. Message-Id: <20230613191631.1080455-1-josimmon@redhat.com>
* string: strerror must not return NULL (bug 30555) fw/bug30555Florian Weimer2023-06-153-4/+87
| | | | | | | | | For strerror, this fixes commit 28aff047818eb1726394296d27b ("string: Implement strerror in terms of strerror_l"). This commit avoids returning NULL for strerror_l as well, although POSIX allows this behavior for strerror_l. Reviewed-by: Arjun Shankar <arjun@redhat.com>
* hurd: Add strlcpy, strlcat, wcslcpy, wcslcat to libc.abilistFlorian Weimer2023-06-151-0/+8
|
* manual: Manual update for strlcat, strlcpy, wcslcat, wclscpyPaul Eggert2023-06-142-3/+101
| | | | | Co-authored-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Add the wcslcpy, wcslcat functionsFlorian Weimer2023-06-1449-0/+563
| | | | | | | These functions are about to be added to POSIX, under Austin Group issue 986. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Implement strlcpy and strlcat [BZ #178]Florian Weimer2023-06-1450-0/+560
| | | | | | | | | | | These functions are about to be added to POSIX, under Austin Group issue 986. The fortified strlcat implementation does not raise SIGABRT if the destination buffer does not contain a null terminator, it just inherits the non-failing regular strlcat behavior. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: replace fgets by xfgetsFrederic Berat2023-06-137-14/+50
| | | | | | With fortification enabled, fgets calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: replace fread by xfreadFrederic Berat2023-06-139-12/+65
| | | | | | With fortification enabled, fread calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* posix: Add test case for gai_strerror()Dridi Boukelmoune2023-06-132-0/+44
| | | | | Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune@gmail.com> Reviewed-by: Arjun Shankar <arjun@redhat.com>
* posix: Handle success in gai_strerror()Dridi Boukelmoune2023-06-131-0/+1
| | | | | Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune@gmail.com> Reviewed-by: Arjun Shankar <arjun@redhat.com>
* LoongArch: Add support for dl_runtime_profilecaiyinyu2023-06-135-4/+220
| | | | This commit can fix the FAIL item: elf/tst-sprof-basic.
* malloc: Decrease resource usage for malloc testsAdhemerval Zanella Netto2023-06-121-12/+11
| | | | | | | | | | | | | | | | | | | | | | The tst-mallocfork2 and tst-mallocfork3 create large number of subprocesss, around 11k for former and 20k for latter, to check for malloc async-signal-safeness on both fork and _Fork. However they do not really exercise allocation patterns different than other tests fro malloc itself, and the spawned process just exit without any extra computation. The tst-malloc-tcache-leak is similar, but creates 100k threads and already checks the resulting with mallinfo. These tests are also very sensitive to system load (since they estresss heavy the kernel resource allocation), and adding them on THP tunable and mcheck tests increase the pressure even more. For THP the fork tests do not add any more coverage than other tests. The mcheck is also not enable for tst-malloc-tcache-leak. Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* stdlib: Tune down fork arc4random testsAdhemerval Zanella Netto2023-06-121-8/+4
| | | | | | | | | There is no fork detection on current arc4random implementation, so use lower subprocess on fork tests. The tests now run on 0.1s instead of 8s on a Ryzen9 5900X. Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* tst-getdate: Improve testcase flexibility and add test.Joe Simmons-Talbott2023-06-121-20/+39
| | | | | | | | | The getdate testcases all expect successful results. Add support for negative testcases and testcases where a full date and time are not supplied by skipping the tm checks in the test. Add a testcase that would catch a use-after-free that was recently found. Reviewed-by: Arjun Shankar <arjun@redhat.com>
* x86: Make the divisor in setting `non_temporal_threshold` cpu specificNoah Goldstein2023-06-124-26/+51
| | | | | | | | | | | | | | | | Different systems prefer a different divisors. From benchmarks[1] so far the following divisors have been found: ICX : 2 SKX : 2 BWD : 8 For Intel, we are generalizing that BWD and older prefers 8 as a divisor, and SKL and newer prefers 2. This number can be further tuned as benchmarks are run. [1]: https://github.com/goldsteinn/memcpy-nt-benchmarks Reviewed-by: DJ Delorie <dj@redhat.com>
* x86: Refactor Intel `init_cpu_features`Noah Goldstein2023-06-121-81/+309
| | | | | | | | | | | | | | | This patch should have no affect on existing functionality. The current code, which has a single switch for model detection and setting prefered features, is difficult to follow/extend. The cases use magic numbers and many microarchitectures are missing. This makes it difficult to reason about what is implemented so far and/or how/where to add support for new features. This patch splits the model detection and preference setting stages so that CPU preferences can be set based on a complete list of available microarchitectures, rather than based on model magic numbers. Reviewed-by: DJ Delorie <dj@redhat.com>
* x86: Increase `non_temporal_threshold` to roughly `sizeof_L3 / 4`Noah Goldstein2023-06-121-27/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current `non_temporal_threshold` set to roughly '3/4 * sizeof_L3 / ncores_per_socket'. This patch updates that value to roughly 'sizeof_L3 / 4` The original value (specifically dividing the `ncores_per_socket`) was done to limit the amount of other threads' data a `memcpy`/`memset` could evict. Dividing by 'ncores_per_socket', however leads to exceedingly low non-temporal thresholds and leads to using non-temporal stores in cases where REP MOVSB is multiple times faster. Furthermore, non-temporal stores are written directly to main memory so using it at a size much smaller than L3 can place soon to be accessed data much further away than it otherwise could be. As well, modern machines are able to detect streaming patterns (especially if REP MOVSB is used) and provide LRU hints to the memory subsystem. This in affect caps the total amount of eviction at 1/cache_associativity, far below meaningfully thrashing the entire cache. As best I can tell, the benchmarks that lead this small threshold where done comparing non-temporal stores versus standard cacheable stores. A better comparison (linked below) is to be REP MOVSB which, on the measure systems, is nearly 2x faster than non-temporal stores at the low-end of the previous threshold, and within 10% for over 100MB copies (well past even the current threshold). In cases with a low number of threads competing for bandwidth, REP MOVSB is ~2x faster up to `sizeof_L3`. The divisor of `4` is a somewhat arbitrary value. From benchmarks it seems Skylake and Icelake both prefer a divisor of `2`, but older CPUs such as Broadwell prefer something closer to `8`. This patch is meant to be followed up by another one to make the divisor cpu-specific, but in the meantime (and for easier backporting), this patch settles on `4` as a middle-ground. Benchmarks comparing non-temporal stores, REP MOVSB, and cacheable stores where done using: https://github.com/goldsteinn/memcpy-nt-benchmarks Sheets results (also available in pdf on the github): https://docs.google.com/spreadsheets/d/e/2PACX-1vS183r0rW_jRX6tG_E90m9qVuFiMbRIJvi5VAE8yYOvEOIEEc3aSNuEsrFbuXw5c3nGboxMmrupZD7K/pubhtml Reviewed-by: DJ Delorie <dj@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Remove unused DATEMSK file for tst-getdateMartin Coufal2023-06-093-4/+1
| | | | | | | | tst-getdate used to rely on an in-tree datemsk file that was subsequently replaced by a file created during test execution. This commit removes the unused file and corresponding env-var and uses a more appropriate name for the temp file. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* resolv_conf: release lock on allocation failure (bug 30527)Andreas Schwab2023-06-071-1/+4
| | | | | | | When the initial allocation of global fails, the local lock is left locked. Reported by Steffen Lammel of SAP HANA development.
* time: Fix use-after-free in getdateArjun Shankar2023-06-061-2/+3
| | | | | | | | | getdate would free the buffer pointed to by the result of its call to strptime, then reference the same buffer later on -- leading to a use-after-free. This commit fixes that. Reported-by: Martin Coufal <mcoufal@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Move {read,write}_all functions to a dedicated headerFrédéric Bérat2023-06-064-81/+69
| | | | | | | | Since these functions are used in both catgets/gencat.c and malloc/memusage{,stat}.c, it make sense to move them into a dedicated header where they can be inlined. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: Replace various function calls with their x variantFrédéric Bérat2023-06-065-6/+13
| | | | | | | With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: fix warn unused result on asprintf callsFrédéric Bérat2023-06-0610-58/+29
| | | | | | | When enabling _FORTIFY_SOURCE, some functions now lead to warnings when their result is not checked. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>