diff --git a/ADVISORIES b/ADVISORIES new file mode 100644 index 0000000000..d4e33f2df3 --- /dev/null +++ b/ADVISORIES @@ -0,0 +1,2 @@ +For the GNU C Library Security Advisories, see the git master branch: +https://sourceware.org/git/?p=glibc.git;a=tree;f=advisories;hb=HEAD diff --git a/Makefile b/Makefile index a6aabca691..d559c42873 100644 --- a/Makefile +++ b/Makefile @@ -575,6 +575,14 @@ $(foreach t,$(+elf_last_subdir_targets),$(eval \ elf/$(t): $(addsuffix /$(t),$(filter-out elf,$(subdirs))))) endif +# The archive rules in Makerules list every stamp file as a +# prerequisite of libc_pic.a, which the elf sub-make evaluates for the +# librtld.map link, but a sub-make can only create its own directory's +# stamps. Create the top-level ones before the fan-out. +$(foreach t,$(+elf_last_subdir_targets),$(eval \ + $(addsuffix /$(t),$(subdirs)): \ + $(foreach o,$(object-suffixes-for-libc),$(common-objpfx)stamp$(o)))) + # Pass barriers: a subdirectory 'others' build links programs against # the libraries, so the 'lib' pass (including the top-level libc.so # link) must have completed. @@ -869,7 +877,11 @@ endif touch $(objpfx)testroot.pristine/install.stamp tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special)) +# The build-only first pass of the two-pass 'make check' (see Makerules) +# passes tests-summary=no: the merge and summary are left to the second +# pass, which folds in this pass's $(tests-special) results. tests: $(tests-special) +ifneq ($(tests-summary),no) $(..)scripts/merge-test-results.sh -s $(objpfx) "" \ $(sort $(tests-special-notdir:.out=)) \ > $(objpfx)subdir-tests.sum @@ -877,11 +889,14 @@ tests: $(tests-special) $(sort $(subdirs) .) \ > $(objpfx)tests.sum $(call summarize-tests,tests.sum) +endif xtests: +ifneq ($(tests-summary),no) $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-xtests.sum \ $(sort $(subdirs)) \ > $(objpfx)xtests.sum $(call summarize-tests,xtests.sum, for extra tests) +endif # The realclean target is just like distclean for the parent, but we want # the subdirs to know the difference in case they care. diff --git a/Makefile.in b/Makefile.in index e40dcbbc78..9fd5468ba8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,6 +16,8 @@ test-supported-fortify = @libc_cv_test_supported_fortify_source@ .PHONY: all install bench +.NOTPARALLEL: + all .DEFAULT: $(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@ diff --git a/Makerules b/Makerules index 6bef57ece9..be51154bae 100644 --- a/Makerules +++ b/Makerules @@ -259,7 +259,17 @@ endif # gen-py-const-headers ifdef gen-as-const-headers # Generating headers for assembly constants. # We need this defined early to get into before-compile before -# it's used in sysd-rules, below. +# it's used in sysd-rules, below. The gen-as-const-headers is evaluated +# per subdirectory, so the before-compile dependency below only orders +# the generated header before the compiles of the subdirectory whose +# Makefile adds the .sym directive. +# The parallel subdirectory recursion does not order sibling subdirectories, +# so a .sym must be added in the subdirectory that compiles its consumers, +# or in csu (which runs before the parallel) when it has consumers in +# several subdirectories. +# It must not add the same .sym in several subdirectories though: their +# concurrent sub-makes would race generating the header through the fixed +# temporary files below. # Define GEN_AS_CONST_HEADERS to avoid circular dependency [BZ #22792]. # NB: is generated from tcb-offsets.sym to define # offsets and sizes of types in and maybe which @@ -302,7 +312,12 @@ lib-names-h-abi = gnu/lib-names-$(default-abi).h lib-names-stmp-abi = gnu/lib-names-$(default-abi).stmp before-compile += $(common-objpfx)$(lib-names-h-abi) common-generated += gnu/lib-names.h +# The $(inst_includedir)/%.h install rules are defined only where $(headers) +# is non-empty, and with parallel subdir recursion a subdir without headers +# (e.g. csu) may run before the top level has installed the header. +ifndef subdir install-others-nosubdir: $(inst_includedir)/$(lib-names-h-abi) +endif $(common-objpfx)gnu/lib-names.h: $(make-target-directory) { \ @@ -743,10 +758,20 @@ all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt)) $(wildcard $(all-dt-files:.dt=.d)) # This is a funny rule in that it removes its input file. +# +# More than one make can convert the .dt files of a single object +# directory: the elf rtld-Rules recursion runs a sub-make over every +# $(rtld-subdirs) directory, concurrently with that directory's own +# sub-make under the parallel subdir recursion. Add the PID of the +# shell to the temporary name and claim the input with a rename: only +# the run that wins converts and installs the target. %.d: %.dt - @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \ - mv -f $(@:.d=.T) $@ && \ - rm -f $< + @dt=$(@:.d=.T)$$$$; \ + if mv -f $< $$dt 2>/dev/null; then \ + sed $(sed-remove-objpfx) $$dt > $$dt.new && \ + mv -f $$dt.new $@ && \ + rm -f $$dt; \ + fi # Avoid the .h.d files for any .sym files whose .h files don't exist yet. # They will be generated when they're needed, and trying too early won't work. @@ -1196,6 +1221,13 @@ ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -D_GNU_SOURCE \ # therefore builds the test programs (run-built-tests=no, recursion fully # parallel) and then runs them (run-built-tests=yes). 'make tests' and a # subdirectory's own 'check' stay single-pass. +# The first pass still runs the static checks ($(tests-special): abi, +# conformtest, installed headers, ...), so tests-summary=no makes it skip +# the results merge and summary: an unexpected FAIL there would otherwise +# abort 'check' before the second pass runs any built test, and even a +# clean run would print a misleading partial summary. The .test-result +# files persist, so the second pass folds those results into the one +# complete summary at the end. check-twopass := ifndef subdir ifeq (yes,$(run-built-tests)) @@ -1204,10 +1236,10 @@ endif endif ifeq (yes,$(check-twopass)) check: - $(MAKE) run-built-tests=no tests + $(MAKE) run-built-tests=no tests-summary=no tests $(MAKE) run-built-tests=yes tests xcheck: - $(MAKE) run-built-tests=no xtests + $(MAKE) run-built-tests=no tests-summary=no xtests $(MAKE) run-built-tests=yes xtests else check: tests @@ -1411,7 +1443,7 @@ endef # Also remove the dependencies and generated source files. common-clean: common-mostlyclean -rm -f $(addprefix $(objpfx),$(generated)) - -rm -f $(objpfx)*.d $(objpfx)*.dt + -rm -f $(objpfx)*.d $(objpfx)*.dt $(objpfx)*.T[0-9]* -rm -fr $(addprefix $(objpfx),$(generated-dirs)) -rm -f $(addprefix $(common-objpfx),$(common-generated)) -rm -f $(gen-as-const-headers:%.sym=$(common-objpfx)%.h) diff --git a/NEWS b/NEWS index ee28fadf49..9f362f4560 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,34 @@ See the end for copying conditions. Please send GNU C library bug reports via using `glibc' in the "product" field. +Version 2.44.1 + +The following bugs are resolved with this release: + + [34338] libc: Cancellable syscall wrappers are missing from backtraces + because they tail-call __syscall_cancel + [34438] build: non reproducible build failure: sigaltstack-offsets.h: + No such file or directory + [34439] build: parallel make install fails on multi-ABI targets: no + rule to make $(inst_includedir)/gnu/lib-names-$(abi).h in csu + [34441] math: math: sinh() returns wrong results for some inputs with + |x| > 36.736801 + [34465] math: math: x86_64 tanh ifunc selection wrong + [34507] nptl: Pretty-printer tests FAIL instead of UNSUPPORTED when + cross-testing without python3 on target + [34509] libc: [m68k] Regression: Perl locks up after upgrading glibc + to 2.43 + [34699] build: Parallel build failures with make check xcheck + [34734] libc: sparc: tcgetattr returns uninitialized bytes in c_cc[17] + and c_cc[18] + [34775] libc: Regression in fts with FTS_FOLLOW + [34781] libc: fts: FTS_CWDFD walk breaks after leaving a directory + followed with FTS_FOLLOW + [34782] libc: fts: wrong fts_path and fts_pathlen for paths longer + than USHRT_MAX + [34875] string: 2.44 regression: Hygon non-temporal threshold can be + zero + Version 2.44 Major new features: diff --git a/Rules b/Rules index 71495028fb..cfdbb459c8 100644 --- a/Rules +++ b/Rules @@ -467,8 +467,9 @@ py-env := PYTHONPATH=$(py-const-dir):$(..)scripts:$${PYTHONPATH} # The pretty printer files and test_common_printers.py must be present for all. $(tests-printers-out): $(objpfx)%.out: $(objpfx)% %.py %.c $(pretty-printers) \ $(..)scripts/test_printers_common.py - $(test-wrapper-env) $(py-env) \ - $(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers) > $@; \ + $(test-wrapper-env) $(py-env) sh -c \ + 'command -v $(firstword $(PYTHON)) > /dev/null 2>&1 || exit 77; \ + exec $(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers)' > $@; \ $(evaluate-test) endif diff --git a/advisories/GLIBC-SA-2023-0001 b/advisories/GLIBC-SA-2023-0001 deleted file mode 100644 index 3d19c91b6a..0000000000 --- a/advisories/GLIBC-SA-2023-0001 +++ /dev/null @@ -1,14 +0,0 @@ -printf: incorrect output for integers with thousands separator and width field - -When the printf family of functions is called with a format specifier -that uses an (enable grouping) and a minimum width -specifier, the resulting output could be larger than reasonably expected -by a caller that computed a tight bound on the buffer size. The -resulting larger than expected output could result in a buffer overflow -in the printf family of functions. - -CVE-Id: CVE-2023-25139 -Public-Date: 2023-02-02 -Vulnerable-Commit: e88b9f0e5cc50cab57a299dc7efe1a4eb385161d (2.37) -Fix-Commit: c980549cc6a1c03c23cc2fe3e7b0fe626a0364b0 (2.38) -Fix-Commit: 07b9521fc6369d000216b96562ff7c0ed32a16c4 (2.37-4) diff --git a/advisories/GLIBC-SA-2023-0002 b/advisories/GLIBC-SA-2023-0002 deleted file mode 100644 index 5122669a64..0000000000 --- a/advisories/GLIBC-SA-2023-0002 +++ /dev/null @@ -1,15 +0,0 @@ -getaddrinfo: Stack read overflow in no-aaaa mode - -If the system is configured in no-aaaa mode via /etc/resolv.conf, -getaddrinfo is called for the AF_UNSPEC address family, and a DNS -response is received over TCP that is larger than 2048 bytes, -getaddrinfo may potentially disclose stack contents via the returned -address data, or crash. - -CVE-Id: CVE-2023-4527 -Public-Date: 2023-09-12 -Vulnerable-Commit: f282cdbe7f436c75864e5640a409a10485e9abb2 (2.36) -Fix-Commit: bd77dd7e73e3530203be1c52c8a29d08270cb25d (2.39) -Fix-Commit: 4ea972b7edd7e36610e8cde18bf7a8149d7bac4f (2.36-113) -Fix-Commit: b7529346025a130fee483d42178b5c118da971bb (2.37-38) -Fix-Commit: b25508dd774b617f99419bdc3cf2ace4560cd2d6 (2.38-19) diff --git a/advisories/GLIBC-SA-2023-0003 b/advisories/GLIBC-SA-2023-0003 deleted file mode 100644 index d3aef80348..0000000000 --- a/advisories/GLIBC-SA-2023-0003 +++ /dev/null @@ -1,15 +0,0 @@ -getaddrinfo: Potential use-after-free - -When an NSS plugin only implements the _gethostbyname2_r and -_getcanonname_r callbacks, getaddrinfo could use memory that was freed -during buffer resizing, potentially causing a crash or read or write to -arbitrary memory. - -CVE-Id: CVE-2023-4806 -Public-Date: 2023-09-12 -Fix-Commit: 973fe93a5675c42798b2161c6f29c01b0e243994 (2.39) -Fix-Commit: e09ee267c03e3150c2c9ba28625ab130705a485e (2.34-420) -Fix-Commit: e3ccb230a961b4797510e6a1f5f21fd9021853e7 (2.35-270) -Fix-Commit: a9728f798ec7f05454c95637ee6581afaa9b487d (2.36-115) -Fix-Commit: 6529a7466c935f36e9006b854d6f4e1d4876f942 (2.37-39) -Fix-Commit: 00ae4f10b504bc4564e9f22f00907093f1ab9338 (2.38-20) diff --git a/advisories/GLIBC-SA-2023-0004 b/advisories/GLIBC-SA-2023-0004 deleted file mode 100644 index 5286a7aa54..0000000000 --- a/advisories/GLIBC-SA-2023-0004 +++ /dev/null @@ -1,16 +0,0 @@ -tunables: local privilege escalation through buffer overflow - -If a tunable of the form NAME=NAME=VAL is passed in the environment of a -setuid program and NAME is valid, it may result in a buffer overflow, -which could be exploited to achieve escalated privileges. This flaw was -introduced in glibc 2.34. - -CVE-Id: CVE-2023-4911 -Public-Date: 2023-10-03 -Vulnerable-Commit: 2ed18c5b534d9e92fc006202a5af0df6b72e7aca (2.34) -Fix-Commit: 1056e5b4c3f2d90ed2b4a55f96add28da2f4c8fa (2.39) -Fix-Commit: dcc367f148bc92e7f3778a125f7a416b093964d9 (2.34-423) -Fix-Commit: c84018a05aec80f5ee6f682db0da1130b0196aef (2.35-274) -Fix-Commit: 22955ad85186ee05834e47e665056148ca07699c (2.36-118) -Fix-Commit: b4e23c75aea756b4bddc4abcf27a1c6dca8b6bd3 (2.37-45) -Fix-Commit: 750a45a783906a19591fb8ff6b7841470f1f5701 (2.38-27) diff --git a/advisories/GLIBC-SA-2023-0005 b/advisories/GLIBC-SA-2023-0005 deleted file mode 100644 index cc4eb90b82..0000000000 --- a/advisories/GLIBC-SA-2023-0005 +++ /dev/null @@ -1,18 +0,0 @@ -getaddrinfo: DoS due to memory leak - -The fix for CVE-2023-4806 introduced a memory leak when an application -calls getaddrinfo for AF_INET6 with AI_CANONNAME, AI_ALL and AI_V4MAPPED -flags set. - -CVE-Id: CVE-2023-5156 -Public-Date: 2023-09-25 -Vulnerable-Commit: e09ee267c03e3150c2c9ba28625ab130705a485e (2.34-420) -Vulnerable-Commit: e3ccb230a961b4797510e6a1f5f21fd9021853e7 (2.35-270) -Vulnerable-Commit: a9728f798ec7f05454c95637ee6581afaa9b487d (2.36-115) -Vulnerable-Commit: 6529a7466c935f36e9006b854d6f4e1d4876f942 (2.37-39) -Vulnerable-Commit: 00ae4f10b504bc4564e9f22f00907093f1ab9338 (2.38-20) -Fix-Commit: 8006457ab7e1cd556b919f477348a96fe88f2e49 (2.34-421) -Fix-Commit: 17092c0311f954e6f3c010f73ce3a78c24ac279a (2.35-272) -Fix-Commit: 856bac55f98dc840e7c27cfa82262b933385de90 (2.36-116) -Fix-Commit: 4473d1b87d04b25cdd0e0354814eeaa421328268 (2.37-42) -Fix-Commit: 5ee59ca371b99984232d7584fe2b1a758b4421d3 (2.38-24) diff --git a/advisories/GLIBC-SA-2024-0001 b/advisories/GLIBC-SA-2024-0001 deleted file mode 100644 index 28931c75ae..0000000000 --- a/advisories/GLIBC-SA-2024-0001 +++ /dev/null @@ -1,15 +0,0 @@ -syslog: Heap buffer overflow in __vsyslog_internal - -__vsyslog_internal did not handle a case where printing a SYSLOG_HEADER -containing a long program name failed to update the required buffer -size, leading to the allocation and overflow of a too-small buffer on -the heap. - -CVE-Id: CVE-2023-6246 -Public-Date: 2024-01-30 -Vulnerable-Commit: 52a5be0df411ef3ff45c10c7c308cb92993d15b1 (2.37) -Fix-Commit: 6bd0e4efcc78f3c0115e5ea9739a1642807450da (2.39) -Fix-Commit: 23514c72b780f3da097ecf33a793b7ba9c2070d2 (2.38-42) -Fix-Commit: 97a4292aa4a2642e251472b878d0ec4c46a0e59a (2.37-57) -Vulnerable-Commit: b0e7888d1fa2dbd2d9e1645ec8c796abf78880b9 (2.36-16) -Fix-Commit: d1a83b6767f68b3cb5b4b4ea2617254acd040c82 (2.36-126) diff --git a/advisories/GLIBC-SA-2024-0002 b/advisories/GLIBC-SA-2024-0002 deleted file mode 100644 index 940bfcf2fc..0000000000 --- a/advisories/GLIBC-SA-2024-0002 +++ /dev/null @@ -1,15 +0,0 @@ -syslog: Heap buffer overflow in __vsyslog_internal - -__vsyslog_internal used the return value of snprintf/vsnprintf to -calculate buffer sizes for memory allocation. If these functions (for -any reason) failed and returned -1, the resulting buffer would be too -small to hold output. - -CVE-Id: CVE-2023-6779 -Public-Date: 2024-01-30 -Vulnerable-Commit: 52a5be0df411ef3ff45c10c7c308cb92993d15b1 (2.37) -Fix-Commit: 7e5a0c286da33159d47d0122007aac016f3e02cd (2.39) -Fix-Commit: d0338312aace5bbfef85e03055e1212dd0e49578 (2.38-43) -Fix-Commit: 67062eccd9a65d7fda9976a56aeaaf6c25a80214 (2.37-58) -Vulnerable-Commit: b0e7888d1fa2dbd2d9e1645ec8c796abf78880b9 (2.36-16) -Fix-Commit: 2bc9d7c002bdac38b5c2a3f11b78e309d7765b83 (2.36-127) diff --git a/advisories/GLIBC-SA-2024-0003 b/advisories/GLIBC-SA-2024-0003 deleted file mode 100644 index b43a5150ab..0000000000 --- a/advisories/GLIBC-SA-2024-0003 +++ /dev/null @@ -1,13 +0,0 @@ -syslog: Integer overflow in __vsyslog_internal - -__vsyslog_internal calculated a buffer size by adding two integers, but -did not first check if the addition would overflow. - -CVE-Id: CVE-2023-6780 -Public-Date: 2024-01-30 -Vulnerable-Commit: 52a5be0df411ef3ff45c10c7c308cb92993d15b1 (2.37) -Fix-Commit: ddf542da94caf97ff43cc2875c88749880b7259b (2.39) -Fix-Commit: d37c2b20a4787463d192b32041c3406c2bd91de0 (2.38-44) -Fix-Commit: 2b58cba076e912961ceaa5fa58588e4b10f791c0 (2.37-59) -Vulnerable-Commit: b0e7888d1fa2dbd2d9e1645ec8c796abf78880b9 (2.36-16) -Fix-Commit: b9b7d6a27aa0632f334352fa400771115b3c69b7 (2.36-128) diff --git a/advisories/GLIBC-SA-2024-0004 b/advisories/GLIBC-SA-2024-0004 deleted file mode 100644 index 08df2b3118..0000000000 --- a/advisories/GLIBC-SA-2024-0004 +++ /dev/null @@ -1,28 +0,0 @@ -ISO-2022-CN-EXT: fix out-of-bound writes when writing escape sequence - -The iconv() function in the GNU C Library versions 2.39 and older may -overflow the output buffer passed to it by up to 4 bytes when converting -strings to the ISO-2022-CN-EXT character set, which may be used to -crash an application or overwrite a neighbouring variable. - -ISO-2022-CN-EXT uses escape sequences to indicate character set changes -(as specified by RFC 1922). While the SOdesignation has the expected -bounds checks, neither SS2designation nor SS3designation have its; -allowing a write overflow of 1, 2, or 3 bytes with fixed values: -'$+I', '$+J', '$+K', '$+L', '$+M', or '$*H'. - -CVE-Id: CVE-2024-2961 -Public-Date: 2024-04-17 -Vulnerable-Commit: 755104edc75c53f4a0e7440334e944ad3c6b32fc (2.1.93-169) -Fix-Commit: f9dc609e06b1136bb0408be9605ce7973a767ada (2.40) -Fix-Commit: 31da30f23cddd36db29d5b6a1c7619361b271fb4 (2.39-31) -Fix-Commit: e1135387deded5d73924f6ca20c72a35dc8e1bda (2.38-66) -Fix-Commit: 89ce64b269a897a7780e4c73a7412016381c6ecf (2.37-89) -Fix-Commit: 4ed98540a7fd19f458287e783ae59c41e64df7b5 (2.36-164) -Fix-Commit: 36280d1ce5e245aabefb877fe4d3c6cff95dabfa (2.35-315) -Fix-Commit: a8b0561db4b9847ebfbfec20075697d5492a363c (2.34-459) -Fix-Commit: ed4f16ff6bed3037266f1fa682ebd32a18fce29c (2.33-263) -Fix-Commit: 682ad4c8623e611a971839990ceef00346289cc9 (2.32-140) -Fix-Commit: 3703c32a8d304c1ee12126134ce69be965f38000 (2.31-154) - -Reported-By: Charles Fol diff --git a/advisories/GLIBC-SA-2024-0005 b/advisories/GLIBC-SA-2024-0005 deleted file mode 100644 index a59596610a..0000000000 --- a/advisories/GLIBC-SA-2024-0005 +++ /dev/null @@ -1,22 +0,0 @@ -nscd: Stack-based buffer overflow in netgroup cache - -If the Name Service Cache Daemon's (nscd) fixed size cache is exhausted -by client requests then a subsequent client request for netgroup data -may result in a stack-based buffer overflow. This flaw was introduced -in glibc 2.15 when the cache was added to nscd. - -This vulnerability is only present in the nscd binary. - -CVE-Id: CVE-2024-33599 -Public-Date: 2024-04-23 -Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) -Fix-Commit: 69c58d5ef9f584ea198bd00f7964d364d0e6b921 (2.31-155) -Fix-Commit: a77064893bfe8a701770e2f53a4d33805bc47a5a (2.32-141) -Fix-Commit: 5c75001a96abcd50cbdb74df24c3f013188d076e (2.33-264) -Fix-Commit: 52f73e5c4e29b14e79167272297977f360ae1e97 (2.34-460) -Fix-Commit: 7a95873543ce225376faf13bb71c43dea6d24f86 (2.35-316) -Fix-Commit: caa3151ca460bdd9330adeedd68c3112d97bffe4 (2.36-165) -Fix-Commit: f75c298e747b2b8b41b1c2f551c011a52c41bfd1 (2.37-91) -Fix-Commit: 5968aebb86164034b8f8421b4abab2f837a5bdaf (2.38-72) -Fix-Commit: 1263d583d2e28afb8be53f8d6922f0842036f35d (2.39-35) -Fix-Commit: 87801a8fd06db1d654eea3e4f7626ff476a9bdaa (2.40) diff --git a/advisories/GLIBC-SA-2024-0006 b/advisories/GLIBC-SA-2024-0006 deleted file mode 100644 index d44148d3d9..0000000000 --- a/advisories/GLIBC-SA-2024-0006 +++ /dev/null @@ -1,32 +0,0 @@ -nscd: Null pointer crash after notfound response - -If the Name Service Cache Daemon's (nscd) cache fails to add a not-found -netgroup response to the cache, the client request can result in a null -pointer dereference. This flaw was introduced in glibc 2.15 when the -cache was added to nscd. - -This vulnerability is only present in the nscd binary. - -CVE-Id: CVE-2024-33600 -Public-Date: 2024-04-24 -Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) -Fix-Commit: b048a482f088e53144d26a61c390bed0210f49f2 (2.40) -Fix-Commit: 7835b00dbce53c3c87bbbb1754a95fb5e58187aa (2.40) -Fix-Commit: c99f886de54446cd4447db6b44be93dabbdc2f8b (2.39-37) -Fix-Commit: 5a508e0b508c8ad53bd0d2fb48fd71b242626341 (2.39-36) -Fix-Commit: 2ae9446c1b7a3064743b4a51c0bbae668ee43e4c (2.38-74) -Fix-Commit: 541ea5172aa658c4bd5c6c6d6fd13903c3d5bb0a (2.38-73) -Fix-Commit: a8070b31043c7585c36ba68a74298c4f7af075c3 (2.37-93) -Fix-Commit: 5eea50c4402e39588de98aa1d4469a79774703d4 (2.37-92) -Fix-Commit: f205b3af56740e3b014915b1bd3b162afe3407ef (2.36-167) -Fix-Commit: c34f470a615b136170abd16142da5dd0c024f7d1 (2.36-166) -Fix-Commit: bafadc589fbe21ae330e8c2af74db9da44a17660 (2.35-318) -Fix-Commit: 4370bef52b0f3f3652c6aa13d7a9bb3ac079746d (2.35-317) -Fix-Commit: 1f94122289a9bf7dba573f5d60327aaa2b85cf2e (2.34-462) -Fix-Commit: 966d6ac9e40222b84bb21674cc4f83c8d72a5a26 (2.34-461) -Fix-Commit: e3eef1b8fbdd3a7917af466ca9c4b7477251ca79 (2.33-266) -Fix-Commit: f20a8d696b13c6261b52a6434899121f8b19d5a7 (2.33-265) -Fix-Commit: be602180146de37582a3da3a0caa4b719645de9c (2.32-143) -Fix-Commit: 394eae338199078b7961b051c191539870742d7b (2.32-142) -Fix-Commit: 8d7949183760170c61e55def723c1d8050187874 (2.31-157) -Fix-Commit: 304ce5fe466c4762b21b36c26926a4657b59b53e (2.31-156) diff --git a/advisories/GLIBC-SA-2024-0007 b/advisories/GLIBC-SA-2024-0007 deleted file mode 100644 index b6928fa27a..0000000000 --- a/advisories/GLIBC-SA-2024-0007 +++ /dev/null @@ -1,28 +0,0 @@ -nscd: netgroup cache may terminate daemon on memory allocation failure - -The Name Service Cache Daemon's (nscd) netgroup cache uses xmalloc or -xrealloc and these functions may terminate the process due to a memory -allocation failure resulting in a denial of service to the clients. The -flaw was introduced in glibc 2.15 when the cache was added to nscd. - -This vulnerability is only present in the nscd binary. - -Subsequent refactoring of the netgroup cache only added more uses of -xmalloc and xrealloc. Uses of xmalloc and xrealloc in other parts of -nscd only occur during startup of the daemon and so are not affected by -client requests that could trigger an out of memory followed by -termination. - -CVE-Id: CVE-2024-33601 -Public-Date: 2024-04-24 -Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) -Fix-Commit: c04a21e050d64a1193a6daab872bca2528bda44b (2.40) -Fix-Commit: a9a8d3eebb145779a18d90e3966009a1daa63cd8 (2.39-38) -Fix-Commit: 71af8ca864345d39b746d5cee84b94b430fad5db (2.38-75) -Fix-Commit: 6e106dc214d6a033a4e945d1c6cf58061f1c5f1f (2.37-94) -Fix-Commit: b6742463694b1dfdd5120b91ee21cf05d15ec2e2 (2.36-168) -Fix-Commit: 7a5864cac60e06000394128a5a2817b03542f5a3 (2.35-319) -Fix-Commit: 86f1d5f4129c373ac6fb6df5bcf38273838843cb (2.34-463) -Fix-Commit: 4d27d4b9a188786fc6a56745506cec2acfc51f83 (2.33-267) -Fix-Commit: 3ed195a8ec89da281e3c4bf887a13d281b72d8f4 (2.32-144) -Fix-Commit: bbf5a58ccb55679217f94de706164d15372fbbc0 (2.31-158) diff --git a/advisories/GLIBC-SA-2024-0008 b/advisories/GLIBC-SA-2024-0008 deleted file mode 100644 index d93e2a6f0b..0000000000 --- a/advisories/GLIBC-SA-2024-0008 +++ /dev/null @@ -1,26 +0,0 @@ -nscd: netgroup cache assumes NSS callback uses in-buffer strings - -The Name Service Cache Daemon's (nscd) netgroup cache can corrupt memory -when the NSS callback does not store all strings in the provided buffer. -The flaw was introduced in glibc 2.15 when the cache was added to nscd. - -This vulnerability is only present in the nscd binary. - -There is no guarantee from the NSS callback API that the returned -strings are all within the buffer. However, the netgroup cache code -assumes that the NSS callback uses in-buffer strings and if it doesn't -the buffer resizing logic could lead to potential memory corruption. - -CVE-Id: CVE-2024-33602 -Public-Date: 2024-04-24 -Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) -Fix-Commit: c04a21e050d64a1193a6daab872bca2528bda44b (2.40) -Fix-Commit: a9a8d3eebb145779a18d90e3966009a1daa63cd8 (2.39-38) -Fix-Commit: 71af8ca864345d39b746d5cee84b94b430fad5db (2.38-75) -Fix-Commit: 6e106dc214d6a033a4e945d1c6cf58061f1c5f1f (2.37-94) -Fix-Commit: b6742463694b1dfdd5120b91ee21cf05d15ec2e2 (2.36-168) -Fix-Commit: 7a5864cac60e06000394128a5a2817b03542f5a3 (2.35-319) -Fix-Commit: 86f1d5f4129c373ac6fb6df5bcf38273838843cb (2.34-463) -Fix-Commit: 4d27d4b9a188786fc6a56745506cec2acfc51f83 (2.33-267) -Fix-Commit: 3ed195a8ec89da281e3c4bf887a13d281b72d8f4 (2.32-144) -Fix-Commit: bbf5a58ccb55679217f94de706164d15372fbbc0 (2.31-158) diff --git a/advisories/GLIBC-SA-2025-0001 b/advisories/GLIBC-SA-2025-0001 deleted file mode 100644 index b053d32e91..0000000000 --- a/advisories/GLIBC-SA-2025-0001 +++ /dev/null @@ -1,40 +0,0 @@ -assert: Buffer overflow when printing assertion failure message - -When the assert() function fails, it does not allocate enough space for the -assertion failure message string and size information, which may lead to a -buffer overflow if the message string size aligns to page size. - -This bug can be triggered when an assertion in a program fails. The assertion -failure message is allocated to allow developers to see this failure in core -dumps and it typically includes, in addition to the invariant assertion -string and function name, the name of the program. If the name of the failing -program is user controlled, for example on a local system, this could allow an -attacker to control the assertion failure to trigger this buffer overflow. - -The only viable vector for exploitation of this bug is local, if a setuid -program exists that has an existing bug that results in an assertion failure. -No such program has been discovered at the time of publishing this advisory, -but the presence of custom setuid programs, although strongly discouraged as a -security practice, cannot be discounted. - -CVE-Id: CVE-2025-0395 -Public-Date: 2025-01-22 -Vulnerable-Commit: f8a3b5bf8fa1d0c43d2458e03cc109a04fdef194 (2.13-175) -Fix-Commit: 68ee0f704cb81e9ad0a78c644a83e1e9cd2ee578 (2.41) -Fix-Commit: cdb9ba84191ce72e86346fb8b1d906e7cd930ea2 (2.42) -Fix-Commit: 69fda28279b497bd405fdd442a6d8e4d3d5f681b (2.41-7) -Fix-Commit: 7d4b6bcae91f29d7b4daf15bab06b66cf1d2217c (2.40-66) -Fix-Commit: d6c156c326999f144cb5b73d29982108d549ad8a (2.40-71) -Fix-Commit: 808a84a8b81468b517a4d721fdc62069cb8c211f (2.39-146) -Fix-Commit: f6d48470aef9264d2d56f4c4533eb76db7f9c2e4 (2.39-150) -Fix-Commit: c32fd59314c343db88c3ea4a203870481d33c3d2 (2.38-122) -Fix-Commit: f984e2d7e8299726891a1a497a3c36cd5542a0bf (2.38-124) -Fix-Commit: a3d7865b098a3a67c44f7812208d9ce4718873ba (2.37-143) -Fix-Commit: b989519fe1683c204ac24ec92830e3fe3bfaccad (2.37-146) -Fix-Commit: 7971add7ee4171fdd8dfd17e7c04c4ed77a18845 (2.36-216) -Fix-Commit: 0487893d5c5bc6710d83d7c3152d888a0339559e (2.36-219) -Fix-Commit: 8b5d4be762419c4f6176261c6fea40ac559b88dc (2.35-370) -Fix-Commit: 8b3d09dc0d350191985f9d291cc30ce96f034b49 (2.35-373) -Fix-Commit: df4e1f4a5096b385c9bcc94424cf2eaa227b3761 (2.34-500) -Fix-Commit: 31eb872cb21449832ab47ad5db83281d240e1d03 (2.34-503) -Reported-By: Qualys Security Advisory diff --git a/advisories/GLIBC-SA-2025-0002 b/advisories/GLIBC-SA-2025-0002 deleted file mode 100644 index 161da13dd4..0000000000 --- a/advisories/GLIBC-SA-2025-0002 +++ /dev/null @@ -1,23 +0,0 @@ -elf: static setuid binary dlopen may incorrectly search LD_LIBRARY_PATH - -A statically linked setuid binary that calls dlopen (including internal -dlopen calls after setlocale or calls to NSS functions such as getaddrinfo) -may incorrectly search LD_LIBRARY_PATH to determine which library to load, -leading to the execution of library code that is attacker controlled. - -The only viable vector for exploitation of this bug is local, if a static -setuid program exists, and that program calls dlopen, then it may search -LD_LIBRARY_PATH to locate the SONAME to load. No such program has been -discovered at the time of publishing this advisory, but the presence of -custom setuid programs, although strongly discouraged as a security -practice, cannot be discounted. - -CVE-Id: CVE-2025-4802 -Public-Date: 2025-05-16 -Vulnerable-Commit: 10e93d968716ab82931d593bada121c17c0a4b93 (2.27) -Fix-Commit: 5451fa962cd0a90a0e2ec1d8910a559ace02bba0 (2.39) -Fix-Commit: 3be3728df2f1912c80abd3288bc6e3a25ad679e4 (2.38-132) -Fix-Commit: 7403ede2d7752e59e0c47d5d33d73c2bf850e7be (2.37-154) -Fix-Commit: 2ef7850279b2931caf6d6d6743ebaa91839e1cf7 (2.36-227) -Fix-Commit: 621c65ccf12ddd415ceeb2234423bd1acd0fabb3 (2.35-387) -Fix-Commit: 35018c0fd20eac9ceaf60060fed2745b3177359d (2.34-517) diff --git a/advisories/GLIBC-SA-2025-0003 b/advisories/GLIBC-SA-2025-0003 deleted file mode 100644 index 2adeb3ce00..0000000000 --- a/advisories/GLIBC-SA-2025-0003 +++ /dev/null @@ -1,30 +0,0 @@ -power10: strcmp fails to save and restore nonvolatile vector registers - -The Power 10 implementation of strcmp in -sysdeps/powerpc/powerpc64/le/power10/strcmp.S failed to save/restore -nonvolatile vector registers in the 32-byte aligned loop path. This -results in callers reading content from those registers in a different -context, potentially altering program logic. - -There could be a program context where a user controlled string could -leak through strcmp into program code, thus altering its logic. There -is also a potential for sensitive strings passed into strcmp leaking -through the clobbered registers into parts of the calling program that -should otherwise not have had access to those strings. - -The impact of this flaw is limited to applications running on Power 10 -hardware that use the nonvolatile vector registers, i.e. v20 to v31 -assuming that they have been treated in accordance with the OpenPower -psABI. It is possible to work around the issue for those specific -applications by setting the glibc.cpu.hwcaps tunable to "-arch_3_1" like -so: - - export GLIBC_TUNABLES=glibc.cpu.hwcaps=-arch_3_1 - -CVE-Id: CVE-2025-5702 -Public-Date: 2025-06-04 -Vulnerable-Commit: 3367d8e180848030d1646f088759f02b8dfe0d6f (2.39) -Fix-Commit: 15808c77b35319e67ee0dc8f984a9a1a434701bc (2.42) -Fix-Commit: 0c76c951620f9e12df2a89b2c684878b55bb6795 (2.41-60) -Fix-Commit: 7e12550b8e3a11764a4a9090ce6bd3fc23fc8a8e (2.40-139) -Fix-Commit: 06a70769fd0b2e1f2a3085ad50ab620282bd77b3 (2.39-209) diff --git a/advisories/GLIBC-SA-2025-0004 b/advisories/GLIBC-SA-2025-0004 deleted file mode 100644 index 9409ca27c4..0000000000 --- a/advisories/GLIBC-SA-2025-0004 +++ /dev/null @@ -1,29 +0,0 @@ -power10: strncmp fails to save and restore nonvolatile vector registers - -The Power 10 implementation of strncmp in -sysdeps/powerpc/powerpc64/le/power10/strncmp.S failed to save/restore -nonvolatile vector registers in the 32-byte aligned loop path. This -results in callers reading content from those registers in a different -context, potentially altering program logic. - -There could be a program context where a user controlled string could -leak through strncmp into program code, thus altering its logic. There -is also a potential for sensitive strings passed into strncmp leaking -through the clobbered registers into parts of the calling program that -should otherwise not have had access to those strings. - -The impact of this flaw is limited to applications running on Power 10 -hardware that use the nonvolatile vector registers, i.e. v20 to v31 -assuming that they have been treated in accordance with the OpenPower -psABI. It is possible to work around the issue for those specific -applications by setting the glibc.cpu.hwcaps tunable to "-arch_3_1" like -so: - - export GLIBC_TUNABLES=glibc.cpu.hwcaps=-arch_3_1 - -CVE-Id: CVE-2025-5745 -Public-Date: 2025-06-05 -Vulnerable-Commit: 23f0d81608d0ca6379894ef81670cf30af7fd081 (2.40) -Fix-Commit: 63c60101ce7c5eac42be90f698ba02099b41b965 (2.42) -Fix-Commit: 84bdbf8a6f2fdafd3661489dbb7f79835a52da82 (2.41-57) -Fix-Commit: 42a5a940c974d02540c8da26d6374c744d148cb9 (2.40-136) diff --git a/advisories/GLIBC-SA-2025-0005 b/advisories/GLIBC-SA-2025-0005 deleted file mode 100644 index 8bcccc59a5..0000000000 --- a/advisories/GLIBC-SA-2025-0005 +++ /dev/null @@ -1,14 +0,0 @@ -posix: Fix double-free after allocation failure in regcomp - -The regcomp function in the GNU C library version from 2.4 to 2.41 is -subject to a double free if some previous allocation fails. It can be -accomplished either by a malloc failure or by using an interposed -malloc that injects random malloc failures. The double free can allow -buffer manipulation depending of how the regex is constructed. -This issue affects all architectures and ABIs supported by the GNU C -library. - -CVE-Id: CVE-2025-8058 -Public-Date: 2025-07-22 -Vulnerable-Commit: 963d8d782fc98fb6dc3a66f0068795f9920c269d (2.3.3-1596) -Fix-Commit: 7ea06e994093fa0bcca0d0ee2c1db271d8d7885d (2.42) diff --git a/advisories/GLIBC-SA-2026-0001 b/advisories/GLIBC-SA-2026-0001 deleted file mode 100644 index 3e0ee3b3f4..0000000000 --- a/advisories/GLIBC-SA-2026-0001 +++ /dev/null @@ -1,41 +0,0 @@ -Integer overflow in memalign leads to heap corruption - -Passing too large an alignment to the memalign suite of functions -(memalign, posix_memalign, aligned_alloc) in the GNU C Library version -2.30 to 2.42 may result in an integer overflow, which could consequently -result in a heap corruption. - -Note that the attacker must have control over both, the size as well as -the alignment arguments of the memalign function to be able to exploit -this. The size parameter must be close enough to PTRDIFF_MAX so as to -overflow size_t along with the large alignment argument. This limits -the malicious inputs for the alignment for memalign to the range [1<<62 -+ 1, 1<<63] and exactly 1<<63 for posix_memalign and aligned_alloc. - -Typically the alignment argument passed to such functions is a known -constrained quantity (e.g. page size, block size, struct sizes) and is -not attacker controlled, because of which this may not be easily -exploitable in practice. An application bug could potentially result in -the input alignment being too large, e.g. due to a different buffer -overflow or integer overflow in the application or its dependent -libraries, but that is again an uncommon usage pattern given typical -sources of alignments. - -CVE-Id: CVE-2026-0861 -Public-Date: 2026-01-14 -Vulnerable-Commit: 9bf8e29ca136094f73f69f725f15c51facc97206 (2.30) -Fix-Commit: c9188d333717d3ceb7e3020011651f424f749f93 (2.43) -Fix-Commit: 7f19ef14fbce095d4c77395e258320cad2ea2b28 (2.30-153) -Fix-Commit: f18446d7b4a423090ee5e328c36b3c2a0f26041c (2.31-166) -Fix-Commit: 8aef9e7a7af9565c0324b4ecb38b30dfa3782fd8 (2.32-151) -Fix-Commit: 011293b4fd748cdd6f95874ba2b6aba9a3df8bff (2.33-275) -Fix-Commit: 2c77e52108a58956c9f674b36e1f59a4e3fdcf4d (2.34-525) -Fix-Commit: 499d1ccafccfe64df1b88deea2fa84d8180e8e8f (2.35-399) -Fix-Commit: fb6b8822175769b5794fb6ea04f2895483a29b61 (2.36-244) -Fix-Commit: 7b913d41a07836def826f2164c52541a9835f324 (2.37-172) -Fix-Commit: 744b63026a29f7eedbbc8e3a01a7f48a6eb0a085 (2.38-212) -Fix-Commit: fb22fd3f5b415dd4cd6f7b5741c2f0412374e242 (2.39-286) -Fix-Commit: bfc4dd9e526eacf3017dd8864ba0848e9d045dd4 (2.40-216) -Fix-Commit: 1e2c1ea4307197ccece0cda574bcfebf9080894c (2.41-121) -Fix-Commit: b0ec8fb689df862171f0f78994a3bdeb51313545 (2.42-49) -Reported-by: Igor Morgenstern, Aisle Research diff --git a/advisories/GLIBC-SA-2026-0002 b/advisories/GLIBC-SA-2026-0002 deleted file mode 100644 index f10d8362f6..0000000000 --- a/advisories/GLIBC-SA-2026-0002 +++ /dev/null @@ -1,36 +0,0 @@ -getnetbyaddr and getnetbyaddr_r leak stack contents to DNS resovler - -Calling getnetbyaddr or getnetbyaddr_r with a configured nsswitch.conf -that specifies the library's DNS backend for networks and queries for a -zero-valued network in the GNU C Library version 2.0 to version 2.42 -can leak stack contents to the configured DNS resolver. - -A defect in the _nss_dns_getnetbyaddr_r function which implements -getnetbyaddr and getnetbyaddr_r in the dns-based network database can -pass stack contents unmodified to the configured DNS resolver as part of -the network DNS query when the network queried is the default network -i.e. net == 0x0. This stack contents leaking in the query is considered -a loss of confidentiality for the host making the query. Typically it -is rare to call these APIs with a net value of zero, and if an attacker -can control the net value it can only leak adjacent stack, and so loss -of confidentiality is spatially limited. The leak might be used to -accelerate an ASLR bypass by knowing pointer values, but also requires -network adjacent access to snoop between the application and the -DNS server; making the attack complexity higher. - -CVE-Id: CVE-2026-0915 -Public-Date: 2026-01-15 -Vulnerable-Commit: 5f0e6fc702296840d2daa39f83f6cb1e40073d58 (1.92-1) -Fix-Commit: e56ff82d5034ec66c6a78f517af6faa427f65b0b (2.43) -Fix-Commit: 453e6b8dbab935257eb0802b0c97bca6b67ba30e (2.42-50) -Fix-Commit: 15c9839a0b853f552b4ed9047841b6223f3c104d (2.41-122) -Fix-Commit: 329c775788b2c9ff3da774ccf59fba7b6b8ff08e (2.40-217) -Fix-Commit: 831f63b94ceb92fb14c0d1a7ddad35a0d1404c71 (2.39-287) -Fix-Commit: 49125ffc8e1674dc2a100dfdc5b78796f22e16f2 (2.38-213) -Fix-Commit: ddcaed5dfb05b2c1a6ea842fd6b643501365450a (2.37-173) -Fix-Commit: a6bf47887f24b2b394acb301a3189fda04bd4d4d (2.36-245) -Fix-Commit: 66f0cb057c9b4fb1249a5fec6ef4a63511a37899 (2.35-400) -Fix-Commit: 96863dee262225cfb79f9fe45e06fd188319c7b8 (2.34-526) -Fix-Commit: d210011f1536c8322157cbb4fe4229b35c834c08 (2.33-276) -Fix-Commit: 1bc1832cfc74c2a601220969f36e789a5e9f0ebe (2.32-152) -Reported-by: Igor Morgenstern, Aisle Research diff --git a/advisories/GLIBC-SA-2026-0003 b/advisories/GLIBC-SA-2026-0003 deleted file mode 100644 index b7a6e83a10..0000000000 --- a/advisories/GLIBC-SA-2026-0003 +++ /dev/null @@ -1,36 +0,0 @@ -wordexp with WRDE_REUSE and WRDE_APPEND may return uninitialized memory - -Calling wordexp with WRDE_REUSE in conjunction with WRDE_APPEND in the -GNU C Library version 2.0 to version 2.42 may cause the interface to -return uninitialized memory in the we_wordv member, which on subsequent -calls to wordfree may abort the process. - -The implementation of WRDE_REUSE in conjunction with WRDE_APPEND fails -to clear the we_wordc member of the structure, and as such, when new -words are added internally, a leading we_wordc count number of entries -are skipped since they are assumed initialized. These skipped entries -are not initialized, but are the contents of a realloc-expanded array of -pointers. If the caller inspects the we_wordv array, it will -dereference invalid pointers and crash. If the caller calls wordfree, -the malloc implementation may detect the invalid pointers and abort the -process. Calls to wordexp using WRDE_REUSE and WRDE_APPEND have never -worked correctly and thus the existence of applications that make use of -this feature is unlikely. - -CVE-Id: CVE-2025-15281 -Public-Date: 2026-01-20 -Vulnerable-Commit: 8f2ece695d8822e9ecc63ecd157e90bf17a6fe65 (1.93-260) -Fix-Commit: 80cc58ea2de214f85b0a1d902a3b668ad2ecb302 (2.43) -Fix-Commit: cbf39c26b25801e9bc88499b4fd361ac172d4125 (2.42-51) -Fix-Commit: fb4db64a04ad6c96cd1fbb7e02eb59323b1f2ac2 (2.41-123) -Fix-Commit: 9fe8576664d43b87ca19401fb6a975e217e47623 (2.40-218) -Fix-Commit: ce65d944e38a20cb70af2a48a4b8aa5d8fabe1cc (2.39-288) -Fix-Commit: d5409a1be010699794264162c551ba60f05ee6c3 (2.38-214) -Fix-Commit: ff2b172803f6bbd897755d2ce83ec4323a1a15b3 (2.37-174) -Fix-Commit: e97cfe2293ed097eb3d0b4c18274d22855e65130 (2.36-246) -Fix-Commit: bb59339d02faebac534a87eea50c83c948f35b77 (2.35-401) -Fix-Commit: 2b656ff94d72f93c84d8da2e7c76456c1994f02e (2.34-527) -Fix-Commit: 1d8ed2067a8a5d162a07670d0d063429679f17a0 (2.33-277) -Fix-Commit: 3a56c4ee4ea49b8f2391a2d8d6220013c4160a79 (2.32-153) -Fix-Commit: 28eb5caf895ced5d895cb02757e109004a2d33e5 (2.31-167) -Reported-by: Vitaly Simonovich diff --git a/advisories/GLIBC-SA-2026-0004 b/advisories/GLIBC-SA-2026-0004 deleted file mode 100644 index fd630dc591..0000000000 --- a/advisories/GLIBC-SA-2026-0004 +++ /dev/null @@ -1,30 +0,0 @@ -nscd client crash on x86_64 under high nscd load - -Calling NSS-backed functions that support caching via nscd may call the -nscd client side code and in the GNU C Library version 2.36 under high -load on x86_64 systems, the client may call memcmp on inputs that are -concurrently modified by other processes or threads and crash. - -The nscd client in the GNU C Library uses the memcmp function with -inputs that may be concurrently modified by another thread, potentially -resulting in spurious cache misses, which in itself is not a security -issue. However in the GNU C Library version 2.36 an optimized -implementation of memcmp was introduced for x86_64 which could crash -when invoked with such undefined behaviour, turning this into a -potential crash of the nscd client and the application that uses it. -This implementation was backported to the 2.35 branch, making the nscd -client in that branch vulnerable as well. Subsequently, the fix for -this issue was backported to all vulnerable branches in the GNU C -Library repository. - -It is advised that distributions that may have cherry-picked the memcpy -SSE2 optimization in their copy of the GNU C Library, also apply the fix -to avoid the potential crash in the nscd client. - -CVE-Id: CVE-2026-3904 -Public-Date: 2026-03-11 -Vulnerable-Commit: 8804157ad9da39631703b92315460808eac86b0c (2.36) -Vulnerable-Commit: 5a8df6485c584e2b0e957ec6b9070437a724911a (2.35-89) -Fix-Commit: b712be52645282c706a5faa038242504feb06db5 (2.37) -Fix-Commit: 93967a2a7bbdcedb73e0b246713580c7c84d001e (2.36-84) -Fix-Commit: 6bcd5d8e3668d52388a6e0580611749f93e6871f (2.35-230) diff --git a/advisories/GLIBC-SA-2026-0005 b/advisories/GLIBC-SA-2026-0005 deleted file mode 100644 index 7a50a43263..0000000000 --- a/advisories/GLIBC-SA-2026-0005 +++ /dev/null @@ -1,37 +0,0 @@ -gethostbyaddr and gethostbyaddr_r may incorrectly handle DNS response - -Calling gethostbyaddr or gethostbyaddr_r with a configured nsswitch.conf -that specifies the library's DNS backend in the GNU C Library version -2.34 to version 2.43 could, with a crafted response from the configured -DNS server, result in a violation of the DNS specification that causes -the application to treat a non-answer section of the DNS response as a -valid answer. - -A defect in the getanswer_ptr function, which implements the iteration -and extraction of the answer from the DNS response, can cause it to -incorrectly transition from the answer section to the next section while -still treating it as an answer to the question. This can happen when -the answer contains only skipped records, and the subsequent section -contains a semantically invalid T_PTR record. This is considered a -security issue because it is a violation of the DNS specification that -leads to incorrect behaviour that could result in the wrong hostname -being returned to the caller. At the time of publication, no known -affected DNS server returns results that would be incorrectly -interpreted by the library. An attacker would either need to be network -adjacent or have compromised the DNS server to use this defect to hide -returned reverse DNS results from intrusion detection systems. Even -then, the inbound connection from the attacker, or the outbound -connection from the application, would be visible to the intrusion -detection system. At best, the defect can be used to obfuscate and -delay analysis of the evolving threat. - -CVE-Id: CVE-2026-4437 -Public-Date: 2026-03-20 -Vulnerable-Commit: 32e5db37684ffcbc6ae34fcc6cdcf28670506baa (2.34-323) -Vulnerable-Commit: def97e7f71a07517810f7263213d607e08ad21f1 (2.35-188) -Vulnerable-Commit: 77f523c473878ec0051582ef15161c6982879095 (2.36-30) -Vulnerable-Commit: e32547d661a43da63368e488b6cfa9c53b4dcf92 (2.37) -Fix-Commit: 5c6fca0c62ce5bd6e68e259f138097756cbafd4d (2.43-16) -Fix-Commit: 9f5f18aab40ec6b61fa49a007615e6077e9a979b (2.44) -Reported-by: Antonio Maini (0rbitingZer0) - 0rbitingZer0@proton.me -Reported-by: Kevin Farrell diff --git a/advisories/GLIBC-SA-2026-0006 b/advisories/GLIBC-SA-2026-0006 deleted file mode 100644 index 1ac70de4d9..0000000000 --- a/advisories/GLIBC-SA-2026-0006 +++ /dev/null @@ -1,27 +0,0 @@ -gethostbyaddr and gethostbyaddr_r return invalid DNS hostnames - -Calling gethostbyaddr or gethostbyaddr_r with a configured nsswitch.conf -that specifies the library's DNS backend in the GNU C library version -2.34 to version 2.43 could result in an invalid DNS hostname being -returned to the caller in violation of the DNS specification. - -A defect in the getanswer_ptr function, which implements the iteration -and extraction of the answer from a DNS response, can cause it to accept -an invalid DNS hostname that can contain shell metacharacters. An -application that uses the returned hostname in a shell, without guarding -for shell expansion, may be subject to shell injection attacks. At the -time of publication, no known affected DNS server returns results with -shell metacharacters in the results. An attacker would either need to -be network adjacent or have compromised the DNS server to use this -defect for shell injection. No known vulnerable application has been -identified. - -CVE-Id: CVE-2026-4438 -Public-Date: 2026-03-20 -Vulnerable-Commit: 32e5db37684ffcbc6ae34fcc6cdcf28670506baa (2.34-323) -Vulnerable-Commit: def97e7f71a07517810f7263213d607e08ad21f1 (2.35-188) -Vulnerable-Commit: 77f523c473878ec0051582ef15161c6982879095 (2.36-30) -Vulnerable-Commit: e32547d661a43da63368e488b6cfa9c53b4dcf92 (2.37) -Fix-Commit: dd9945c0ba40d2dbc9eb7c99291ba6b69bd66718 (2.43-17) -Fix-Commit: e10977481f4db4b2a3ce34fa4c3a1e26651ae312 (2.44) -Reported-by: Antonio Maini (0rbitingZer0) - 0rbitingZer0@proton.me diff --git a/advisories/GLIBC-SA-2026-0007 b/advisories/GLIBC-SA-2026-0007 deleted file mode 100644 index b880fb5544..0000000000 --- a/advisories/GLIBC-SA-2026-0007 +++ /dev/null @@ -1,15 +0,0 @@ -iconv crash due to assertion failure with untrusted input - -The iconv() function in the GNU C Library versions 2.43 and earlier may -crash due to an assertion failure when converting inputs from the -IBM1390 or IBM1399 character sets, which may be used to remotely crash -an application. - -This vulnerability can be trivially mitigated by removing the IBM1390 -and IBM1399 character sets from systems that do not need them. - -CVE-Id: CVE-2026-4046 -Public-Date: 2026-03-12 -Vulnerable-Commit: 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (2.3.3-1501) -Fix-Commit: d6f08d1cf027f4eb2ba289a6cc66853722d4badc (2.44) -Reported-by: Rocket Ma diff --git a/advisories/GLIBC-SA-2026-0008 b/advisories/GLIBC-SA-2026-0008 deleted file mode 100644 index 43b38ce38a..0000000000 --- a/advisories/GLIBC-SA-2026-0008 +++ /dev/null @@ -1,22 +0,0 @@ -REJECTED: Static buffer overflow in deprecated nis_local_principal - -REJECTED: CVE-2026-5358 is rejected for two reasons. Firstly it has been -discovered that no NIS+ client or server was ever released for any -Linux-based OS distributions and as such this makes the API provisional -and unused. Secondly it has been discovered that the NIS+ cold start -cache (/var/nis/NIS_COLD_START) cannot be bypassed and as such the API -can only be called with a trusted server from the pre-populated cache. -The use of a trusted server means no trust boundary is crossed and this -is therefore considered a normal bug. - -NIS+ support in the GNU C Library was never officially supported even -though an incomplete implementation of the APIs was made pulibc. To the -best knowledge of the glibc security team no open-source NIS+ server -implementations were ever released for use with this API. Applications -should not use any of the NIS+ APIs and should move to modern identity -and access management services. - -CVE-Id: CVE-2026-5358 -Public-Date: 2026-04-10 -Rejected-Date: 2026-04-33 -Reported-by: Rahul Hoysala diff --git a/advisories/GLIBC-SA-2026-0009 b/advisories/GLIBC-SA-2026-0009 deleted file mode 100644 index 3c297fdc80..0000000000 --- a/advisories/GLIBC-SA-2026-0009 +++ /dev/null @@ -1,23 +0,0 @@ -scanf %mc off-by-one heap buffer overflow - -Calling the scanf family of functions with a %mc (malloc'd character -match) in the GNU C Library version 2.7 to version 2.43 with a format -width specifier with an explicit width greater than 1024 could result in -a one byte heap buffer overflow. - -The bug is in the buffer growth formula in __vfscanf_internal, which -under-allocates by one byte during realloc expansion, allowing a -controlled single-byte overwrite past the end of the heap buffer. - -The impact is limited by the fact that to execute the overwrite you need -both user controlled input data and a specific choice of maximum width -that yields a smaller than needed allocation. The latter point has to -take into account malloc's particular chunk size rounding process. The -"%[width]mc" format specifier does not appear to have notable use in -major Linux-based OS distributions, due to which the real world impact -may be limited to bespoke use cases. - -CVE-Id: CVE-2026-5450 -Public-Date: 2026-03-19 -Vulnerable-Commit: 874aa52349cc111d1f6ea5dff24bb14c306714e0 (2.7) -Reported-by: Rocket Ma diff --git a/advisories/GLIBC-SA-2026-0010 b/advisories/GLIBC-SA-2026-0010 deleted file mode 100644 index ae9953fb71..0000000000 --- a/advisories/GLIBC-SA-2026-0010 +++ /dev/null @@ -1,24 +0,0 @@ -Potential buffer under-read in ungetwc - -Calling the ungetwc function on a FILE stream with wide characters -encoded in a character set that has overlaps between its single byte and -multi-byte character encodings, in the GNU C Library version 2.43 or -earlier, may result in an attempt to read bytes before an allocated -buffer, potentially resulting in unintentional disclosure of neighboring -data in the heap, or a program crash. - -A bug in the wide character pushback implementation -(_IO_wdefault_pbackfail in libio/wgenops.c) causes ungetwc() to operate -on the regular character buffer (fp->_IO_read_ptr) instead of the actual -wide-stream read pointer (fp->_wide_data->_IO_read_ptr). The program -crash may happen in cases where fp->_IO_read_ptr is not initialized and -hence points to NULL. The buffer under-read requires a special situation -where the input character encoding is such that there are overlaps -between single byte representations and multibyte representations in -that encoding, resulting in spurious matches. The spurious match case -is not possible in the standard Unicode character sets. - -CVE-Id: CVE-2026-5928 -Public-Date: 2026-03-17 -Reported-by: Rocket Ma -Vulnerable-Commit: d64b6ad07585b8a37e5fecc9a47fcee766d52ede (2.1.1-89) diff --git a/advisories/GLIBC-SA-2026-0011 b/advisories/GLIBC-SA-2026-0011 deleted file mode 100644 index e492fa5507..0000000000 --- a/advisories/GLIBC-SA-2026-0011 +++ /dev/null @@ -1,24 +0,0 @@ -Potential buffer overflow in ns_sprintrrf TSIG handling path - -The deprecated functions ns_printrrf, ns_printrr and fp_nquery in the -GNU C Library version 2.2 and newer fail to enforce the caller-supplied -buffer length, and can result in an out-of-bounds write when printing -TSIG records. - -A defect in the TSIG case handling within ns_sprintrrf performs a -formatted write using sprintf without checking the remaining buffer -length, and may write up to 6 bytes past the end of the buffer. If the -library is compiled with assertions, and the out-of-bounds write doesn't -terminate the process, then a subsequent check for "len <= *buflen" will -trigger an assertion failure. - -These functions are for application debugging only and hence not in the -path of code executed by the DNS resolver. Further, they have been -deprecated since version 2.34 (2021-08-02) and should not be used by any -new applications. Applications should consider porting away from these -interfaces since they may be removed in future versions. - -CVE-Id: CVE-2026-5435 -Public-Date: 2026-04-02 -Vulnerable-Commit: b43b13ac2544b11f35be301d1589b51a8473e32b (2.2) -Reported-by: shinobu diff --git a/advisories/GLIBC-SA-2026-0012 b/advisories/GLIBC-SA-2026-0012 deleted file mode 100644 index 22071d97a6..0000000000 --- a/advisories/GLIBC-SA-2026-0012 +++ /dev/null @@ -1,18 +0,0 @@ -Buffer overread in ns_printrrf with corrupted RDATA field - -The deprecated functions ns_printrrf, ns_printrr and fp_nquery in the -GNU C Library version 2.0.1 to version 2.43 fail to validate the RDATA -content against the RDATA length in a DNS response when processing A6, -CERT, LOC, TKEY or TSIG records, which may allow an attacker to craft a -DNS response, causing a target application to crash or read -uninitialized memory. - -These functions are for application debugging only and hence not in the -path of code executed by the DNS resolver. Further, they have been -deprecated since version 2.34 and should not be used by any new -applications. Applications should consider porting away from these -interfaces since they may be removed in future versions. - -CVE-Id: CVE-2026-6238 -Public-Date: 2026-04-11 -Vulnerable-Commit: ee188d555b8c32ad9704a7440cab400af967292f (1.90) diff --git a/advisories/GLIBC-SA-2026-0013 b/advisories/GLIBC-SA-2026-0013 deleted file mode 100644 index 085a853434..0000000000 --- a/advisories/GLIBC-SA-2026-0013 +++ /dev/null @@ -1,20 +0,0 @@ -Potential stack-based buffer clash during tilde expansion in wordexp - -Calling wordexp with a tilde (~) followed by an overly long username -in the GNU C Library version 2.2.3 to 2.43 may lead to a stack buffer -clash. - -When expanding paths that begin with a tilde (~) followed by a username, the -internal parse_tilde function extracts the username to determine the user's -home directory. The implementation allocates memory for this username directly -on the stack using the strndupa macro. Because the size of this allocation -was determined by the length of the user-supplied input without any bounds -checks, passing an excessively long username e.g. thousands of characters, -forces the thread to exhaust its stack space. Thus if an application passes -untrusted, attacker-controlled input to the wordexp function, an attacker -can trigger a stack clash. - -CVE-Id: CVE-2026-6791 -Public-Date: 2026-06-22 -Vulnerable-Commit: 344af000e1d6e9c7882b9bc48e71cb3f1b5fc03c (2.2.3-114) -Reported-by: storm diff --git a/advisories/GLIBC-SA-2026-0014 b/advisories/GLIBC-SA-2026-0014 deleted file mode 100644 index 1e9a0039f0..0000000000 --- a/advisories/GLIBC-SA-2026-0014 +++ /dev/null @@ -1,19 +0,0 @@ -wordexp with WRDE_APPEND may result in an invalid call to free() - -Calling wordexp with WRDE_APPEND in conjunction with an invalid expansion -(where an error like WRDE_BADCHAR would be returned) can create a stale -address in the wordexp_t that can cause an invalid free from wordfree. -This affects the GNU C Library version 2.0 to version 2.43. - -In WRDE_APPEND mode, wordexp saves the caller-visible wordexp_t state -before appending the processing input. If the word expansion grows -we_wordv via realloc, and realloc requires moving we_wordv to a new memory -location (instead of expanding in-place), and the expansion later fails, -the rollback fails to properly restore all previous we_wordv values and -may add stale pointers into the caller-visible state. A subsequent -wordfree may then issue an invalid call to free(). - -CVE-Id: CVE-2026-6368 -Public-Date: 2026-07-14 -Vulnerable-Commit: 8f2ece695d8822e9ecc63ecd157e90bf17a6fe65 (1.93-260) -Reported-by: shinobu diff --git a/advisories/README b/advisories/README deleted file mode 100644 index 330a31dff3..0000000000 --- a/advisories/README +++ /dev/null @@ -1,92 +0,0 @@ -GNU C Library Security Advisory Format -====================================== - -Security advisories in this directory follow a simple git commit log -format, with a heading and free-format description augmented with tags -to allow parsing key information. References to code changes are -specific to the glibc repository and follow a specific format: - - Tag-name: (release-version) - -The indicates a specific commit in the repository. The -release-version indicates the publicly consumable release in which this -commit is known to exist. The release-version is derived from the -git-describe format, (i.e. stripped out from glibc-2.34.NNN-gxxxx) and -is of the form 2.34-NNN. If the -NNN suffix is absent, it means that -the change is in that release tarball, otherwise the change is on the -release/2.YY/master branch and not in any released tarball. - -The following tags are currently being used: - -CVE-Id: -This is the CVE-Id assigned under the CVE Program -(https://www.cve.org/). - -Public-Date: -The date this issue became publicly known. - -Rejected-Date: -The most recent date the assigned advisory was rejected. If the advisory -is ever published again the Rejected-Date tag should be removed. - -Vulnerable-Commit: -The commit that introduced this vulnerability. There could be multiple -entries, one for each release branch in the glibc repository; the -release-version portion of this tag should tell you which branch this is -on. - -Fix-Commit: -The commit that fixed this vulnerability. There could be multiple -entries for each release branch in the glibc repository, indicating that -all of those commits contributed to fixing that issue in each of those -branches. - -Reported-By: -The entity that reported this issue. There could be multiple entries, one for -each reporter. - -Adding an Advisory ------------------- - -An advisory for a CVE needs to be added on the master branch in two steps: - -1. Add the text of the advisory without any Fix-Commit tags along with - the fix for the CVE. Add the Vulnerable-Commit tag, if applicable. - The advisories directory does not exist in release branches, so keep - the advisory text commit distinct from the code changes, to ease - backports. Ask for the GLIBC-SA advisory number from the security - team. - -2. Finish all backports on release branches and then back on the msater - branch, add all commit refs to the advisory using the Fix-Commit - tags. Don't bother adding the release-version subscript since the - next step will overwrite it. - -3. Run the process-advisories.sh script in the scripts directory on the - advisory: - - scripts/process-advisories.sh update GLIBC-SA-YYYY-NNNN - - (replace YYYY-NNNN with the actual advisory number). - -4. Verify the updated advisory and push the result. - -Rejecting an Advisory ---------------------- - -Rejecting an advisory on the master branch can be done in one step: - -1. Mark the advisory as rejected. Add the text "REJECTED: " as a prefix - to any short-form description. Add a new paragraph that starts with - "REJECTED: " and explains the reason for the rejection including - justification for why it no longer has security impact. Lastly add - a Rejected-Date tag to the advisory. - -Getting a NEWS snippet from advisories --------------------------------------- - -Run: - - scripts/process-advisories.sh news - -and copy the content into the NEWS file. diff --git a/benchtests/Makefile b/benchtests/Makefile index f407e492cb..16cc951d19 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -622,6 +622,7 @@ $(bench-link-targets): %: %.o $(objpfx)json-lib.o \ $(bench-link-targets): LDFLAGS += $(link-bench-bind-now) $(objpfx)bench-%.c: %-inputs $(bench-deps) + $(make-target-directory) { if [ -n "$($*-INCLUDE)" ]; then \ cat $($*-INCLUDE); \ fi; \ diff --git a/config.make.in b/config.make.in index 0ddc24a589..8b467a2efd 100644 --- a/config.make.in +++ b/config.make.in @@ -53,7 +53,7 @@ c++-bits-std_abs-h = @CXX_BITS_STD_ABS_H@ enable-werror = @enable_werror@ have-z-execstack = @libc_cv_z_execstack@ -have-no-error-execstack = @libc_cv_no_error_execstack@ +have-no-error-execstack = @libc_cv_test_no_error_execstack@ have-protected-data = @libc_cv_protected_data@ have-insert = @libc_cv_insert@ have-glob-dat-reloc = @libc_cv_has_glob_dat@ diff --git a/conform/data/spawn.h-data b/conform/data/spawn.h-data index 1f332324c2..43aa9cb8ae 100644 --- a/conform/data/spawn.h-data +++ b/conform/data/spawn.h-data @@ -29,10 +29,6 @@ function int posix_spawnattr_setpgroup (posix_spawnattr_t*, pid_t) function int posix_spawnattr_setschedparam (posix_spawnattr_t*, const struct sched_param*) function int posix_spawnattr_setschedpolicy (posix_spawnattr_t*, int) function int posix_spawnattr_setsigmask (posix_spawnattr_t*, const sigset_t*) -#if defined XOPEN2K24 || defined POSIX2024 -function int posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t*, const char *) -function int posix_spawn_file_actions_addfchdir (posix_spawn_file_actions_t*, int) -#endif function int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t*, int) function int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t*, int, int) function int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t*, int, const char *, int, mode_t) diff --git a/debug/tst-backtrace5.c b/debug/tst-backtrace5.c index 4c5784c060..6538da9ab5 100644 --- a/debug/tst-backtrace5.c +++ b/debug/tst-backtrace5.c @@ -36,10 +36,15 @@ trampoline, read, 3 * fn, and do_test. */ #define NUM_FUNCTIONS 7 +/* Avoid the read wrapper frame truncation on targets that add extra frames + between it and handle_signal (the cancellable syscall wrappers + __syscall_cancel*, or the i686 __kernel_vsyscall entry). */ +#define MAX_FUNCTIONS 64 + void handle_signal (int signum) { - void *addresses[NUM_FUNCTIONS]; + void *addresses[MAX_FUNCTIONS]; char **symbols; int n; int i; @@ -70,23 +75,28 @@ handle_signal (int signum) return; } - /* Do not check name for signal trampoline or cancellable syscall - wrappers (__syscall_cancel*). */ - for (; i < n - 1; i++) + /* Skip the signal trampoline and any cancellable syscall wrapper frames + (__syscall_cancel*) and require the read syscall wrapper to be + present. */ + for (i = 1; i < n; i++) if (match (symbols[i], "read")) break; - if (i == n - 1) + if (i == n) { FAIL (); return; } - for (; i < n - 1; i++) - if (!match (symbols[i], "fn")) - { - FAIL (); - return; - } + /* The read wrapper must be followed by the three fn recursion frames. */ + for (int j = 0; j < 3; j++) + { + i++; + if (i == n || !match (symbols[i], "fn")) + { + FAIL (); + return; + } + } /* Symbol names are not available for static functions, so we do not check do_test. */ diff --git a/elf/Makefile b/elf/Makefile index 94c5b7e6ed..a9cafed56d 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -306,6 +306,7 @@ tst-ifunc-resolver-protector-static-non-pie-no-pie = yes tests-container := \ tst-dl-cache-long-path \ + tst-dl-cache-old-format \ tst-ldconfig-bad-aux-cache \ tst-ldconfig-ld_so_conf-update \ # tests-container @@ -566,6 +567,7 @@ tests-internal += \ tst-audit19a \ tst-create_format1 \ tst-dl-hwcaps_split \ + tst-dl-path-normalize \ tst-dl_find_object \ tst-dl_find_object-threads \ tst-dlmopen2 \ @@ -591,6 +593,7 @@ tests-container += \ tst-dlopen-self-container \ tst-dlopen-tlsmodid-container \ tst-ldconfig-cache \ + tst-origin-secure \ tst-pldd \ tst-preload-pthread-libc \ tst-ptrguard-static-dlopen \ @@ -599,6 +602,7 @@ tests-container += \ # tests-container test-srcs = \ + tst-origin-secure-victim \ tst-pathopt \ tst-sprof-basic \ # tests-srcs @@ -839,6 +843,7 @@ modules-names += \ libtracemod3-1 \ libtracemod4-1 \ libtracemod5-1 \ + libtst-origin-secure-mod \ ltglobmod1 \ ltglobmod2 \ neededobj1 \ @@ -1034,6 +1039,7 @@ modules-names += \ tst-nodeps2-mod \ tst-non-directory-mod \ tst-null-argv-lib \ + tst-origin-secure-evilmod \ tst-p_alignmod-base \ tst-p_alignmod3 \ tst-ptrguard-static-dlopen-mod \ @@ -1396,6 +1402,13 @@ modules-names += \ tst-ifunc-tls-write-lib \ tst-tls-tdata-reloc-lib \ # modules-names +ifeq (yes,$(have-gcc-ifunc)) +tests += \ + tst-ifunc-fault-dep-bindnow \ + tst-ifunc-fault-dep-lazy \ + # tests +modules-names += tst-ifunc-fault-mod +endif ifneq (no,$(have-test-mtls-descriptor)) tests += tst-ifunc-tls-init-tlsdesc modules-names += tst-ifunc-tls-init-tlsdesc-lib @@ -1425,6 +1438,7 @@ tests-special += \ $(objpfx)check-execstack.out \ $(objpfx)check-initfini.out \ $(objpfx)check-localplt.out \ + $(objpfx)check-symbol-version.out \ $(objpfx)check-textrel.out \ $(objpfx)check-wx-segment.out \ # tests-special @@ -1574,7 +1588,9 @@ $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os) # when compiled for libc. rtld-stubbed-symbols = \ __libc_assert_fail \ - __syscall_cancel \ + __libc_single_threaded_internal \ + __syscall_cancel_arch \ + __syscall_do_cancel \ calloc \ free \ malloc \ @@ -2368,6 +2384,12 @@ $(objpfx)check-initfini.out: $(..)scripts/check-initfini.awk \ $(evaluate-test) generated += check-initfini.out +$(objpfx)check-symbol-version.out: $(..)scripts/check-symbol-version.awk \ + $(all-built-dso:=.dynsym) + LC_ALL=C $(AWK) -f $^ > $@; \ + $(evaluate-test) +generated += check-symbol-version.out + $(objpfx)tst-dlopenrpath: $(objpfx)tst-dlopenrpathmod.so CFLAGS-tst-dlopenrpath.c += -DPFX=\"$(objpfx)\" LDFLAGS-tst-dlopenrpathmod.so += -Wl,-rpath,\$$ORIGIN/test-subdir @@ -2545,6 +2567,27 @@ $(objpfx)tst-ifunc-fault-bindnow.out: $(objpfx)tst-ifunc-fault-bindnow \ $(objpfx)ld.so $(tst-ifunc-fault-script) +LDFLAGS-tst-ifunc-fault-dep-lazy = -Wl,-z,lazy +LDFLAGS-tst-ifunc-fault-dep-bindnow = -Wl,-z,now +define tst-ifunc-fault-dep-script +( $(test-wrapper) $(rtld-prefix) --verify $< \ + && $(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 $(rtld-prefix) $< \ + && $(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 LD_DEBUG=unused \ + $(rtld-prefix) $< \ + && $(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 LD_WARN=yes LD_BIND_NOW=1 \ + $(rtld-prefix) $< \ +) > $@; $(evaluate-test) +endef +$(objpfx)tst-ifunc-fault-dep-lazy: $(objpfx)tst-ifunc-fault-mod.so +$(objpfx)tst-ifunc-fault-dep-bindnow: $(objpfx)tst-ifunc-fault-mod.so +$(objpfx)tst-ifunc-fault-dep-lazy.out: $(objpfx)tst-ifunc-fault-dep-lazy \ + $(objpfx)tst-ifunc-fault-mod.so $(objpfx)ld.so + $(tst-ifunc-fault-dep-script) +$(objpfx)tst-ifunc-fault-dep-bindnow.out: \ + $(objpfx)tst-ifunc-fault-dep-bindnow \ + $(objpfx)tst-ifunc-fault-mod.so $(objpfx)ld.so + $(tst-ifunc-fault-dep-script) + LDFLAGS-tst-ifunc-plt-lib.so = -Wl,-z,lazy tst-ifunc-plt-bindnow-ENV = LD_BIND_NOW=1 @@ -3006,9 +3049,10 @@ LDFLAGS-tst-dlopen-nodelete-reloc-mod17.so = -Wl,--no-as-needed $(objpfx)tst-ldconfig-ld_so_conf-update.out: $(objpfx)tst-ldconfig-ld-mod.so -# Reuses the trivial module already built for tst-dl-path-buf. $(objpfx)tst-dl-cache-long-path: $(shared-thread-library) +# Both cache tests reuse the trivial module already built for tst-dl-path-buf. $(objpfx)tst-dl-cache-long-path.out: $(objpfx)tst-dl-path-buf-mod.so +$(objpfx)tst-dl-cache-old-format.out: $(objpfx)tst-dl-path-buf-mod.so LDFLAGS-tst-dst-needed-leaf-mod.so = \ -Wl,-soname,\$$ORIGIN/\$$ORIGIN/\$$ORIGIN/\$$ORIGIN/\$$ORIGIN/leaf.so @@ -3734,3 +3778,16 @@ $(objpfx)tst-dl-debug-exclude.out: tst-dl-debug-exclude.sh \ $(objpfx)tst-recursive-tls > $@; \ $(evaluate-test) endif + +LDFLAGS-libtst-origin-secure-mod.so += -Wl,-soname,libtst-origin-secure-mod.so +LDFLAGS-tst-origin-secure-evilmod.so += -Wl,-soname,libtst-origin-secure-mod.so +$(objpfx)tst-origin-secure-victim: $(objpfx)libtst-origin-secure-mod.so +# The number of "../" here must match the layout invariants described in +# tst-origin-secure.c. +LDFLAGS-tst-origin-secure-victim += \ + -Wl,--no-as-needed \ + -Wl,-rpath,\$$ORIGIN/sub/../../../../..$(slibdir)/tst-origin-secure \ + -Wl,--disable-new-dtags +$(objpfx)tst-origin-secure.out: $(objpfx)tst-origin-secure-victim \ + $(objpfx)libtst-origin-secure-mod.so \ + $(objpfx)tst-origin-secure-evilmod.so diff --git a/elf/dl-load.c b/elf/dl-load.c index 95404adae9..471478649b 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "dynamic-link.h" #include "get-dynamic-info.h" @@ -91,67 +92,30 @@ static const size_t system_dirs_len[] = }; #define nsystem_dirs_len array_length (system_dirs_len) +/* Return true if the normalized path NPATH of length NLEN is rooted in one of + the trusted system directories. The system_dirs entries carry a trailing + '/'; NPATH matches an entry when it shares the entry's leading component + sequence and then either ends or continues with '/'. For instance, + "/lib64" and "/lib64/x" match "/lib64/" but "/lib64x" does not. */ static bool -is_trusted_path_normalize (const char *path, size_t len) +path_is_trusted (const char *npath, size_t nlen) { - if (len == 0) - return false; - - struct dl_scratch_buffer scratch = dl_scratch_buffer_init (); - dl_scratch_buffer_allocate (&scratch, len + 2, 0); - char *npath = scratch.data; - char *wnp = npath; - while (*path != '\0') - { - if (path[0] == '/') - { - if (path[1] == '.') - { - if (path[2] == '.' && (path[3] == '/' || path[3] == '\0')) - { - while (wnp > npath && *--wnp != '/') - ; - path += 3; - continue; - } - else if (path[2] == '/' || path[2] == '\0') - { - path += 2; - continue; - } - } - - if (wnp > npath && wnp[-1] == '/') - { - ++path; - continue; - } - } - - *wnp++ = *path++; - } - - if (wnp == npath || wnp[-1] != '/') - *wnp++ = '/'; - - bool result = false; const char *trun = system_dirs; for (size_t idx = 0; idx < nsystem_dirs_len; ++idx) { - if (wnp - npath >= system_dirs_len[idx] - && memcmp (trun, npath, system_dirs_len[idx]) == 0) - { - /* Found it. */ - result = true; - break; - } + /* Compare against the entry without its trailing '/'. */ + size_t dirlen = system_dirs_len[idx] - 1; + + if (nlen >= dirlen + && memcmp (trun, npath, dirlen) == 0 + && (npath[dirlen] == '/' || npath[dirlen] == '\0')) + return true; trun += system_dirs_len[idx] + 1; } - dl_scratch_buffer_free (&scratch); - return result; + return false; } /* Given a substring starting at INPUT, just after the DST '$' start @@ -335,16 +299,21 @@ _dl_dst_substitute (struct link_map *l, const char *input, char *result) checked for trust, the authors of the binaries themselves are trusted to have designed this correctly. Only $ORIGIN is tested in this way because it may be manipulated in some ways with hard - links. */ - if (__glibc_unlikely (check_for_trusted) - && !is_trusted_path_normalize (result, wp - result)) - { - *result = '\0'; - return result; - } + links. + + _dl_normalize_path replaces the expansion with its normalized form + in place, so that the path that is opened is exactly the path that + was validated. */ *wp = '\0'; + if (__glibc_unlikely (check_for_trusted)) + { + size_t nlen = _dl_normalize_path (result); + if (!path_is_trusted (result, nlen)) + *result = '\0'; + } + return result; } diff --git a/elf/dl-path-normalize.h b/elf/dl-path-normalize.h new file mode 100644 index 0000000000..ca4b14698c --- /dev/null +++ b/elf/dl-path-normalize.h @@ -0,0 +1,118 @@ +/* In-place lexical path normalization for the dynamic loader. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_PATH_NORMALIZE_H +#define _DL_PATH_NORMALIZE_H + +#include +#include + +/* Lexically normalize the null-terminated PATH in place and return the + length of the result (excluding the terminating NUL byte): + + - Runs of '/' are collapsed to a single '/'. + + - "." components are removed. + + - A ".." component removes the preceding component if there is one and it + is not itself a preserved "..". In an absolute path a surplus ".." at + the root is dropped ("/../a" normalizes to "/a"), in a relative path + leading ".." components are preserved ("../a" stays "../a", "a/../../b" + normalizes to "../b"). + + - The result has no trailing '/' except for the root path "/" itself + ("/a/" normalizes to "/a"). + + - The result is empty if and only if every component cancels or is removed + ("", ".", "a/.." all normalize to ""). + + The PATH is written in place, and the internal write cursor never runs + ahead of the read cursor. Only bytes within the strlen (PATH) + 1 storage + are accessed. */ +static inline size_t +_dl_normalize_path (char *path) +{ + /* The root '/' of an absolute path is not removed. */ + char *pstart = path + (path[0] == '/'); + const char *rnp = pstart; + char *wnp = pstart; + /* End of the prefix a ".." may not remove. Either the root '/', or, for + relative paths, the original start of the string extended by any + preserved leading ".." components. */ + char *limit = pstart; + + while (*rnp != '\0') + { + /* Collapse consecutive separators. */ + if (*rnp == '/') + { + ++rnp; + continue; + } + + /* [RNP, REND) is the next input component. */ + const char *rend = rnp; + while (*rend != '\0' && *rend != '/') + ++rend; + size_t clen = rend - rnp; + + /* Drop '.' component. */ + if (clen == 1 && rnp[0] == '.') + ; + else if (clen == 2 && rnp[0] == '.' && rnp[1] == '.') + { + if (wnp > limit) + { + /* Remove the last component along with the '/' separating it + from its predecessor (the root '/' of an absolute path is + retained). */ + while (wnp > limit && wnp[-1] != '/') + --wnp; + if (wnp > pstart) + --wnp; + } + else if (pstart == path) + { + /* No component is left and the original path is relative: + keep the unresolvable ".." (it becomes part of the + preserved prefix). */ + if (wnp > pstart) + *wnp++ = '/'; + *wnp++ = '.'; + *wnp++ = '.'; + limit = wnp; + } + /* Otherwise the path is absolute and the surplus ".." at the + root is dropped ("/../a" normalizes to "/a"). */ + } + else + { + if (wnp > pstart) + *wnp++ = '/'; + memmove (wnp, rnp, clen); + wnp += clen; + } + + rnp = rend; + } + + *wnp = '\0'; + return wnp - path; +} + +#endif /* _DL_PATH_NORMALIZE_H */ diff --git a/elf/dl-reloc-static-pie.c b/elf/dl-reloc-static-pie.c index 8463e46147..5dc5a545a8 100644 --- a/elf/dl-reloc-static-pie.c +++ b/elf/dl-reloc-static-pie.c @@ -80,7 +80,7 @@ _dl_relocate_static_pie (void) /* Relocate ourselves so we can do normal function calls and data access using the global offset table. IRELATIVE entries are deferred. */ - ELF_DYNAMIC_RELOCATE_NOIFUNC (main_map, NULL, 0, 0); + ELF_DYNAMIC_RELOCATE_PASS (DL_RELOC_NORMAL, main_map, NULL, 0, 0, 0); /* Initialize _r_debug_extended. */ struct r_debug *r = _dl_debug_initialize (0, LM_ID_BASE); @@ -98,7 +98,7 @@ void _dl_relocate_static_pie_ifunc (void) { struct link_map *main_map = _dl_get_dl_main_map (); - ELF_DYNAMIC_RELOCATE_IFUNC (main_map, NULL, 0, 0); + ELF_DYNAMIC_RELOCATE_PASS (DL_RELOC_IRELATIVE, main_map, NULL, 0, 0, 0); main_map->l_relocated = 1; } #endif diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index 15a6a4cffe..fa2f41ac44 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -278,7 +278,8 @@ _dl_relocate_object_no_relro (struct link_map *l, struct r_scope_elem *scope[], IFUNC resolvers. Without this, a resolver would see the unrelocated initialiser bytes that were placed into the slot by the early _dl_allocate_tls_init. */ - ELF_DYNAMIC_RELOCATE_NOIFUNC (l, scope, lazy, consider_profiling); + ELF_DYNAMIC_RELOCATE_PASS (DL_RELOC_NORMAL, l, scope, lazy, + consider_profiling, skip_ifunc); #ifdef SHARED /* Re-initialise the static TLS slot with the .tdata so the IRELATIVE @@ -291,7 +292,8 @@ _dl_relocate_object_no_relro (struct link_map *l, struct r_scope_elem *scope[], _dl_init_static_tls (l); #endif - ELF_DYNAMIC_RELOCATE_IFUNC (l, scope, lazy, skip_ifunc); + ELF_DYNAMIC_RELOCATE_PASS (DL_RELOC_IRELATIVE, l, scope, lazy, + 0, skip_ifunc); if ((consider_profiling || consider_symbind) && l->l_info[DT_PLTRELSZ] != NULL) diff --git a/elf/do-rel.h b/elf/do-rel.h index 7702244734..c610d12dbe 100644 --- a/elf/do-rel.h +++ b/elf/do-rel.h @@ -79,17 +79,23 @@ elf_dynamic_Rel_audit_symbind (struct link_map *map, /* Perform the relocations in MAP on the running program image as specified by RELTAG, SZTAG. If LAZY is nonzero, this is the first pass on PLT relocations; they should be set up to call _dl_runtime_resolve, rather - than fully resolved now. + than fully resolved now. If SKIP_IFUNC is nonzero no IFUNC resolver is + called; this is required for the trace modes (ldd -u / ldd -r), which + relocate objects. - IRELATIVE entries are always skipped (non-bootstrap); they are handled + IRELATIVE entries and relocations against an STT_GNU_IFUNC symbol defined + in MAP itself are always skipped (non-bootstrap); they are handled separately by elf_dynamic_do_Rel_irelative after all other relocations - for both .rel.dyn and .rel.plt have been processed. */ + for both .rel.dyn and .rel.plt have been processed. Relocations against + an IFUNC symbol defined in *another* object are not deferred, since the + IFUNC symbol is only known after symbol resolution, and the defining object + has already been relocated at this point. */ static inline void __attribute__ ((always_inline)) elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[], ElfW(Addr) reladdr, ElfW(Addr) relsize, __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative, - int lazy) + int lazy, int skip_ifunc) { const ElfW(Rel) *relative = (const void *) reladdr; const ElfW(Rel) *r = relative + nrelative; @@ -111,7 +117,7 @@ elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[], void *const r_addr_arg = (void *) (l_addr + r->r_offset); const struct r_found_version *rversion = &map->l_versions[ndx]; - elf_machine_rel (map, scope, r, sym, rversion, r_addr_arg, 0); + elf_machine_rel (map, scope, r, sym, rversion, r_addr_arg, skip_ifunc); } #else /* !RTLD_BOOTSTRAP */ #if !defined DO_RELA || !defined ELF_MACHINE_PLT_REL @@ -126,7 +132,7 @@ elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[], const ElfW (Sym) *sym = &symtab[ELFW (R_SYM) (r->r_info)]; if (elf_dynamic_is_Rel_irelative (r, sym)) continue; - elf_machine_lazy_rel (map, scope, l_addr, r, 0); + elf_machine_lazy_rel (map, scope, l_addr, r, skip_ifunc); } } else @@ -158,7 +164,8 @@ elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[], if (elf_dynamic_is_Rel_irelative (r, sym)) continue; - elf_machine_rel (map, scope, r, sym, rversion, r_addr_arg, 0); + elf_machine_rel (map, scope, r, sym, rversion, r_addr_arg, + skip_ifunc); elf_dynamic_Rel_audit_symbind (map, scope, r, sym, rversion, r_addr_arg); } @@ -172,7 +179,8 @@ elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[], if (elf_dynamic_is_Rel_irelative (r, sym)) continue; - elf_machine_rel (map, scope, r, sym, NULL, r_addr_arg, 0); + elf_machine_rel (map, scope, r, sym, NULL, r_addr_arg, + skip_ifunc); elf_dynamic_Rel_audit_symbind (map, scope, r, sym, NULL, r_addr_arg); } diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h index 35141acec4..0130c63feb 100644 --- a/elf/dynamic-link.h +++ b/elf/dynamic-link.h @@ -78,18 +78,23 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[], consumes precisely the very end of the DT_REL*, or DT_JMPREL and DT_REL* are completely separate and there is a gap between them. */ -/* This controls which sub-passes _ELF_DYNAMIC_DO_RELOC runs. Used to - interleave TLS / stack-protector setup between the two passes so IFUNC - resolvers see a fully-initialised TCB. */ -enum elf_dynamic_reloc_phase +/* Selects which relocations a pass processes. Splitting them allows the + caller to interleave TLS / stack-protector setup between the two passes, + so IFUNC resolvers see a fully-initialised TCB. + + This is orthogonal to the skip_ifunc argument, which says whether an IFUNC + resolver may be run at all and is honoured by every pass. In particular + DL_RELOC_NORMAL also runs IFUNC resolvers, for relocations against an + IFUNC symbol defined in another object. */ +enum elf_dynamic_reloc_pass { - DL_RELOC_BOTH = 0, /* Non-IRELATIVE pass then IRELATIVE pass. */ - DL_RELOC_NOIFUNC = 1, /* Non-IRELATIVE pass only. */ - DL_RELOC_IFUNC = 2, /* IRELATIVE pass only. */ + DL_RELOC_ALL = 0, /* Non-IRELATIVE relocations, then IRELATIVE. */ + DL_RELOC_NORMAL = 1, /* Non-IRELATIVE relocations only. */ + DL_RELOC_IRELATIVE = 2, /* IRELATIVE relocations only. */ }; # define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, scope, do_lazy, skip_ifunc, \ - test_rel, phase) \ + test_rel, pass) \ do { \ struct { ElfW(Addr) start, size; \ __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative; int lazy; } \ @@ -136,14 +141,15 @@ enum elf_dynamic_reloc_phase by the linker. */ \ if (!DO_RTLD_BOOTSTRAP) \ { \ - if ((phase) != DL_RELOC_IFUNC) \ + if ((pass) != DL_RELOC_IRELATIVE) \ for (int ranges_index = 0; ranges_index < 2; ++ranges_index) \ elf_dynamic_do_##reloc ((map), scope, \ ranges[ranges_index].start, \ ranges[ranges_index].size, \ ranges[ranges_index].nrelative, \ - ranges[ranges_index].lazy); \ - if ((phase) != DL_RELOC_NOIFUNC) \ + ranges[ranges_index].lazy, \ + skip_ifunc); \ + if ((pass) != DL_RELOC_NORMAL) \ for (int ranges_index = 0; ranges_index < 2; ++ranges_index) \ elf_dynamic_do_##reloc##_irelative ((map), scope, \ ranges[ranges_index].start, \ @@ -158,7 +164,8 @@ enum elf_dynamic_reloc_phase ranges[ranges_index].start, \ ranges[ranges_index].size, \ ranges[ranges_index].nrelative, \ - ranges[ranges_index].lazy); \ + ranges[ranges_index].lazy, \ + skip_ifunc); \ } while (0) # if ELF_MACHINE_NO_REL || ELF_MACHINE_NO_RELA @@ -169,37 +176,21 @@ enum elf_dynamic_reloc_phase # if ! ELF_MACHINE_NO_REL # include "do-rel.h" -# define ELF_DYNAMIC_DO_REL(map, scope, lazy, skip_ifunc) \ - _ELF_DYNAMIC_DO_RELOC (REL, Rel, map, scope, lazy, skip_ifunc, \ - _ELF_CHECK_REL, DL_RELOC_BOTH) -# define ELF_DYNAMIC_DO_REL_NOIFUNC(map, scope, lazy) \ - _ELF_DYNAMIC_DO_RELOC (REL, Rel, map, scope, lazy, 0, \ - _ELF_CHECK_REL, DL_RELOC_NOIFUNC) -# define ELF_DYNAMIC_DO_REL_IFUNCONLY(map, scope, lazy, skip_ifunc) \ +# define ELF_DYNAMIC_DO_REL(map, scope, lazy, skip_ifunc, pass) \ _ELF_DYNAMIC_DO_RELOC (REL, Rel, map, scope, lazy, skip_ifunc, \ - _ELF_CHECK_REL, DL_RELOC_IFUNC) + _ELF_CHECK_REL, pass) # else -# define ELF_DYNAMIC_DO_REL(map, scope, lazy, skip_ifunc) /* Nothing to do. */ -# define ELF_DYNAMIC_DO_REL_NOIFUNC(map, scope, lazy) /* Nothing to do. */ -# define ELF_DYNAMIC_DO_REL_IFUNCONLY(map, scope, lazy, skip_ifunc) /* Nothing. */ +# define ELF_DYNAMIC_DO_REL(map, scope, lazy, skip_ifunc, pass) /* Nothing. */ # endif # if ! ELF_MACHINE_NO_RELA # define DO_RELA # include "do-rel.h" -# define ELF_DYNAMIC_DO_RELA(map, scope, lazy, skip_ifunc) \ - _ELF_DYNAMIC_DO_RELOC (RELA, Rela, map, scope, lazy, skip_ifunc, \ - _ELF_CHECK_REL, DL_RELOC_BOTH) -# define ELF_DYNAMIC_DO_RELA_NOIFUNC(map, scope, lazy) \ - _ELF_DYNAMIC_DO_RELOC (RELA, Rela, map, scope, lazy, 0, \ - _ELF_CHECK_REL, DL_RELOC_NOIFUNC) -# define ELF_DYNAMIC_DO_RELA_IFUNCONLY(map, scope, lazy, skip_ifunc) \ +# define ELF_DYNAMIC_DO_RELA(map, scope, lazy, skip_ifunc, pass) \ _ELF_DYNAMIC_DO_RELOC (RELA, Rela, map, scope, lazy, skip_ifunc, \ - _ELF_CHECK_REL, DL_RELOC_IFUNC) + _ELF_CHECK_REL, pass) # else -# define ELF_DYNAMIC_DO_RELA(map, scope, lazy, skip_ifunc) /* Nothing to do. */ -# define ELF_DYNAMIC_DO_RELA_NOIFUNC(map, scope, lazy) /* Nothing to do. */ -# define ELF_DYNAMIC_DO_RELA_IFUNCONLY(map, scope, lazy, skip_ifunc) /* Nothing. */ +# define ELF_DYNAMIC_DO_RELA(map, scope, lazy, skip_ifunc, pass) /* Nothing. */ # endif # define ELF_DYNAMIC_DO_RELR(map) \ @@ -240,37 +231,33 @@ enum elf_dynamic_reloc_phase # else # define DO_RTLD_BOOTSTRAP 0 # endif -# define ELF_DYNAMIC_RELOCATE(map, scope, lazy, consider_profile, skip_ifunc) \ - do { \ - int edr_lazy = elf_machine_runtime_setup ((map), (scope), (lazy), \ - (consider_profile)); \ - if (!is_rtld_link_map (map) || DO_RTLD_BOOTSTRAP) \ - ELF_DYNAMIC_DO_RELR (map); \ - ELF_DYNAMIC_DO_REL ((map), (scope), edr_lazy, skip_ifunc); \ - ELF_DYNAMIC_DO_RELA ((map), (scope), edr_lazy, skip_ifunc); \ - ELF_DYNAMIC_AFTER_RELOC ((map), (edr_lazy)); \ - } while (0) +/* Perform one relocation pass over MAP. PASS selects which relocations are + processed. It is orthogonal to SKIP_IFUNC, which suppresses running IFUNC + resolvers in whichever pass is selected. -/* Like ELF_DYNAMIC_RELOCATE but only processes the non-IRELATIVE pass. - The IRELATIVE pass must be completed later via ELF_DYNAMIC_RELOCATE_IFUNC. - Used by the static-pie startup so the TCB and stack-protector canary can - be initialised between the two passes. */ -# define ELF_DYNAMIC_RELOCATE_NOIFUNC(map, scope, lazy, consider_profile) \ + Unless PASS is DL_RELOC_IRELATIVE, this also performs the machine-specific + PLT/GOT setup, the DT_RELR relocations, and the ELF_DYNAMIC_AFTER_RELOC + hook. */ +# define ELF_DYNAMIC_RELOCATE_PASS(pass, map, scope, lazy, consider_profile, \ + skip_ifunc) \ do { \ - int edr_lazy = elf_machine_runtime_setup ((map), (scope), (lazy), \ + int edr_lazy = (lazy); \ + if ((pass) != DL_RELOC_IRELATIVE) \ + { \ + edr_lazy = elf_machine_runtime_setup ((map), (scope), (lazy), \ (consider_profile)); \ - if (!is_rtld_link_map (map) || DO_RTLD_BOOTSTRAP) \ - ELF_DYNAMIC_DO_RELR (map); \ - ELF_DYNAMIC_DO_REL_NOIFUNC ((map), (scope), edr_lazy); \ - ELF_DYNAMIC_DO_RELA_NOIFUNC ((map), (scope), edr_lazy); \ - ELF_DYNAMIC_AFTER_RELOC ((map), (edr_lazy)); \ + if (!is_rtld_link_map (map) || DO_RTLD_BOOTSTRAP) \ + ELF_DYNAMIC_DO_RELR (map); \ + } \ + ELF_DYNAMIC_DO_REL ((map), (scope), edr_lazy, skip_ifunc, (pass)); \ + ELF_DYNAMIC_DO_RELA ((map), (scope), edr_lazy, skip_ifunc, (pass)); \ + if ((pass) != DL_RELOC_IRELATIVE) \ + ELF_DYNAMIC_AFTER_RELOC ((map), edr_lazy); \ } while (0) -/* IRELATIVE-only companion to ELF_DYNAMIC_RELOCATE_NOIFUNC. */ -# define ELF_DYNAMIC_RELOCATE_IFUNC(map, scope, lazy, skip_ifunc) \ - do { \ - ELF_DYNAMIC_DO_REL_IFUNCONLY ((map), (scope), (lazy), skip_ifunc); \ - ELF_DYNAMIC_DO_RELA_IFUNCONLY ((map), (scope), (lazy), skip_ifunc); \ - } while (0) +/* Run both passes back to back, for callers with nothing to interleave. */ +# define ELF_DYNAMIC_RELOCATE(map, scope, lazy, consider_profile, skip_ifunc) \ + ELF_DYNAMIC_RELOCATE_PASS (DL_RELOC_ALL, (map), (scope), (lazy), \ + (consider_profile), skip_ifunc) #endif diff --git a/elf/libtst-origin-secure-mod.c b/elf/libtst-origin-secure-mod.c new file mode 100644 index 0000000000..8d7f372094 --- /dev/null +++ b/elf/libtst-origin-secure-mod.c @@ -0,0 +1,25 @@ +/* Module for tst-origin-secure (the "good" copy). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-origin-secure.h" + +int +origin_secure_id (void) +{ + return ORIGIN_SECURE_ID_TRUSTED; +} diff --git a/elf/tst-dl-cache-old-format.c b/elf/tst-dl-cache-old-format.c new file mode 100644 index 0000000000..985aed99ec --- /dev/null +++ b/elf/tst-dl-cache-old-format.c @@ -0,0 +1,144 @@ +/* Test that ld.so accepts an ld.so.cache written in the old format. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* A cache written by "ldconfig -c old" carries no new-format header, so + the loader must not look for cache extensions in it. The test writes + such a cache, then starts a dynamically linked child, which is where + an unpatched loader dies before main, and then dlopens a module that + is only reachable through the cache, which covers the reload path. */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +/* ldconfig only indexes file names starting with "lib", so the module is + deployed under a lib-prefixed name and dlopened by that name. */ +#define MOD_BUILT "tst-dl-path-buf-mod.so" +#define MOD_DEPLOYED "libtst-dl-path-buf-mod.so" +#define MOD_SYMBOL "tst_dl_path_buf_mod_value" +#define MOD_EXPECTED 0xaabbccddu + +#define MOD_DIR "/tst-dl-cache-old-format" + +/* Copied from sysdeps/generic/dl-cache.h, which cannot be included here + because it relies on libc-internal attributes. */ +#define CACHE_MAGIC_OLD "ld.so-1.7.0" +#define CACHE_MAGIC_NEW "glibc-ld.so.cache1.1" + +/* Set in the re-executed child, whose only job is to reach main. */ +static int restart; +#define CMDLINE_OPTIONS \ + { "restart", no_argument, &restart, 1 }, + +static void +run_ldconfig (void *closure __attribute__ ((unused))) +{ + char *prog = xasprintf ("%s/ldconfig", support_install_rootsbindir); + char *args[] = { prog, (char *) "-c", (char *) "old", NULL }; + execv (args[0], args); + FAIL_EXIT1 ("execv (%s): %m", prog); +} + +/* ldconfig accepts an unknown -c argument without complaining and falls + back to the new format, so verify that the cache on disk really is the + old format and carries no new-format header anywhere. */ +static void +check_cache_is_old_format (void) +{ + char *path = xasprintf ("%s/ld.so.cache", support_sysconfdir_prefix); + int fd = xopen (path, O_RDONLY, 0); + struct stat64 st; + xfstat64 (fd, &st); + size_t length = st.st_size; + char *contents = xmalloc (length); + xread (fd, contents, length); + xclose (fd); + + TEST_COMPARE_BLOB (contents, sizeof CACHE_MAGIC_OLD - 1, + CACHE_MAGIC_OLD, sizeof CACHE_MAGIC_OLD - 1); + TEST_VERIFY (memmem (contents, length, CACHE_MAGIC_NEW, + sizeof CACHE_MAGIC_NEW - 1) == NULL); + + free (contents); + free (path); +} + +static void +do_prepare (int argc, char **argv) +{ + if (restart) + return; + + xmkdirp (MOD_DIR, 0777); + add_temp_file (MOD_DIR); + char *src = xasprintf ("%s/elf/" MOD_BUILT, support_objdir_root); + support_copy_file (src, MOD_DIR "/" MOD_DEPLOYED); + add_temp_file (MOD_DIR "/" MOD_DEPLOYED); + free (src); + + char *conf = xasprintf ("%s/ld.so.conf", support_sysconfdir_prefix); + support_write_file_string (conf, MOD_DIR "\n"); + free (conf); + + xmkdirp ("/var/cache/ldconfig", 0777); + struct support_capture_subprocess result + = support_capture_subprocess (run_ldconfig, NULL); + support_capture_subprocess_check (&result, "ldconfig", 0, sc_allow_none); + support_capture_subprocess_free (&result); + + check_cache_is_old_format (); +} +#define PREPARE do_prepare + +static int +do_test (int argc, char **argv) +{ + if (restart) + /* Reaching main is the entire check: the loader read the old-format + cache while starting this process. */ + return 0; + + char *spargv[] = { argv[0], (char *) "--direct", (char *) "--restart", + NULL }; + struct support_capture_subprocess result + = support_capture_subprogram (spargv[0], spargv, NULL); + support_capture_subprocess_check (&result, "restart", 0, sc_allow_none); + support_capture_subprocess_free (&result); + + /* This process still has the cache from its own startup mapped, so the + dlopen exercises the reload of the replaced file as well. */ + void *handle = xdlopen (MOD_DEPLOYED, RTLD_NOW | RTLD_LOCAL); + unsigned int (*value) (void) = xdlsym (handle, MOD_SYMBOL); + TEST_COMPARE (value (), MOD_EXPECTED); + xdlclose (handle); + + return 0; +} + +#define TEST_FUNCTION_ARGV do_test +#include diff --git a/elf/tst-dl-cache-old-format.root/postclean.req b/elf/tst-dl-cache-old-format.root/postclean.req new file mode 100644 index 0000000000..e69de29bb2 diff --git a/elf/tst-dl-path-normalize.c b/elf/tst-dl-path-normalize.c new file mode 100644 index 0000000000..f6d45d654f --- /dev/null +++ b/elf/tst-dl-path-normalize.c @@ -0,0 +1,142 @@ +/* Unit tests for dl-path-normalize.h. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include + +static void +check_one_guarded (const char *input, const char *expected, bool before) +{ + size_t size = strlen (input) + 1; + struct support_next_to_fault ntf + = before ? support_next_to_fault_allocate_before (size) + : support_next_to_fault_allocate (size); + memcpy (ntf.buffer, input, size); + + size_t len = _dl_normalize_path (ntf.buffer); + + TEST_COMPARE (len, strlen (ntf.buffer)); + TEST_COMPARE_STRING (ntf.buffer, expected); + + support_next_to_fault_free (&ntf); +} + +static void +check_one (const char *input, const char *expected) +{ + /* Check that _dl_normalize_path does not access the string outside the + input argument. It checks for both over-runs and under-runs (the + latter for the case of '..' expansions). */ + check_one_guarded (input, expected, false); + check_one_guarded (input, expected, true); +} + +static int +do_test (void) +{ + /* Absolute paths. */ + check_one ("/", "/"); + check_one ("//", "/"); + check_one ("///", "/"); + check_one ("////", "/"); + check_one ("/a", "/a"); + check_one ("/a/", "/a"); + check_one ("/a//", "/a"); + check_one ("//a//b//", "/a/b"); + check_one ("/.", "/"); + check_one ("/./", "/"); + check_one ("/./a", "/a"); + check_one ("/a/./b", "/a/b"); + check_one ("/a/.", "/a"); + check_one ("/..", "/"); + check_one ("/../", "/"); + check_one ("/../a", "/a"); + check_one ("/a/..", "/"); + check_one ("/a/../", "/"); + check_one ("/a/../..", "/"); + check_one ("/a/../b", "/b"); + check_one ("/a/../../b", "/b"); + check_one ("/a/b/../../c", "/c"); + check_one ("/a/b/../c", "/a/c"); + check_one ("/a/b/c/../..", "/a"); + check_one ("/usr/lib/../lib64", "/usr/lib64"); + check_one ("/usr/lib/../lib64/", "/usr/lib64"); + check_one ("/usr/lib/..//lib64/", "/usr/lib64"); + check_one ("/usr/lib/../../lib64/", "/lib64"); + + /* "." and ".." are special only as complete components. */ + check_one ("/a..", "/a.."); + check_one ("/..a", "/..a"); + check_one ("/a/...", "/a/..."); + check_one ("/.../a", "/.../a"); + check_one ("/a./b", "/a./b"); + check_one (".a", ".a"); + check_one ("a.", "a."); + check_one ("..a", "..a"); + check_one ("...", "..."); + + /* Relative paths. */ + check_one ("", ""); + check_one (".", ""); + check_one ("./", ""); + check_one ("..", ".."); + check_one ("../", ".."); + check_one ("a", "a"); + check_one ("a/", "a"); + check_one ("a//b", "a/b"); + check_one ("a..", "a.."); + check_one ("./a", "a"); + check_one ("./.", ""); + check_one ("./..", ".."); + + check_one ("a/..", ""); + check_one ("a/../", ""); + check_one ("ab/..", ""); + check_one (".a/..", ""); + check_one ("a./..", ""); + check_one (".../..", ""); + check_one ("a/./..", ""); + check_one ("a/b/..", "a"); + check_one ("abc/def/..", "abc"); + + /* Appending a component to an emptied relative output must not produce a + leading '/' (the path must stay relative). */ + check_one ("a/../b", "b"); + check_one ("a/.././b", "b"); + check_one ("a/../lib64/b", "lib64/b"); + + /* Leading ".." components of a relative path are preserved and stack + instead of cancelling each other; ordinary components may follow and be + removed again afterwards. */ + check_one ("../a", "../a"); + check_one ("../..", "../.."); + check_one ("../../..", "../../.."); + check_one ("../../a", "../../a"); + check_one ("../a/..", ".."); + check_one ("../../a/..", "../.."); + check_one ("a/../../b", "../b"); + check_one ("a/b/../../..", ".."); + + return 0; +} + +#include diff --git a/elf/tst-ifunc-fault-dep-bindnow.c b/elf/tst-ifunc-fault-dep-bindnow.c new file mode 100644 index 0000000000..60d97dcaa4 --- /dev/null +++ b/elf/tst-ifunc-fault-dep-bindnow.c @@ -0,0 +1,19 @@ +/* Program calling an IFUNC defined in a dependency. BIND_NOW variant. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-ifunc-fault-dep-lazy.c" diff --git a/elf/tst-ifunc-fault-dep-lazy.c b/elf/tst-ifunc-fault-dep-lazy.c new file mode 100644 index 0000000000..122d33f391 --- /dev/null +++ b/elf/tst-ifunc-fault-dep-lazy.c @@ -0,0 +1,27 @@ +/* Program calling an IFUNC defined in a dependency (BZ 34428). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +extern void magic (void); + +int +main (void) +{ + /* JMP_SLOT relocation against an undefined symbol. */ + magic (); + return 1; +} diff --git a/elf/tst-ifunc-fault-mod.c b/elf/tst-ifunc-fault-mod.c new file mode 100644 index 0000000000..11c21b48ac --- /dev/null +++ b/elf/tst-ifunc-fault-mod.c @@ -0,0 +1,38 @@ +/* Shared object exporting an IFUNC symbol with a resolver which crashes. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +static void +implementation (void) +{ + /* Produce a crash, without depending on any relocations. */ + volatile char *volatile p = NULL; + *p = 0; +} + +static __typeof__ (implementation) * +resolver (void) +{ + /* Produce a crash, without depending on any relocations. */ + volatile char *volatile p = NULL; + *p = 0; + return implementation; +} + +void magic (void) __attribute__ ((ifunc ("resolver"))); diff --git a/elf/tst-ldconfig-cache.c b/elf/tst-ldconfig-cache.c index 9f71418b3a..f4820a1822 100644 --- a/elf/tst-ldconfig-cache.c +++ b/elf/tst-ldconfig-cache.c @@ -85,7 +85,10 @@ corrupt (void) static void ldconfig (void) { - xsystem ("/sbin/ldconfig -X"); + char *cmd = xasprintf("%s/ldconfig -X", support_install_rootsbindir); + xsystem (cmd); + + free(cmd); } /* Change ld.so.conf to refer to the new directory, and generate a new diff --git a/elf/tst-origin-secure-evilmod.c b/elf/tst-origin-secure-evilmod.c new file mode 100644 index 0000000000..0913e32e21 --- /dev/null +++ b/elf/tst-origin-secure-evilmod.c @@ -0,0 +1,28 @@ +/* Module for tst-origin-secure (the attacker-controlled copy). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-origin-secure.h" + +/* If the victim reports this copy, the loader opened the un-normalized rpath + and resolved it through the attacker's symlink -- i.e. the trusted-path + check was bypassed (bug 34360). */ +int +origin_secure_id (void) +{ + return ORIGIN_SECURE_ID_ATTACKER; +} diff --git a/elf/tst-origin-secure-victim.c b/elf/tst-origin-secure-victim.c new file mode 100644 index 0000000000..601265aaa4 --- /dev/null +++ b/elf/tst-origin-secure-victim.c @@ -0,0 +1,43 @@ +/* Victim program for tst-origin-secure. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-origin-secure.h" + +extern int __libc_enable_secure; + +/* Report both which module was loaded and whether the loader ran in secure + mode, so the driver can tell a genuine trusted-path bypass apart from a run + that simply was not secure. + + The exit status is the combination of the ORIGIN_SECURE_STATUS_* bits: + + _NONE trusted copy, not secure + _ATTACKER attacker copy, not secure (the control run) + _SECURE trusted copy, secure (a fixed loader) + _SECURE | _ATTACKER attacker copy, secure (the bug: the raw + rpath was opened) */ +int +main (void) +{ + int status = ORIGIN_SECURE_STATUS_NONE; + if (origin_secure_id () == ORIGIN_SECURE_ID_ATTACKER) + status |= ORIGIN_SECURE_STATUS_ATTACKER; + if (__libc_enable_secure != 0) + status |= ORIGIN_SECURE_STATUS_SECURE; + return status; +} diff --git a/elf/tst-origin-secure.c b/elf/tst-origin-secure.c new file mode 100644 index 0000000000..f304823b49 --- /dev/null +++ b/elf/tst-origin-secure.c @@ -0,0 +1,203 @@ +/* Test that AT_SECURE $ORIGIN rpath entries are looked up using the + normalized (trusted) path, not the raw expansion (bug 34360). + + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + + +/* For a SUID/SGID program the loader only honors $ORIGIN in DT_RPATH when + the normalized expansion is rooted in a trusted directory. If the loader + opens the un-normalized string (that contains "../"), it might disagree + as soon as a path component is a symbolic link. + + This test builds the executable with the rpath: + + $ORIGIN/sub/../../../../..SLIBDIR/tst-origin-secure + + and runs it as BASE/a/b/victim, so $ORIGIN is BASE/a/b. Lexically the + five "../" pop $ORIGIN/sub back to "/" (BASE is /tmp/tst-origin-secure, + so $ORIGIN/sub is the five components tmp, tst-origin-secure, a, b, sub), + and the entry normalizes to the trusted SLIBDIR/tst-origin-secure. But + "sub" is a symlink pointing six levels deep under BASE, so opening the raw + string makes the kernel resolve the "../" through the symlink and land in + BASE/x1 SLIBDIR/tst-origin-secure instead. + + The "../" count in the rpath (see the Makefile) is therefore + depth(BASE) + 2 (for the "a/b" of $ORIGIN) + 1 (for "sub"); it is + independent of SLIBDIR, which is appended whole on both the raw and the + normalized side. + + A trusted copy of the module (ORIGIN_SECURE_ID_TRUSTED) is installed in + SLIBDIR/tst-origin-secure; an attacker copy (ORIGIN_SECURE_ID_ATTACKER) is + placed at the symlink-diverted location. The trusted subdirectory is + rooted under SLIBDIR (so it passes the trusted-path check) but is not + itself a default loader search directory. + + The victim reports, in its exit status, both which module it loaded and + whether it ran in secure mode. + + Secure mode is forced with glibc.rtld.enable_secure=1 so that no real + SUID/SGID binary is required. */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include "tst-origin-secure.h" + +#define BASE "/tmp/tst-origin-secure" +#define SONAME "libtst-origin-secure-mod.so" +/* Subdirectory of the trusted SLIBDIR that the rpath normalizes to. It is + trusted (rooted under SLIBDIR) but not a default search directory. */ +#define SUBDIR "tst-origin-secure" + +static int +run_victim (char *const *envp) +{ + const char *victim = BASE "/a/b/victim"; + char *const argv[] = { (char *) victim, NULL }; + + struct support_capture_subprocess res + = support_capture_subprogram (victim, argv, envp); + /* The victim itself prints nothing; forward any loader diagnostics to + the test log. */ + if (res.err.length > 0) + printf ("info: victim stderr: %s\n", res.err.buffer); + int status = res.status; + support_capture_subprocess_free (&res); + return WIFEXITED (status) ? WEXITSTATUS (status) : -1; +} + +/* With SLIBDIR "/lib64" the container layout is: + + /lib64/tst-origin-secure/libtst-origin-secure-mod.so trusted copy (id 1) + BASE/a/b/victim the executable + BASE/a/b/sub -> BASE/x1/x2/x3/x4/x5/x6 six levels deep + BASE/x1/lib64/tst-origin-secure/libtst-origin-secure-mod.so + attacker copy (id 2) + BASE/x1/x2/x3/x4/x5/x6/ the symlink target + + The victim's rpath is $ORIGIN/sub + five "../" + /lib64/tst-origin-secure. */ +static void +do_prepare (int argc, char **argv) +{ + const char *slibdir = support_slibdir_prefix; + const char *objelf = support_objdir_root; + + char *good_src = xasprintf ("%s/elf/libtst-origin-secure-mod.so", objelf); + char *evil_src = xasprintf ("%s/elf/tst-origin-secure-evilmod.so", objelf); + char *victim_src = xasprintf ("%s/elf/tst-origin-secure-victim", objelf); + + xmkdirp (BASE "/a/b", 0755); + xmkdirp (BASE "/x1/x2/x3/x4/x5/x6", 0755); + + /* Where the trusted copy lives (reached only via the normalized rpath, + SLIBDIR/SUBDIR) ... */ + char *good_dir = xasprintf ("%s/%s", slibdir, SUBDIR); + char *good_dst = xasprintf ("%s/%s", good_dir, SONAME); + xmkdirp (good_dir, 0755); + /* ... and where the raw, symlink-diverted lookup lands. */ + char *evil_dir = xasprintf ("%s/x1%s/%s", BASE, slibdir, SUBDIR); + char *evil_dst = xasprintf ("%s/%s", evil_dir, SONAME); + xmkdirp (evil_dir, 0755); + + /* support_copy_file preserves the source mode, so the victim stays + executable and the modules readable; no chmod is needed. */ + support_copy_file (good_src, good_dst); + support_copy_file (evil_src, evil_dst); + support_copy_file (victim_src, BASE "/a/b/victim"); + + unlink (BASE "/a/b/sub"); + xsymlink (BASE "/x1/x2/x3/x4/x5/x6", BASE "/a/b/sub"); + + free (good_src); + free (evil_src); + free (victim_src); + free (good_dir); + free (good_dst); + free (evil_dir); + free (evil_dst); +} +#define PREPARE do_prepare + +static int +do_test (void) +{ + /* Control run: in normal mode $ORIGIN is honored without the trusted check, + so the raw rpath resolves through "sub" and the attacker copy is + loaded. */ + { + char *const env[] = { NULL }; + int rc = run_victim (env); + if (rc != ORIGIN_SECURE_STATUS_ATTACKER) + FAIL_EXIT1 ("control run returned status %d, expected %d (attacker " + "copy, not secure): the $ORIGIN layout does not reproduce " + "the divergence between the raw and the normalized rpath", + rc, ORIGIN_SECURE_STATUS_ATTACKER); + } + + /* Secure run: force AT_SECURE. A fixed loader normalizes the rpath to the + trusted SLIBDIR/SUBDIR and loads the trusted copy; a loader with the bug + opens the raw path, resolves "sub", and loads the attacker copy. */ + { + char *const env[] = { (char *) "GLIBC_TUNABLES=glibc.rtld.enable_secure=1", + NULL }; + int rc = run_victim (env); + switch (rc) + { + /* Secure, trusted copy loaded via the normalized rpath: fixed. */ + case ORIGIN_SECURE_STATUS_SECURE: + break; + + /* Secure, attacker copy loaded: the raw rpath was opened. */ + case ORIGIN_SECURE_STATUS_SECURE | ORIGIN_SECURE_STATUS_ATTACKER: + FAIL_EXIT1 ("secure-mode loader resolved the un-normalized rpath " + "through the attacker symlink (bug 34360)"); + + /* Not secure, attacker copy: exactly what the control run produced, so + the tunable did not engage and this run says nothing about the + trusted-path handling. */ + case ORIGIN_SECURE_STATUS_ATTACKER: + FAIL_UNSUPPORTED ("glibc.rtld.enable_secure=1 did not enable " + "secure mode (victim status %d)", rc); + + /* Not secure, yet the trusted copy was loaded, which is reachable only + through the normalized rpath, and only a secure loader normalizes it. + Fail rather than report UNSUPPORTED. */ + case ORIGIN_SECURE_STATUS_NONE: + FAIL_EXIT1 ("secure run loaded the trusted copy but the victim " + "reports not being secure: __libc_enable_secure is no " + "longer a valid proxy for secure mode"); + + /* Neither copy loaded: since the trusted copy is reachable only through + the normalized rpath, this means the rpath entry was not honored at + all. */ + default: + FAIL_EXIT1 ("secure run did not load the module via the normalized " + "rpath (victim status %d)", rc); + } + } + + return 0; +} + +#include diff --git a/elf/tst-origin-secure.h b/elf/tst-origin-secure.h new file mode 100644 index 0000000000..2e2b944607 --- /dev/null +++ b/elf/tst-origin-secure.h @@ -0,0 +1,41 @@ +/* Definitions shared by the tst-origin-secure test, its victim and modules. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _TST_ORIGIN_SECURE_H +#define _TST_ORIGIN_SECURE_H 1 + +enum + { + ORIGIN_SECURE_ID_TRUSTED = 1, /* The copy installed in the trusted + SLIBDIR. */ + ORIGIN_SECURE_ID_ATTACKER = 2, /* The copy reachable only by resolving the + "sub" symlink. */ + }; + +extern int origin_secure_id (void); + +enum + { + ORIGIN_SECURE_STATUS_NONE = 0, + ORIGIN_SECURE_STATUS_ATTACKER = 1 << 0, /* The victim loaded attacker + rather than the trusted. */ + ORIGIN_SECURE_STATUS_SECURE = 1 << 1, /* The loader ran the victim in + secure mode. */ + }; + +#endif diff --git a/elf/tst-origin-secure.root/postclean.req b/elf/tst-origin-secure.root/postclean.req new file mode 100644 index 0000000000..e69de29bb2 diff --git a/iconvdata/Makefile b/iconvdata/Makefile index fbb0067302..ba2eec2b48 100644 --- a/iconvdata/Makefile +++ b/iconvdata/Makefile @@ -76,7 +76,8 @@ tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \ tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \ bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4 \ bug-iconv13 bug-iconv14 bug-iconv15 \ - tst-iconv-iso-2022-cn-ext tst-bug33980 + tst-iconv-iso-2022-cn-ext tst-bug33980 \ + tst-jisx0213-progress ifeq ($(have-thread-library),yes) tests += bug-iconv3 endif @@ -335,6 +336,8 @@ $(objpfx)tst-iconv-iso-2022-cn-ext.out: $(addprefix $(objpfx), $(gconv-modules)) $(addprefix $(objpfx),$(modules.so)) $(objpfx)tst-bug33980.out: $(addprefix $(objpfx), $(gconv-modules)) \ $(addprefix $(objpfx),$(modules.so)) +$(objpfx)tst-jisx0213-progress.out: \ + $(addprefix $(objpfx), $(gconv-modules)) $(addprefix $(objpfx),$(modules.so)) $(objpfx)iconv-test.out: run-iconv-test.sh \ $(addprefix $(objpfx), $(gconv-modules)) \ diff --git a/iconvdata/euc-jisx0213.c b/iconvdata/euc-jisx0213.c index 5572bbdb7b..61c22231e1 100644 --- a/iconvdata/euc-jisx0213.c +++ b/iconvdata/euc-jisx0213.c @@ -224,6 +224,9 @@ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ } \ + else \ + /* There was a pending character. Clear it. */ \ + *statep = 0; \ \ put32 (outptr, ch); \ outptr += 4; \ diff --git a/iconvdata/shift_jisx0213.c b/iconvdata/shift_jisx0213.c index 61c9c3ce6d..e9179f605e 100644 --- a/iconvdata/shift_jisx0213.c +++ b/iconvdata/shift_jisx0213.c @@ -226,6 +226,9 @@ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ } \ + else \ + /* There was a pending character. Clear it. */ \ + *statep = 0; \ \ put32 (outptr, ch); \ outptr += 4; \ diff --git a/iconvdata/tst-jisx0213-progress.c b/iconvdata/tst-jisx0213-progress.c new file mode 100644 index 0000000000..7b2073be1f --- /dev/null +++ b/iconvdata/tst-jisx0213-progress.c @@ -0,0 +1,124 @@ +/* Test JISX0213 combining character conversion progress (bug 34556, bug 34568). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Certain JISX0213 byte sequences map to a combining sequence, for + example U+304B (HIRAGANA LETTER KA) followed by U+309A (COMBINING + SEMI-VOICED SOUND MARK). When converting to internal encoding + (actually UTF-32) with a small output buffer, the first code point + is emitted and the second is queued in the converter state. This + test verifies that the queued code point is consumed exactly once + on retry, so that the conversion makes progress and terminates. */ + +#include +#include +#include +#include + +#include +#include + +static void +test_one (const char *charset, const char *input, size_t outbufsize) +{ + printf ("info: %s: testing output buffer size %zu\n", charset, outbufsize); + + /* Expected UTF-32 output. */ + static const wchar_t expected[] = { 0x304b, 0x309a, 'A' }; + + /* Use WCHAR_T encoding to avoid the BOM. */ + iconv_t cd = iconv_open ("WCHAR_T", charset); + TEST_VERIFY_EXIT (cd != (iconv_t) -1); + + char result[64]; + size_t result_len = 0; + + char *inptr = (char *) input; + size_t inleft = strlen (input); + + char outbuf[64]; + + int iterations = 0; + while (inleft > 0) + { + char *outptr = outbuf; + size_t outleft = outbufsize; + size_t inleft_before = inleft; + + size_t ret = iconv (cd, &inptr, &inleft, &outptr, &outleft); + size_t produced = outptr - outbuf; + + TEST_VERIFY_EXIT (result_len + produced <= sizeof (result)); + memcpy (result + result_len, outbuf, produced); + result_len += produced; + + if (ret == (size_t) -1 && errno == E2BIG) + { + if (produced == 0 && inleft == inleft_before) + { + /* Output buffer too small for a single code point. */ + TEST_VERIFY_EXIT (outbufsize < 4); + break; + } + /* Bound iterations to detect non-progress bugs. */ + if (++iterations < 10) + continue; + else + { + FAIL ("%s: no progress", charset); + goto out; + } + } + if (ret == (size_t) -1) + FAIL_EXIT1 ("outbufsize %zu: iconv: %m", outbufsize); + break; + } + + /* Flush pending converter state. */ + { + char *outptr = outbuf; + size_t outleft = outbufsize; + size_t ret = iconv (cd, NULL, NULL, &outptr, &outleft); + TEST_VERIFY (ret == 0); + size_t produced = outptr - outbuf; + memcpy (result + result_len, outbuf, produced); + result_len += produced; + } + + if (outbufsize >= 4) + { + TEST_COMPARE (inleft, 0); + TEST_COMPARE_BLOB (result, result_len, + expected, sizeof (expected)); + } + + out: + TEST_VERIFY_EXIT (iconv_close (cd) == 0); +} + +static int +do_test (void) +{ + for (size_t outbufsize = 1; outbufsize <= 16; outbufsize++) + { + test_one ("EUC-JISX0213", "\244\367A", outbufsize); + test_one ("SHIFT_JISX0213", "\202\365A", outbufsize); + } + return 0; +} + +#include diff --git a/include/fcntl.h b/include/fcntl.h index be435047bc..86890a5b3d 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -20,11 +20,9 @@ extern int __fcntl (int __fd, int __cmd, ...); libc_hidden_proto (__fcntl) extern int __fcntl64 (int __fd, int __cmd, ...) attribute_hidden; libc_hidden_proto (__fcntl64) -extern int __openat (int __fd, const char *__file, int __oflag, ...) - __nonnull ((2)); +extern int __openat (int __fd, const char *__file, int __oflag, ...); libc_hidden_proto (__openat) -extern int __openat64 (int __fd, const char *__file, int __oflag, ...) - __nonnull ((2)); +extern int __openat64 (int __fd, const char *__file, int __oflag, ...); libc_hidden_proto (__openat64) extern int __open_2 (const char *__path, int __oflag); diff --git a/io/Makefile b/io/Makefile index 2a5b4dcb65..f80e8b8358 100644 --- a/io/Makefile +++ b/io/Makefile @@ -198,6 +198,10 @@ tests := \ tst-fstatat \ tst-fts \ tst-fts-bz22944 \ + tst-fts-bz34782 \ + tst-fts-bz34782-root \ + tst-fts-cwdfd-follow \ + tst-fts-follow \ tst-fts-lfs \ tst-fts-newflags \ tst-ftw-bz26353 \ diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h index f076cc3367..074c16b204 100644 --- a/io/bits/fcntl2.h +++ b/io/bits/fcntl2.h @@ -135,18 +135,14 @@ open64 (__fortify_clang_overload_arg (const char *, ,__path), int __oflag, #ifdef __USE_ATFILE # ifndef __USE_FILE_OFFSET64 -extern int __openat_2 (int __fd, const char *__path, int __oflag) - __nonnull ((2)); +extern int __openat_2 (int __fd, const char *__path, int __oflag); extern int __REDIRECT (__openat_alias, (int __fd, const char *__path, - int __oflag, ...), openat) - __nonnull ((2)); + int __oflag, ...), openat); # else extern int __REDIRECT (__openat_2, (int __fd, const char *__path, - int __oflag), __openat64_2) - __nonnull ((2)); + int __oflag), __openat64_2); extern int __REDIRECT (__openat_alias, (int __fd, const char *__path, - int __oflag, ...), openat64) - __nonnull ((2)); + int __oflag, ...), openat64); # endif # ifdef __va_arg_pack_len diff --git a/io/fcntl.h b/io/fcntl.h index d0ad4d6652..3d90cc9adb 100644 --- a/io/fcntl.h +++ b/io/fcntl.h @@ -230,19 +230,17 @@ extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1)); This function is a cancellation point and therefore not marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 -extern int openat (int __fd, const char *__file, int __oflag, ...) - __nonnull ((2)); +extern int openat (int __fd, const char *__file, int __oflag, ...); # else # ifdef __REDIRECT extern int __REDIRECT (openat, (int __fd, const char *__file, int __oflag, - ...), openat64) __nonnull ((2)); + ...), openat64); # else # define openat openat64 # endif # endif # ifdef __USE_LARGEFILE64 -extern int openat64 (int __fd, const char *__file, int __oflag, ...) - __nonnull ((2)); +extern int openat64 (int __fd, const char *__file, int __oflag, ...); # endif #endif diff --git a/io/fts-common.c b/io/fts-common.c index 3825f0aeb4..b3a75d2b90 100644 --- a/io/fts-common.c +++ b/io/fts-common.c @@ -66,6 +66,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #include #include #include +#include /* Support for the LFS API version. */ #ifndef FTS_OPEN @@ -302,6 +303,13 @@ static int fts_safe_changedir (FTSOBJ *, FTSENTRY *, int, const char *); ? (cwd_advance_fd ((sp), (fd), true), 0) \ : fchdir (fd))) +/* fts_read sets FTS_FOLLOWED, a private fts_flags bit defined with the + others in fts.h, on an entry that the application asked it to follow + with FTS_FOLLOW, even if it is not a symbolic link (an entry from the + fts_children list). Unlike FTS_SYMFOLLOW, it is also set with + FTS_NOCHDIR. Such a directory must be opened without O_NOFOLLOW, even + in a physical walk. */ + /* fts_build flags */ /* FIXME: make this an enum */ @@ -398,14 +406,15 @@ restore_initial_cwd (FTSOBJ *sp) /* Open the directory DIR if possible, and return a file descriptor. Return -1 and set errno on failure. It doesn't matter - whether the file descriptor has read or write access. */ + whether the file descriptor has read or write access. In a physical + walk, DIR is not followed if it is a symbolic link (unless FOLLOW). */ static int internal_function -diropen (FTSOBJ const *sp, char const *dir) +diropen (FTSOBJ const *sp, char const *dir, bool follow) { int open_flags = (O_SEARCH | O_CLOEXEC | O_DIRECTORY | O_NOCTTY | O_NONBLOCK - | (ISSET (FTS_PHYSICAL) ? O_NOFOLLOW : 0)); + | (ISSET (FTS_PHYSICAL) && !follow ? O_NOFOLLOW : 0)); int fd = (ISSET (FTS_CWDFD) ? openat (sp->fts_cwd_fd, dir, open_flags) @@ -600,7 +609,7 @@ FTS_OPEN (char * const *argv, * descriptor we run anyway, just more slowly. */ if (!ISSET(FTS_NOCHDIR) && !ISSET(FTS_CWDFD) - && (sp->fts_rfd = diropen (sp, ".")) < 0) + && (sp->fts_rfd = diropen (sp, ".", false)) < 0) SET(FTS_NOCHDIR); i_ring_init (&sp->fts_fd_ring, -1); @@ -935,8 +944,9 @@ FTS_READ (FTSOBJ *sp) if (instr == FTS_FOLLOW && (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { p->fts_info = fts_stat(sp, p, true); + p->fts_flags |= FTS_FOLLOWED; if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = diropen (sp, ".")) < 0) { + if ((p->fts_symfd = diropen (sp, ".", false)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -1061,8 +1071,10 @@ next: ; goto next; if (p->fts_instr == FTS_FOLLOW) { p->fts_info = fts_stat(sp, p, true); + p->fts_flags |= FTS_FOLLOWED; if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = diropen (sp, ".")) < 0) { + if ((p->fts_symfd + = diropen (sp, ".", false)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -1140,11 +1152,28 @@ cd_dot_dot: SET(FTS_STOP); } } else if (p->fts_flags & FTS_SYMFOLLOW) { - if (FCHDIR(sp, p->fts_symfd)) { - p->fts_errno = errno; - SET(FTS_STOP); + if (ISSET(FTS_CWDFD)) { + /* The descriptor pushed on the ring when changing + into P refers to the same directory as + fts_symfd, so discard it. It is not there if + the change failed, and the ring is empty if + deeper levels displaced it. */ + if (!(p->fts_flags & FTS_DONTCHDIR) + && ! i_ring_empty (&sp->fts_fd_ring)) { + int fd = i_ring_pop (&sp->fts_fd_ring); + if (0 <= fd) + close (fd); + } + /* fts_symfd becomes the virtual working directory, + so it must not be closed here. */ + cwd_advance_fd (sp, p->fts_symfd, false); + } else { + if (FCHDIR(sp, p->fts_symfd)) { + p->fts_errno = errno; + SET(FTS_STOP); + } + (void)close(p->fts_symfd); } - (void)close(p->fts_symfd); } else if (!(p->fts_flags & FTS_DONTCHDIR) && fts_safe_changedir(sp, p->fts_parent, -1, "..")) { p->fts_errno = errno; @@ -1235,7 +1264,7 @@ FTS_CHILDREN (FTSOBJ *sp, int instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - int fd = diropen (sp, "."); + int fd = diropen (sp, ".", false); if (fd < 0) return (sp->fts_child = NULL); sp->fts_child = fts_build(sp, instr); @@ -1316,6 +1345,7 @@ set_stat_type (struct STRUCT_STAT *st, unsigned int dtype) ? sp->fts_cwd_fd : AT_FDCWD), \ file, \ (((ISSET(FTS_PHYSICAL) \ + && ! (cur->fts_flags & FTS_FOLLOWED) \ && ! (ISSET(FTS_COMFOLLOW) \ && cur->fts_level == FTS_ROOTLEVEL)) \ ? O_NOFOLLOW : 0)), \ @@ -1559,14 +1589,15 @@ mem1: ; maxlen = sp->fts_pathlen - len; } - size_t new_len = len + d_namelen; - if (new_len < len) { + if (INT_ADD_WRAPV (len, d_namelen, &p->fts_pathlen)) { /* - * In the unlikely event that we would end up - * with a file name longer than SIZE_MAX, free up + * For !_LIBC In the unlikely event that we would end + * up with a file name longer than SIZE_MAX, free up * the current structure and the structures already * allocated, then error out with ENAMETOOLONG. - */ + * + * However, for _LIBC the FTSENT::fts_pathlen is an + * unsigned short, so it can wrap around here. */ free(FTSENT_WRAPPER(p)); fts_lfree(head); closedir_and_clear(FTSENT_DIRP(cur)); @@ -1577,7 +1608,6 @@ mem1: ; } p->fts_level = level; p->fts_parent = sp->fts_cur; - p->fts_pathlen = new_len; /* Store dirent.d_ino, in case we need to sort entries before processing them. */ @@ -1989,8 +2019,14 @@ fts_alloc (FTSOBJ *sp, const char *name, register size_t namelen) #else /* * For glibc, we use a wrapper struct to provide the extra required - * fields without changing the FSENT layout. + * fields without changing the FSENT layout. That layout also keeps + * fts_namelen and fts_pathlen as unsigned short, so reject a name + * that does not fit (only fts_open root arguments can be that long). */ + if (namelen > USHRT_MAX) { + __set_errno (ENAMETOOLONG); + return (NULL); + } len += sizeof (struct FTSENT_wrapper); struct FTSENT_wrapper *wrapper = malloc(len); if (wrapper == NULL) @@ -2044,18 +2080,15 @@ static bool internal_function fts_palloc (FTSOBJ *sp, size_t more) { - size_t new_len = sp->fts_pathlen + more + 256; - /* - * See if fts_pathlen would overflow. + * See if fts_pathlen, an int in an FTS, would overflow. */ - if (new_len < sp->fts_pathlen) { + if (INT_ADD_WRAPV (sp->fts_pathlen, more + 256, &sp->fts_pathlen)) { free(sp->fts_path); sp->fts_path = NULL; __set_errno (ENAMETOOLONG); return false; } - sp->fts_pathlen = new_len; char *p = realloc(sp->fts_path, sp->fts_pathlen); if (p == NULL) { free(sp->fts_path); @@ -2160,19 +2193,24 @@ fts_safe_changedir (FTSOBJ *sp, FTSENTRY *p, int fd, char const *dir) } } + /* P was reached through a symbolic link at the application's + request (FTS_FOLLOW), so it must be followed again here. */ + bool follow = ! is_dotdot && (p->fts_flags & FTS_FOLLOWED); + int newfd = fd; - if (fd < 0 && (newfd = diropen (sp, dir)) < 0) + if (fd < 0 && (newfd = diropen (sp, dir, follow)) < 0) return -1; /* The following dev/inode check is necessary if we're doing a "logical" traversal (through symlinks, a la chown -L), if the - system lacks O_NOFOLLOW support, or if we're changing to ".." + system lacks O_NOFOLLOW support, if we're following a symlink + at the application's request, or if we're changing to ".." (but not via a popped file descriptor). When changing to the name "..", O_NOFOLLOW can't help. In general, when the target is not "..", diropen's use of O_NOFOLLOW ensures we don't mistakenly follow a symlink, so we can avoid the expense of this fstat. */ int ret; - if (ISSET(FTS_LOGICAL) || ! HAVE_WORKING_O_NOFOLLOW + if (ISSET(FTS_LOGICAL) || ! HAVE_WORKING_O_NOFOLLOW || follow || (dir && streq (dir, ".."))) { struct STRUCT_STAT sb; diff --git a/io/fts.h b/io/fts.h index 50636e6c87..818eb6b3b2 100644 --- a/io/fts.h +++ b/io/fts.h @@ -258,6 +258,7 @@ typedef struct _ftsent { #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ +#define FTS_FOLLOWED 0x04 /* followed with fts_set FTS_FOLLOW */ unsigned short fts_flags; /* private flags for FTSENT structure */ #define FTS_AGAIN 1 /* read node again */ diff --git a/io/ftw.c b/io/ftw.c index ed0eeb3904..a9368a706e 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -18,7 +18,9 @@ #include -#ifndef __OFF_T_MATCHES_OFF64_T +#include + +#if !XSTAT_IS_XSTAT64 # include "ftw-common.c" versioned_symbol (libc, __new_nftw, nftw, GLIBC_2_3_3); diff --git a/io/ftw64.c b/io/ftw64.c index d3cd14c21a..fa7b05df22 100644 --- a/io/ftw64.c +++ b/io/ftw64.c @@ -31,6 +31,9 @@ #define ftw __rename_ftw #define nftw __rename_nftw +#include + +#include #include #include "ftw-common.c" @@ -44,7 +47,7 @@ versioned_symbol (libc, __new_nftw64, nftw64, GLIBC_2_3_3); compat_symbol (libc, __old_nftw64, nftw64, GLIBC_2_1); #endif -#ifdef __OFF_T_MATCHES_OFF64_T +#if XSTAT_IS_XSTAT64 weak_alias (__ftw64, ftw) versioned_symbol (libc, __new_nftw64, nftw, GLIBC_2_3_3); # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_3_3) diff --git a/io/sys/stat.h b/io/sys/stat.h index 3069e187b0..ff70b69f59 100644 --- a/io/sys/stat.h +++ b/io/sys/stat.h @@ -370,7 +370,7 @@ extern int fchmod (int __fd, __mode_t __mode) __THROW; the directory FD is open on. */ extern int fchmodat (int __fd, const char *__file, __mode_t __mode, int __flag) - __THROW __nonnull ((2)) __wur; + __THROW __wur; #endif /* Use ATFILE. */ diff --git a/io/tst-fts-bz22944.c b/io/tst-fts-bz22944.c index 7f86045234..2add7c0e29 100644 --- a/io/tst-fts-bz22944.c +++ b/io/tst-fts-bz22944.c @@ -18,14 +18,22 @@ #include #include +#include +#include #include +#include +#include #include +#include #include #include -#define BASENAME "tst-fts-bz22944." +#ifndef BASENAME +# define BASENAME "tst-fts-bz22944." +# define NESTED_DEPTH 150 +#endif -enum { nested_depth = 150 }; +enum { nested_depth = NESTED_DEPTH }; static const char dir_name[] = { [0 ... 254] = 'A', '\0' }; static void @@ -61,11 +69,32 @@ int do_test (void) { char *tempdir = support_create_temp_directory (BASENAME); + size_t tempdir_len = strlen (tempdir); + size_t level_len = 1 + strlen (dir_name); + + /* The fts_path of the deepest directory. The fts_path of a directory at + level N is its first TEMPDIR_LEN + N * LEVEL_LEN bytes. */ + size_t full_path_len = tempdir_len + level_len * nested_depth; + char *full_path = xmalloc (full_path_len + 1); + char *p = stpcpy (full_path, tempdir); + xchdir (tempdir); for (int i = 0; i < nested_depth; i++) { check_mkdir (dir_name); xchdir (dir_name); + *p++ = '/'; + p = stpcpy (p, dir_name); + } + + /* FTSENT::fts_pathlen is an unsigned short, so fts must stop with + ENAMETOOLONG instead of returning a path longer than USHRT_MAX. */ + int expected_dirs = nested_depth + 1; + int expected_errno = 0; + if (full_path_len > USHRT_MAX) + { + expected_dirs = 1 + (USHRT_MAX - tempdir_len) / level_len; + expected_errno = ENAMETOOLONG; } char *paths[] = { tempdir , 0 }; @@ -73,27 +102,42 @@ do_test (void) TEST_VERIFY_EXIT (ftsp != NULL); int num_dirs = 0; + bool path_mismatch = false; FTSENT *ent; while ((ent = fts_read(ftsp)) != 0) { - switch (ent->fts_info) + if (ent->fts_info != FTS_D && ent->fts_info != FTS_DP) + continue; + if (ent->fts_info == FTS_D) + num_dirs++; + + /* Stop at the first wrong path, since the paths are large. */ + size_t len = tempdir_len + level_len * ent->fts_level; + if (ent->fts_pathlen != len + || memcmp (ent->fts_path, full_path, len) != 0 + || ent->fts_path[len] != '\0') { - case FTS_D: - num_dirs++; - break; - default: + support_record_failure (); + printf ("error: wrong fts_path for level %d (fts_pathlen %u, " + "expected %zu)\n", ent->fts_level, ent->fts_pathlen, len); + path_mismatch = true; break; } } + int err = errno; - TEST_COMPARE (num_dirs, nested_depth + 1); - TEST_COMPARE (errno, 0); - - fts_close (ftsp); + TEST_COMPARE (fts_close (ftsp), 0); do_cleanup (); + if (!path_mismatch) + { + TEST_COMPARE (num_dirs, expected_dirs); + TEST_COMPARE (err, expected_errno); + } + + free (full_path); return 0; } diff --git a/io/tst-fts-bz34782-root.c b/io/tst-fts-bz34782-root.c new file mode 100644 index 0000000000..5df4b09bb5 --- /dev/null +++ b/io/tst-fts-bz34782-root.c @@ -0,0 +1,80 @@ +/* Check fts_open with root arguments around USHRT_MAX bytes (BZ 34782). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* FTSENT::fts_namelen and FTSENT::fts_pathlen are unsigned short, so + fts_open must reject a root argument longer than USHRT_MAX instead of + truncating its length. */ +static void +check_root (size_t len) +{ + char *root = xmalloc (len + 1); + memset (root, 'a', len); + root[len] = '\0'; + char *paths[] = { root, NULL }; + + errno = 0; + FTS *ftsp = fts_open (paths, FTS_PHYSICAL, NULL); + if (len > USHRT_MAX) + { + if (ftsp != NULL) + { + support_record_failure (); + printf ("error: fts_open accepted a %zu byte root\n", len); + fts_close (ftsp); + } + else + TEST_COMPARE (errno, ENAMETOOLONG); + } + else + { + TEST_VERIFY_EXIT (ftsp != NULL); + FTSENT *ent = fts_read (ftsp); + TEST_VERIFY_EXIT (ent != NULL); + /* The name does not exist (and is longer than PATH_MAX on Linux), + but the entry must still describe it correctly. */ + TEST_COMPARE (ent->fts_info, FTS_NS); + TEST_COMPARE (ent->fts_namelen, len); + TEST_COMPARE (ent->fts_pathlen, len); + TEST_COMPARE (strnlen (ent->fts_path, len + 1), len); + TEST_VERIFY (memcmp (ent->fts_path, root, len) == 0); + TEST_COMPARE (fts_close (ftsp), 0); + } + + free (root); +} + +static int +do_test (void) +{ + check_root (USHRT_MAX); + check_root (USHRT_MAX + 1); + check_root (USHRT_MAX + 2); + check_root (2 * (USHRT_MAX + 1) + 10); + return 0; +} + +#include diff --git a/io/tst-fts-bz34782.c b/io/tst-fts-bz34782.c new file mode 100644 index 0000000000..578690611e --- /dev/null +++ b/io/tst-fts-bz34782.c @@ -0,0 +1,23 @@ +/* Check that fts fails with ENAMETOOLONG, instead of returning corrupted + paths, when the paths get longer than USHRT_MAX (BZ 34782). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define BASENAME "tst-fts-bz34782." +/* Enough levels for the paths to get longer than USHRT_MAX. */ +#define NESTED_DEPTH 300 +#include "tst-fts-bz22944.c" diff --git a/io/tst-fts-cwdfd-follow.c b/io/tst-fts-cwdfd-follow.c new file mode 100644 index 0000000000..d52321a7a8 --- /dev/null +++ b/io/tst-fts-cwdfd-follow.c @@ -0,0 +1,217 @@ +/* Check fts_set FTS_FOLLOW on directories in an FTS_CWDFD walk (BZ 34781). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static char *root; + +/* Create the tree: + + root/a/file + root/b/file + root/c/d/e/f/g/h/file + root/z/file + + There are no symbolic links and the walk follows plain directories. The + nested directories under root/c are deep enough to exhaust the descriptor + ring used by FTS_CWDFD, so the return from root/c can not rely on it. */ +static void +do_prepare (int argc, char **argv) +{ + char *tempdir = support_create_temp_directory ("tst-fts-cwdfd-follow-"); + root = xasprintf ("%s/root", tempdir); + free (tempdir); + xmkdir (root, 0700); + add_temp_file (root); + + static const char *const dirs[] = + { + "a", + "b", + "c", + "c/d", + "c/d/e", + "c/d/e/f", + "c/d/e/f/g", + "c/d/e/f/g/h", + "z" + }; + for (size_t i = 0; i < array_length (dirs); i++) + { + char *path = xasprintf ("%s/%s", root, dirs[i]); + xmkdir (path, 0700); + add_temp_file (path); + free (path); + } + + static const char *const files[] = + { + "a/file", + "b/file", + "c/d/e/f/g/h/file", + "z/file" + }; + for (size_t i = 0; i < array_length (files); i++) + { + char *path = xasprintf ("%s/%s", root, files[i]); + xclose (xopen (path, O_WRONLY | O_CREAT | O_EXCL, 0600)); + add_temp_file (path); + free (path); + } +} +#define PREPARE do_prepare + +static int +compare_name (const FTSENT **a, const FTSENT **b) +{ + return strcmp ((*a)->fts_name, (*b)->fts_name); +} + +static const char *const expected[] = + { + "a", + "a/file", + "b", + "b/file", + "c", + "c/d", + "c/d/e", + "c/d/e/f", + "c/d/e/f/g", + "c/d/e/f/g/h", + "c/d/e/f/g/h/file", + "z", + "z/file" + }; + +static void +check_walk (int options, bool sort) +{ + printf ("info: options=%#x sort=%d\n", options, sort); + + struct support_descriptors *descriptors = support_descriptors_list (); + + char *paths[] = { root, NULL }; + FTS *fts = fts_open (paths, options, sort ? compare_name : NULL); + TEST_VERIFY_EXIT (fts != NULL); + + bool seen[array_length (expected)] = { false }; + /* Descriptors that the application opens during the walk. */ + int fds[4]; + size_t nfds = 0; + size_t rootlen = strlen (root); + FTSENT *ent; + while ((ent = fts_read (fts)) != NULL) + { + const char *rel = ent->fts_path + rootlen; + if (*rel == '/') + rel++; + + if (ent->fts_info != FTS_D + && ent->fts_info != FTS_DP + && ent->fts_info != FTS_F) + { + FAIL ("%s: unexpected fts_info %d (fts_errno %d)", ent->fts_path, + ent->fts_info, ent->fts_errno); + continue; + } + + /* The returned entry must be reachable through fts_accpath from the + current, possibly virtual, working directory. */ + int dirfd = (options & FTS_CWDFD) ? fts->fts_cwd_fd : AT_FDCWD; + struct stat st; + if (fstatat (dirfd, ent->fts_accpath, &st, AT_SYMLINK_NOFOLLOW) != 0) + FAIL ("%s: fstatat (%s): %m", ent->fts_path, ent->fts_accpath); + else + TEST_VERIFY (st.st_ino == ent->fts_statp->st_ino); + + /* Follow every child of root before fts_read reaches it. fts_read does + not apply the instruction to the first child. */ + if (ent->fts_level == FTS_ROOTLEVEL && ent->fts_info == FTS_D) + for (FTSENT *child = fts_children (fts, 0); + child != NULL; + child = child->fts_link) + TEST_COMPARE (fts_set (fts, child, FTS_FOLLOW), 0); + + /* If fts closed the descriptor of its working directory when it left + the followed directory, this open reuses it. */ + if (ent->fts_level == 1 && ent->fts_info == FTS_DP) + { + TEST_VERIFY_EXIT (nfds < array_length (fds)); + fds[nfds++] = xopen ("/dev/null", O_RDONLY, 0); + } + + if (ent->fts_info != FTS_DP) + for (size_t i = 0; i < array_length (expected); i++) + if (strcmp (rel, expected[i]) == 0) + { + TEST_VERIFY (!seen[i]); + seen[i] = true; + } + } + TEST_COMPARE (errno, 0); + TEST_COMPARE (fts_close (fts), 0); + + for (size_t i = 0; i < array_length (expected); i++) + if (!seen[i]) + FAIL ("%s/%s was not visited", root, expected[i]); + + /* fts must not close descriptors that it does not own. */ + for (size_t i = 0; i < nfds; i++) + if (fcntl (fds[i], F_GETFD) < 0) + FAIL ("descriptor %d was closed by fts: %m", fds[i]); + else + xclose (fds[i]); + + support_descriptors_check (descriptors); + support_descriptors_free (descriptors); +} + +static int +do_test (void) +{ + static const int options[] = + { + FTS_PHYSICAL, + FTS_PHYSICAL | FTS_CWDFD, + FTS_PHYSICAL | FTS_CWDFD | FTS_DEFER_STAT, + }; + + for (size_t i = 0; i < array_length (options); i++) + { + check_walk (options[i], true); + check_walk (options[i], false); + } + + return 0; +} + +#include diff --git a/io/tst-fts-follow.c b/io/tst-fts-follow.c new file mode 100644 index 0000000000..39b8e350a2 --- /dev/null +++ b/io/tst-fts-follow.c @@ -0,0 +1,249 @@ +/* Test fts_set with FTS_FOLLOW on a symbolic link to a directory (BZ 34775). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static char *root; + +/* Create the tree: + + root/aa + root/link -> target + root/target/file + root/target/a/b/c/d/e/file + root/zz + + The nested directories are deep enough to exhaust the descriptor ring used + by FTS_CWDFD, so the return from the followed directory can not rely on it. + The files after "link" in name order check that the walk resumes in the + right directory. */ +static void +do_prepare (int argc, char **argv) +{ + char *tempdir = support_create_temp_directory ("tst-fts-follow-"); + root = xasprintf ("%s/root", tempdir); + free (tempdir); + xmkdir (root, 0700); + add_temp_file (root); + + static const char *const dirs[] = + { + "target", + "target/a", + "target/a/b", + "target/a/b/c", + "target/a/b/c/d", + "target/a/b/c/d/e" + }; + for (size_t i = 0; i < array_length (dirs); i++) + { + char *path = xasprintf ("%s/%s", root, dirs[i]); + xmkdir (path, 0700); + add_temp_file (path); + free (path); + } + + static const char *const files[] = + { + "aa", + "zz", + "target/file", + "target/a/b/c/d/e/file" + }; + for (size_t i = 0; i < array_length (files); i++) + { + char *path = xasprintf ("%s/%s", root, files[i]); + xclose (xopen (path, O_WRONLY | O_CREAT | O_EXCL, 0600)); + add_temp_file (path); + free (path); + } + + char *path = xasprintf ("%s/link", root); + xsymlink ("target", path); + add_temp_file (path); + free (path); +} +#define PREPARE do_prepare + +static int +compare_name (const FTSENT **a, const FTSENT **b) +{ + return strcmp ((*a)->fts_name, (*b)->fts_name); +} + +enum follow_mode + { + /* fts_set on the FTS_SL entry returned by fts_read. */ + follow_returned, + /* fts_set on the entry from fts_children of root, before fts_read + reaches it. */ + follow_children, + }; + +static const char *const expected[] = + { + "link", + "link/file", + "link/a/b/c/d/e/file", + "target/file", + "aa", + "zz" + }; + +static void +check_walk (int options, enum follow_mode mode, bool sort) +{ + printf ("info: options=%#x mode=%s sort=%d\n", options, + mode == follow_returned ? "returned" : "children", sort); + + struct support_descriptors *descriptors = support_descriptors_list (); + char *cwd = getcwd (NULL, 0); + TEST_VERIFY_EXIT (cwd != NULL); + + char *paths[] = { root, NULL }; + FTS *fts = fts_open (paths, options, sort ? compare_name : NULL); + TEST_VERIFY_EXIT (fts != NULL); + + bool seen[array_length (expected)] = { false }; + size_t rootlen = strlen (root); + bool followed = false; + FTSENT *ent; + while ((ent = fts_read (fts)) != NULL) + { + const char *rel = ent->fts_path + rootlen; + if (*rel == '/') + rel++; + + if (ent->fts_info == FTS_DNR + || ent->fts_info == FTS_ERR + || ent->fts_info == FTS_NS + || ent->fts_info == FTS_DC) + FAIL ("%s: unexpected fts_info %d (fts_errno %d)", ent->fts_path, + ent->fts_info, ent->fts_errno); + + if (ent->fts_info == FTS_SL) + { + /* With follow_children, fts_read still returns the entry once + without following it if it is the first child. */ + TEST_COMPARE_STRING (rel, "link"); + if (mode == follow_returned) + { + TEST_VERIFY (!followed); + TEST_COMPARE (fts_set (fts, ent, FTS_FOLLOW), 0); + followed = true; + } + continue; + } + + /* The returned entry must be reachable through fts_accpath from the + current, possibly virtual, working directory. */ + int dirfd = (options & FTS_CWDFD) ? fts->fts_cwd_fd : AT_FDCWD; + { + struct stat st; + int flags = strcmp (rel, "link") == 0 ? 0 : AT_SYMLINK_NOFOLLOW; + if (fstatat (dirfd, ent->fts_accpath, &st, flags) != 0) + FAIL ("%s: fstatat (%s): %m", ent->fts_path, ent->fts_accpath); + else + TEST_VERIFY (st.st_ino == ent->fts_statp->st_ino); + } + + if (mode == follow_children + && ent->fts_level == FTS_ROOTLEVEL + && ent->fts_info == FTS_D) + { + FTSENT *child; + for (child = fts_children (fts, 0); child != NULL; + child = child->fts_link) + if (strcmp (child->fts_name, "link") == 0) + break; + TEST_VERIFY_EXIT (child != NULL); + TEST_COMPARE (fts_set (fts, child, FTS_FOLLOW), 0); + followed = true; + } + + if (ent->fts_info == FTS_D && strcmp (rel, "link") == 0) + TEST_VERIFY (followed); + + if (ent->fts_info == FTS_D || ent->fts_info == FTS_F) + for (size_t i = 0; i < array_length (expected); i++) + if (strcmp (rel, expected[i]) == 0) + { + TEST_VERIFY (!seen[i]); + seen[i] = true; + } + } + TEST_COMPARE (errno, 0); + TEST_COMPARE (fts_close (fts), 0); + + for (size_t i = 0; i < array_length (expected); i++) + if (!seen[i]) + FAIL ("%s/%s was not visited", root, expected[i]); + + char *cwd_after = getcwd (NULL, 0); + TEST_VERIFY_EXIT (cwd_after != NULL); + TEST_COMPARE_STRING (cwd, cwd_after); + free (cwd_after); + free (cwd); + + support_descriptors_check (descriptors); + support_descriptors_free (descriptors); +} + +static int +do_test (void) +{ + static const int options[] = + { + FTS_PHYSICAL, + FTS_PHYSICAL | FTS_NOCHDIR, + FTS_PHYSICAL | FTS_COMFOLLOW | FTS_NOCHDIR, + FTS_PHYSICAL | FTS_CWDFD, + FTS_PHYSICAL | FTS_CWDFD | FTS_DEFER_STAT, + }; + + for (size_t i = 0; i < array_length (options); i++) + { + check_walk (options[i], follow_returned, true); + check_walk (options[i], follow_returned, false); + /* With FTS_NOCHDIR, fts_read stats a sibling entry marked with + FTS_FOLLOW before it builds the entry's path, so it checks the wrong + file. This is a long-standing issue unrelated to BZ 34775. */ + if (!(options[i] & FTS_NOCHDIR)) + { + check_walk (options[i], follow_children, true); + check_walk (options[i], follow_children, false); + } + } + + return 0; +} + +#include diff --git a/libio/Makefile b/libio/Makefile index 616107ee10..9aec016cca 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -110,6 +110,7 @@ tests = \ tst-fgetwc \ tst-fgetws \ tst-file-init-race \ + tst-fopen-ccs-empty \ tst-fopenloc2 \ tst-fputws \ tst-freopen \ diff --git a/libio/fileops.c b/libio/fileops.c index 9348d7c3a1..5a249725ee 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -355,12 +355,14 @@ _IO_new_file_fopen (FILE *fp, const char *filename, const char *mode, *((char *) __mempcpy (ccs, cs + 5, endp - (cs + 5))) = '\0'; strip (ccs, ccs); - if (__wcsmbs_named_conv (&fcts, ccs[2] == '\0' - ? upstr (ccs, cs + 5) : ccs) != 0) + /* After stripping, ccs[2] == '\0' means the charset name is empty. + This is not a valid charset and would cause problems downstream. + Reject it with EINVAL (BZ #34574, CVE-2026-18374). */ + if (ccs[2] == '\0' || __wcsmbs_named_conv (&fcts, ccs) != 0) { - /* Something went wrong, we cannot load the conversion modules. - This means we cannot proceed since the user explicitly asked - for these. */ + /* Either the charset name is empty after strip(), or conversion + modules cannot be loaded. This means we cannot proceed since + the user explicitly asked for character conversion. */ (void) _IO_file_close_it (fp); free (ccs); __set_errno (EINVAL); diff --git a/libio/tst-fopen-ccs-empty.c b/libio/tst-fopen-ccs-empty.c new file mode 100644 index 0000000000..64723965e1 --- /dev/null +++ b/libio/tst-fopen-ccs-empty.c @@ -0,0 +1,62 @@ +/* Test fopen with an empty ",ccs=" value in the mode string (bug 34574). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static void +check_fopen_fails (const char *path, const char *mode) +{ + errno = 0; + FILE *fp = fopen (path, mode); + TEST_VERIFY (fp == NULL); + TEST_COMPARE (errno, EINVAL); + if (fp != NULL) + fclose (fp); +} + +static int +do_test (void) +{ + char *path; + xclose (create_temp_file ("tst-fopen-ccs-empty", &path)); + + /* The value is blank and the mode string continues well past it. */ + enum { size = 1024 * 1024 }; + char *mode = xmalloc (size); + memset (mode, 'X', size); + mode[size - 1] = '\0'; + static const char prefix[] = "w,ccs= ,"; + memcpy (mode, prefix, sizeof (prefix) - 1); + check_fopen_fails (path, mode); + free (mode); + + check_fopen_fails (path, "w,ccs="); + check_fopen_fails (path, "w,ccs=,"); + + free (path); + return 0; +} + +#include diff --git a/malloc/malloc.c b/malloc/malloc.c index 8fe8b18340..a50ff3598c 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3256,7 +3256,7 @@ __libc_realloc (void *oldmem, size_t bytes) if (newmem == NULL) return NULL; /* propagate failure */ - memcpy (newmem, oldmem, oldsize - CHUNK_HDR_SZ); + memcpy (newmem, oldmem, usable); munmap_chunk (oldp); return newmem; } diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index ca670768a2..5c4d486af4 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -9661,6 +9661,14 @@ sinh 0x2.c5d37700c6bb03a6c24b6c9b494cp+12 sinh 0x2.c5d37700c6bb03a6c24b6c9b494ep+12 # the next value generates larger error bounds on x86_64 (binary64) sinh -0x1.633c62890fa14p+9 +sinh 0x1.2b4f4e0bb49c9p+5 +sinh -0x1.2b4f4e0bb49c9p+5 +sinh 0x1.2ac43fb6d3abap+5 +sinh -0x1.2ac43fb6d3abap+5 +sinh 0x1.b7efa91915c95p-2 +sinh -0x1.b7efa91915c95p-2 +sinh 0x1.92a5c27afbe82p+4 +sinh -0x1.92a5c27afbe82p+4 sinpi 0 sinpi -0 diff --git a/math/auto-libm-test-out-sinh b/math/auto-libm-test-out-sinh index f96252b91c..91ab5c19fa 100644 --- a/math/auto-libm-test-out-sinh +++ b/math/auto-libm-test-out-sinh @@ -6466,3 +6466,555 @@ sinh -0x1.633c62890fa14p+9 = sinh tonearest ibm128 -0x2.c678c5121f428p+8 : -0xf.ef3a7e711d2c75a66ea3ca1c4p+1020 : inexact-ok = sinh towardzero ibm128 -0x2.c678c5121f428p+8 : -0xf.ef3a7e711d2c75a66ea3ca1c4p+1020 : inexact-ok = sinh upward ibm128 -0x2.c678c5121f428p+8 : -0xf.ef3a7e711d2c75a66ea3ca1c4p+1020 : inexact-ok +sinh 0x1.2b4f4e0bb49c9p+5 += sinh downward binary32 0x2.569eap+4 : 0x1.f7c30ap+52 : inexact-ok += sinh tonearest binary32 0x2.569eap+4 : 0x1.f7c30ap+52 : inexact-ok += sinh towardzero binary32 0x2.569eap+4 : 0x1.f7c30ap+52 : inexact-ok += sinh upward binary32 0x2.569eap+4 : 0x1.f7c30cp+52 : inexact-ok += sinh downward binary64 0x2.569eap+4 : 0x1.f7c30a155eea3p+52 : inexact-ok += sinh tonearest binary64 0x2.569eap+4 : 0x1.f7c30a155eea4p+52 : inexact-ok += sinh towardzero binary64 0x2.569eap+4 : 0x1.f7c30a155eea3p+52 : inexact-ok += sinh upward binary64 0x2.569eap+4 : 0x1.f7c30a155eea4p+52 : inexact-ok += sinh downward intel96 0x2.569eap+4 : 0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh tonearest intel96 0x2.569eap+4 : 0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh towardzero intel96 0x2.569eap+4 : 0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh upward intel96 0x2.569eap+4 : 0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh downward m68k96 0x2.569eap+4 : 0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh tonearest m68k96 0x2.569eap+4 : 0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh towardzero m68k96 0x2.569eap+4 : 0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh upward m68k96 0x2.569eap+4 : 0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh downward binary128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84f52p+52 : inexact-ok += sinh tonearest binary128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84f52p+52 : inexact-ok += sinh towardzero binary128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84f52p+52 : inexact-ok += sinh upward binary128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84f53p+52 : inexact-ok += sinh downward ibm128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84fp+52 : inexact-ok += sinh tonearest ibm128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84f8p+52 : inexact-ok += sinh towardzero ibm128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84fp+52 : inexact-ok += sinh upward ibm128 0x2.569eap+4 : 0x1.f7c30a155eea3c77d646a5f84f8p+52 : inexact-ok += sinh downward binary32 0x2.569e9cp+4 : 0x1.f7c28cp+52 : inexact-ok += sinh tonearest binary32 0x2.569e9cp+4 : 0x1.f7c28cp+52 : inexact-ok += sinh towardzero binary32 0x2.569e9cp+4 : 0x1.f7c28cp+52 : inexact-ok += sinh upward binary32 0x2.569e9cp+4 : 0x1.f7c28ep+52 : inexact-ok += sinh downward binary64 0x2.569e9cp+4 : 0x1.f7c28c24ac22fp+52 : inexact-ok += sinh tonearest binary64 0x2.569e9cp+4 : 0x1.f7c28c24ac23p+52 : inexact-ok += sinh towardzero binary64 0x2.569e9cp+4 : 0x1.f7c28c24ac22fp+52 : inexact-ok += sinh upward binary64 0x2.569e9cp+4 : 0x1.f7c28c24ac23p+52 : inexact-ok += sinh downward intel96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh tonearest intel96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh towardzero intel96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh upward intel96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbcp+52 : inexact-ok += sinh downward m68k96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh tonearest m68k96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh towardzero m68k96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh upward m68k96 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbcp+52 : inexact-ok += sinh downward binary128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd1ebp+52 : inexact-ok += sinh tonearest binary128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd1ebp+52 : inexact-ok += sinh towardzero binary128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd1ebp+52 : inexact-ok += sinh upward binary128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd1ecp+52 : inexact-ok += sinh downward ibm128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd18p+52 : inexact-ok += sinh tonearest ibm128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd2p+52 : inexact-ok += sinh towardzero ibm128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd18p+52 : inexact-ok += sinh upward ibm128 0x2.569e9cp+4 : 0x1.f7c28c24ac22fbbe1ad8f17fd2p+52 : inexact-ok += sinh downward binary64 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1dp+52 : inexact-ok += sinh tonearest binary64 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1ep+52 : inexact-ok += sinh towardzero binary64 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1dp+52 : inexact-ok += sinh upward binary64 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1ep+52 : inexact-ok += sinh downward intel96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh tonearest intel96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh towardzero intel96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh upward intel96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d802p+52 : inexact-ok += sinh downward m68k96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh tonearest m68k96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh towardzero m68k96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh upward m68k96 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d802p+52 : inexact-ok += sinh downward binary128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000008f84p+52 : inexact-ok += sinh tonearest binary128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000008f85p+52 : inexact-ok += sinh towardzero binary128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000008f84p+52 : inexact-ok += sinh upward binary128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000008f85p+52 : inexact-ok += sinh downward ibm128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000008f8p+52 : inexact-ok += sinh tonearest ibm128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000008f8p+52 : inexact-ok += sinh towardzero ibm128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000008f8p+52 : inexact-ok += sinh upward ibm128 0x2.569e9c1769392p+4 : 0x1.f7c28f05c4c1d800000000009p+52 : inexact-ok +sinh -0x1.2b4f4e0bb49c9p+5 += sinh downward binary32 -0x2.569e9cp+4 : -0x1.f7c28ep+52 : inexact-ok += sinh tonearest binary32 -0x2.569e9cp+4 : -0x1.f7c28cp+52 : inexact-ok += sinh towardzero binary32 -0x2.569e9cp+4 : -0x1.f7c28cp+52 : inexact-ok += sinh upward binary32 -0x2.569e9cp+4 : -0x1.f7c28cp+52 : inexact-ok += sinh downward binary64 -0x2.569e9cp+4 : -0x1.f7c28c24ac23p+52 : inexact-ok += sinh tonearest binary64 -0x2.569e9cp+4 : -0x1.f7c28c24ac23p+52 : inexact-ok += sinh towardzero binary64 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fp+52 : inexact-ok += sinh upward binary64 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fp+52 : inexact-ok += sinh downward intel96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbcp+52 : inexact-ok += sinh tonearest intel96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh towardzero intel96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh upward intel96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh downward m68k96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbcp+52 : inexact-ok += sinh tonearest m68k96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh towardzero m68k96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh upward m68k96 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbep+52 : inexact-ok += sinh downward binary128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd1ecp+52 : inexact-ok += sinh tonearest binary128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd1ebp+52 : inexact-ok += sinh towardzero binary128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd1ebp+52 : inexact-ok += sinh upward binary128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd1ebp+52 : inexact-ok += sinh downward ibm128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd2p+52 : inexact-ok += sinh tonearest ibm128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd2p+52 : inexact-ok += sinh towardzero ibm128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd18p+52 : inexact-ok += sinh upward ibm128 -0x2.569e9cp+4 : -0x1.f7c28c24ac22fbbe1ad8f17fd18p+52 : inexact-ok += sinh downward binary32 -0x2.569eap+4 : -0x1.f7c30cp+52 : inexact-ok += sinh tonearest binary32 -0x2.569eap+4 : -0x1.f7c30ap+52 : inexact-ok += sinh towardzero binary32 -0x2.569eap+4 : -0x1.f7c30ap+52 : inexact-ok += sinh upward binary32 -0x2.569eap+4 : -0x1.f7c30ap+52 : inexact-ok += sinh downward binary64 -0x2.569eap+4 : -0x1.f7c30a155eea4p+52 : inexact-ok += sinh tonearest binary64 -0x2.569eap+4 : -0x1.f7c30a155eea4p+52 : inexact-ok += sinh towardzero binary64 -0x2.569eap+4 : -0x1.f7c30a155eea3p+52 : inexact-ok += sinh upward binary64 -0x2.569eap+4 : -0x1.f7c30a155eea3p+52 : inexact-ok += sinh downward intel96 -0x2.569eap+4 : -0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh tonearest intel96 -0x2.569eap+4 : -0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh towardzero intel96 -0x2.569eap+4 : -0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh upward intel96 -0x2.569eap+4 : -0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh downward m68k96 -0x2.569eap+4 : -0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh tonearest m68k96 -0x2.569eap+4 : -0x1.f7c30a155eea3c78p+52 : inexact-ok += sinh towardzero m68k96 -0x2.569eap+4 : -0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh upward m68k96 -0x2.569eap+4 : -0x1.f7c30a155eea3c76p+52 : inexact-ok += sinh downward binary128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84f53p+52 : inexact-ok += sinh tonearest binary128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84f52p+52 : inexact-ok += sinh towardzero binary128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84f52p+52 : inexact-ok += sinh upward binary128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84f52p+52 : inexact-ok += sinh downward ibm128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84f8p+52 : inexact-ok += sinh tonearest ibm128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84f8p+52 : inexact-ok += sinh towardzero ibm128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84fp+52 : inexact-ok += sinh upward ibm128 -0x2.569eap+4 : -0x1.f7c30a155eea3c77d646a5f84fp+52 : inexact-ok += sinh downward binary64 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1ep+52 : inexact-ok += sinh tonearest binary64 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1ep+52 : inexact-ok += sinh towardzero binary64 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1dp+52 : inexact-ok += sinh upward binary64 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1dp+52 : inexact-ok += sinh downward intel96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d802p+52 : inexact-ok += sinh tonearest intel96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh towardzero intel96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh upward intel96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh downward m68k96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d802p+52 : inexact-ok += sinh tonearest m68k96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh towardzero m68k96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh upward m68k96 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d8p+52 : inexact-ok += sinh downward binary128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000008f85p+52 : inexact-ok += sinh tonearest binary128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000008f85p+52 : inexact-ok += sinh towardzero binary128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000008f84p+52 : inexact-ok += sinh upward binary128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000008f84p+52 : inexact-ok += sinh downward ibm128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000009p+52 : inexact-ok += sinh tonearest ibm128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000008f8p+52 : inexact-ok += sinh towardzero ibm128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000008f8p+52 : inexact-ok += sinh upward ibm128 -0x2.569e9c1769392p+4 : -0x1.f7c28f05c4c1d800000000008f8p+52 : inexact-ok +sinh 0x1.2ac43fb6d3abap+5 += sinh downward binary32 0x2.55888p+4 : 0x1.d6b0ecp+52 : inexact-ok += sinh tonearest binary32 0x2.55888p+4 : 0x1.d6b0ecp+52 : inexact-ok += sinh towardzero binary32 0x2.55888p+4 : 0x1.d6b0ecp+52 : inexact-ok += sinh upward binary32 0x2.55888p+4 : 0x1.d6b0eep+52 : inexact-ok += sinh downward binary64 0x2.55888p+4 : 0x1.d6b0ecda100c2p+52 : inexact-ok += sinh tonearest binary64 0x2.55888p+4 : 0x1.d6b0ecda100c2p+52 : inexact-ok += sinh towardzero binary64 0x2.55888p+4 : 0x1.d6b0ecda100c2p+52 : inexact-ok += sinh upward binary64 0x2.55888p+4 : 0x1.d6b0ecda100c3p+52 : inexact-ok += sinh downward intel96 0x2.55888p+4 : 0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh tonearest intel96 0x2.55888p+4 : 0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh towardzero intel96 0x2.55888p+4 : 0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh upward intel96 0x2.55888p+4 : 0x1.d6b0ecda100c254p+52 : inexact-ok += sinh downward m68k96 0x2.55888p+4 : 0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh tonearest m68k96 0x2.55888p+4 : 0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh towardzero m68k96 0x2.55888p+4 : 0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh upward m68k96 0x2.55888p+4 : 0x1.d6b0ecda100c254p+52 : inexact-ok += sinh downward binary128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed6d8p+52 : inexact-ok += sinh tonearest binary128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed6d8p+52 : inexact-ok += sinh towardzero binary128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed6d8p+52 : inexact-ok += sinh upward binary128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed6d9p+52 : inexact-ok += sinh downward ibm128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed68p+52 : inexact-ok += sinh tonearest ibm128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed7p+52 : inexact-ok += sinh towardzero ibm128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed68p+52 : inexact-ok += sinh upward ibm128 0x2.55888p+4 : 0x1.d6b0ecda100c253edb8a451ed7p+52 : inexact-ok += sinh downward binary32 0x2.55887cp+4 : 0x1.d6b076p+52 : inexact-ok += sinh tonearest binary32 0x2.55887cp+4 : 0x1.d6b078p+52 : inexact-ok += sinh towardzero binary32 0x2.55887cp+4 : 0x1.d6b076p+52 : inexact-ok += sinh upward binary32 0x2.55887cp+4 : 0x1.d6b078p+52 : inexact-ok += sinh downward binary64 0x2.55887cp+4 : 0x1.d6b0772de38b2p+52 : inexact-ok += sinh tonearest binary64 0x2.55887cp+4 : 0x1.d6b0772de38b2p+52 : inexact-ok += sinh towardzero binary64 0x2.55887cp+4 : 0x1.d6b0772de38b2p+52 : inexact-ok += sinh upward binary64 0x2.55887cp+4 : 0x1.d6b0772de38b3p+52 : inexact-ok += sinh downward intel96 0x2.55887cp+4 : 0x1.d6b0772de38b2768p+52 : inexact-ok += sinh tonearest intel96 0x2.55887cp+4 : 0x1.d6b0772de38b2768p+52 : inexact-ok += sinh towardzero intel96 0x2.55887cp+4 : 0x1.d6b0772de38b2768p+52 : inexact-ok += sinh upward intel96 0x2.55887cp+4 : 0x1.d6b0772de38b276ap+52 : inexact-ok += sinh downward m68k96 0x2.55887cp+4 : 0x1.d6b0772de38b2768p+52 : inexact-ok += sinh tonearest m68k96 0x2.55887cp+4 : 0x1.d6b0772de38b2768p+52 : inexact-ok += sinh towardzero m68k96 0x2.55887cp+4 : 0x1.d6b0772de38b2768p+52 : inexact-ok += sinh upward m68k96 0x2.55887cp+4 : 0x1.d6b0772de38b276ap+52 : inexact-ok += sinh downward binary128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c261p+52 : inexact-ok += sinh tonearest binary128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c261p+52 : inexact-ok += sinh towardzero binary128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c261p+52 : inexact-ok += sinh upward binary128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c262p+52 : inexact-ok += sinh downward ibm128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c2p+52 : inexact-ok += sinh tonearest ibm128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c28p+52 : inexact-ok += sinh towardzero ibm128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c2p+52 : inexact-ok += sinh upward ibm128 0x2.55887cp+4 : 0x1.d6b0772de38b2768d785fab9c28p+52 : inexact-ok += sinh downward binary64 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65p+52 : inexact-ok += sinh tonearest binary64 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh towardzero binary64 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65p+52 : inexact-ok += sinh upward binary64 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh downward intel96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh tonearest intel96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh towardzero intel96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh upward intel96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh downward m68k96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh tonearest m68k96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh towardzero m68k96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh upward m68k96 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh downward binary128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff289ep+52 : inexact-ok += sinh tonearest binary128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff289ep+52 : inexact-ok += sinh towardzero binary128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff289ep+52 : inexact-ok += sinh upward binary128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff289fp+52 : inexact-ok += sinh downward ibm128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff288p+52 : inexact-ok += sinh tonearest ibm128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff288p+52 : inexact-ok += sinh towardzero ibm128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff288p+52 : inexact-ok += sinh upward ibm128 0x2.55887f6da7574p+4 : 0x1.d6b0dc08d1b65fffffffffff29p+52 : inexact-ok +sinh -0x1.2ac43fb6d3abap+5 += sinh downward binary32 -0x2.55887cp+4 : -0x1.d6b078p+52 : inexact-ok += sinh tonearest binary32 -0x2.55887cp+4 : -0x1.d6b078p+52 : inexact-ok += sinh towardzero binary32 -0x2.55887cp+4 : -0x1.d6b076p+52 : inexact-ok += sinh upward binary32 -0x2.55887cp+4 : -0x1.d6b076p+52 : inexact-ok += sinh downward binary64 -0x2.55887cp+4 : -0x1.d6b0772de38b3p+52 : inexact-ok += sinh tonearest binary64 -0x2.55887cp+4 : -0x1.d6b0772de38b2p+52 : inexact-ok += sinh towardzero binary64 -0x2.55887cp+4 : -0x1.d6b0772de38b2p+52 : inexact-ok += sinh upward binary64 -0x2.55887cp+4 : -0x1.d6b0772de38b2p+52 : inexact-ok += sinh downward intel96 -0x2.55887cp+4 : -0x1.d6b0772de38b276ap+52 : inexact-ok += sinh tonearest intel96 -0x2.55887cp+4 : -0x1.d6b0772de38b2768p+52 : inexact-ok += sinh towardzero intel96 -0x2.55887cp+4 : -0x1.d6b0772de38b2768p+52 : inexact-ok += sinh upward intel96 -0x2.55887cp+4 : -0x1.d6b0772de38b2768p+52 : inexact-ok += sinh downward m68k96 -0x2.55887cp+4 : -0x1.d6b0772de38b276ap+52 : inexact-ok += sinh tonearest m68k96 -0x2.55887cp+4 : -0x1.d6b0772de38b2768p+52 : inexact-ok += sinh towardzero m68k96 -0x2.55887cp+4 : -0x1.d6b0772de38b2768p+52 : inexact-ok += sinh upward m68k96 -0x2.55887cp+4 : -0x1.d6b0772de38b2768p+52 : inexact-ok += sinh downward binary128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c262p+52 : inexact-ok += sinh tonearest binary128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c261p+52 : inexact-ok += sinh towardzero binary128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c261p+52 : inexact-ok += sinh upward binary128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c261p+52 : inexact-ok += sinh downward ibm128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c28p+52 : inexact-ok += sinh tonearest ibm128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c28p+52 : inexact-ok += sinh towardzero ibm128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c2p+52 : inexact-ok += sinh upward ibm128 -0x2.55887cp+4 : -0x1.d6b0772de38b2768d785fab9c2p+52 : inexact-ok += sinh downward binary32 -0x2.55888p+4 : -0x1.d6b0eep+52 : inexact-ok += sinh tonearest binary32 -0x2.55888p+4 : -0x1.d6b0ecp+52 : inexact-ok += sinh towardzero binary32 -0x2.55888p+4 : -0x1.d6b0ecp+52 : inexact-ok += sinh upward binary32 -0x2.55888p+4 : -0x1.d6b0ecp+52 : inexact-ok += sinh downward binary64 -0x2.55888p+4 : -0x1.d6b0ecda100c3p+52 : inexact-ok += sinh tonearest binary64 -0x2.55888p+4 : -0x1.d6b0ecda100c2p+52 : inexact-ok += sinh towardzero binary64 -0x2.55888p+4 : -0x1.d6b0ecda100c2p+52 : inexact-ok += sinh upward binary64 -0x2.55888p+4 : -0x1.d6b0ecda100c2p+52 : inexact-ok += sinh downward intel96 -0x2.55888p+4 : -0x1.d6b0ecda100c254p+52 : inexact-ok += sinh tonearest intel96 -0x2.55888p+4 : -0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh towardzero intel96 -0x2.55888p+4 : -0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh upward intel96 -0x2.55888p+4 : -0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh downward m68k96 -0x2.55888p+4 : -0x1.d6b0ecda100c254p+52 : inexact-ok += sinh tonearest m68k96 -0x2.55888p+4 : -0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh towardzero m68k96 -0x2.55888p+4 : -0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh upward m68k96 -0x2.55888p+4 : -0x1.d6b0ecda100c253ep+52 : inexact-ok += sinh downward binary128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed6d9p+52 : inexact-ok += sinh tonearest binary128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed6d8p+52 : inexact-ok += sinh towardzero binary128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed6d8p+52 : inexact-ok += sinh upward binary128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed6d8p+52 : inexact-ok += sinh downward ibm128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed7p+52 : inexact-ok += sinh tonearest ibm128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed7p+52 : inexact-ok += sinh towardzero ibm128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed68p+52 : inexact-ok += sinh upward ibm128 -0x2.55888p+4 : -0x1.d6b0ecda100c253edb8a451ed68p+52 : inexact-ok += sinh downward binary64 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh tonearest binary64 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh towardzero binary64 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65p+52 : inexact-ok += sinh upward binary64 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65p+52 : inexact-ok += sinh downward intel96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh tonearest intel96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh towardzero intel96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh upward intel96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh downward m68k96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh tonearest m68k96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b66p+52 : inexact-ok += sinh towardzero m68k96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh upward m68k96 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65ffep+52 : inexact-ok += sinh downward binary128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff289fp+52 : inexact-ok += sinh tonearest binary128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff289ep+52 : inexact-ok += sinh towardzero binary128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff289ep+52 : inexact-ok += sinh upward binary128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff289ep+52 : inexact-ok += sinh downward ibm128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff29p+52 : inexact-ok += sinh tonearest ibm128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff288p+52 : inexact-ok += sinh towardzero ibm128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff288p+52 : inexact-ok += sinh upward ibm128 -0x2.55887f6da7574p+4 : -0x1.d6b0dc08d1b65fffffffffff288p+52 : inexact-ok +sinh 0x1.b7efa91915c95p-2 += sinh downward binary32 0x6.dfbea8p-4 : 0x7.1661a8p-4 : inexact-ok += sinh tonearest binary32 0x6.dfbea8p-4 : 0x7.1661a8p-4 : inexact-ok += sinh towardzero binary32 0x6.dfbea8p-4 : 0x7.1661a8p-4 : inexact-ok += sinh upward binary32 0x6.dfbea8p-4 : 0x7.1661bp-4 : inexact-ok += sinh downward binary64 0x6.dfbea8p-4 : 0x7.1661abb8260e4p-4 : inexact-ok += sinh tonearest binary64 0x6.dfbea8p-4 : 0x7.1661abb8260e8p-4 : inexact-ok += sinh towardzero binary64 0x6.dfbea8p-4 : 0x7.1661abb8260e4p-4 : inexact-ok += sinh upward binary64 0x6.dfbea8p-4 : 0x7.1661abb8260e8p-4 : inexact-ok += sinh downward intel96 0x6.dfbea8p-4 : 0x7.1661abb8260e76a8p-4 : inexact-ok += sinh tonearest intel96 0x6.dfbea8p-4 : 0x7.1661abb8260e76a8p-4 : inexact-ok += sinh towardzero intel96 0x6.dfbea8p-4 : 0x7.1661abb8260e76a8p-4 : inexact-ok += sinh upward intel96 0x6.dfbea8p-4 : 0x7.1661abb8260e76bp-4 : inexact-ok += sinh downward m68k96 0x6.dfbea8p-4 : 0x7.1661abb8260e76a8p-4 : inexact-ok += sinh tonearest m68k96 0x6.dfbea8p-4 : 0x7.1661abb8260e76a8p-4 : inexact-ok += sinh towardzero m68k96 0x6.dfbea8p-4 : 0x7.1661abb8260e76a8p-4 : inexact-ok += sinh upward m68k96 0x6.dfbea8p-4 : 0x7.1661abb8260e76bp-4 : inexact-ok += sinh downward binary128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ebed4p-4 : inexact-ok += sinh tonearest binary128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ebed8p-4 : inexact-ok += sinh towardzero binary128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ebed4p-4 : inexact-ok += sinh upward binary128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ebed8p-4 : inexact-ok += sinh downward ibm128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ebep-4 : inexact-ok += sinh tonearest ibm128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ebep-4 : inexact-ok += sinh towardzero ibm128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ebep-4 : inexact-ok += sinh upward ibm128 0x6.dfbea8p-4 : 0x7.1661abb8260e76a92049555ecp-4 : inexact-ok += sinh downward binary32 0x6.dfbeap-4 : 0x7.1661ap-4 : inexact-ok += sinh tonearest binary32 0x6.dfbeap-4 : 0x7.1661ap-4 : inexact-ok += sinh towardzero binary32 0x6.dfbeap-4 : 0x7.1661ap-4 : inexact-ok += sinh upward binary32 0x6.dfbeap-4 : 0x7.1661a8p-4 : inexact-ok += sinh downward binary64 0x6.dfbeap-4 : 0x7.1661a2f837414p-4 : inexact-ok += sinh tonearest binary64 0x6.dfbeap-4 : 0x7.1661a2f837418p-4 : inexact-ok += sinh towardzero binary64 0x6.dfbeap-4 : 0x7.1661a2f837414p-4 : inexact-ok += sinh upward binary64 0x6.dfbeap-4 : 0x7.1661a2f837418p-4 : inexact-ok += sinh downward intel96 0x6.dfbeap-4 : 0x7.1661a2f837416e9p-4 : inexact-ok += sinh tonearest intel96 0x6.dfbeap-4 : 0x7.1661a2f837416e9p-4 : inexact-ok += sinh towardzero intel96 0x6.dfbeap-4 : 0x7.1661a2f837416e9p-4 : inexact-ok += sinh upward intel96 0x6.dfbeap-4 : 0x7.1661a2f837416e98p-4 : inexact-ok += sinh downward m68k96 0x6.dfbeap-4 : 0x7.1661a2f837416e9p-4 : inexact-ok += sinh tonearest m68k96 0x6.dfbeap-4 : 0x7.1661a2f837416e9p-4 : inexact-ok += sinh towardzero m68k96 0x6.dfbeap-4 : 0x7.1661a2f837416e9p-4 : inexact-ok += sinh upward m68k96 0x6.dfbeap-4 : 0x7.1661a2f837416e98p-4 : inexact-ok += sinh downward binary128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d4c8p-4 : inexact-ok += sinh tonearest binary128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d4c8p-4 : inexact-ok += sinh towardzero binary128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d4c8p-4 : inexact-ok += sinh upward binary128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d4ccp-4 : inexact-ok += sinh downward ibm128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d4p-4 : inexact-ok += sinh tonearest ibm128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d4p-4 : inexact-ok += sinh towardzero ibm128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d4p-4 : inexact-ok += sinh upward ibm128 0x6.dfbeap-4 : 0x7.1661a2f837416e909121ab55d6p-4 : inexact-ok += sinh downward binary64 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed208p-4 : inexact-ok += sinh tonearest binary64 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20cp-4 : inexact-ok += sinh towardzero binary64 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed208p-4 : inexact-ok += sinh upward binary64 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20cp-4 : inexact-ok += sinh downward intel96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh tonearest intel96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20cp-4 : inexact-ok += sinh towardzero intel96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh upward intel96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20cp-4 : inexact-ok += sinh downward m68k96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh tonearest m68k96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20cp-4 : inexact-ok += sinh towardzero m68k96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh upward m68k96 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20cp-4 : inexact-ok += sinh downward binary128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffeb44p-4 : inexact-ok += sinh tonearest binary128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffeb48p-4 : inexact-ok += sinh towardzero binary128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffeb44p-4 : inexact-ok += sinh upward binary128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffeb48p-4 : inexact-ok += sinh downward ibm128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffeap-4 : inexact-ok += sinh tonearest ibm128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffecp-4 : inexact-ok += sinh towardzero ibm128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffeap-4 : inexact-ok += sinh upward ibm128 0x6.dfbea46457254p-4 : 0x7.1661a7c5ed20bfffffffffffecp-4 : inexact-ok +sinh -0x1.b7efa91915c95p-2 += sinh downward binary32 -0x6.dfbeap-4 : -0x7.1661a8p-4 : inexact-ok += sinh tonearest binary32 -0x6.dfbeap-4 : -0x7.1661ap-4 : inexact-ok += sinh towardzero binary32 -0x6.dfbeap-4 : -0x7.1661ap-4 : inexact-ok += sinh upward binary32 -0x6.dfbeap-4 : -0x7.1661ap-4 : inexact-ok += sinh downward binary64 -0x6.dfbeap-4 : -0x7.1661a2f837418p-4 : inexact-ok += sinh tonearest binary64 -0x6.dfbeap-4 : -0x7.1661a2f837418p-4 : inexact-ok += sinh towardzero binary64 -0x6.dfbeap-4 : -0x7.1661a2f837414p-4 : inexact-ok += sinh upward binary64 -0x6.dfbeap-4 : -0x7.1661a2f837414p-4 : inexact-ok += sinh downward intel96 -0x6.dfbeap-4 : -0x7.1661a2f837416e98p-4 : inexact-ok += sinh tonearest intel96 -0x6.dfbeap-4 : -0x7.1661a2f837416e9p-4 : inexact-ok += sinh towardzero intel96 -0x6.dfbeap-4 : -0x7.1661a2f837416e9p-4 : inexact-ok += sinh upward intel96 -0x6.dfbeap-4 : -0x7.1661a2f837416e9p-4 : inexact-ok += sinh downward m68k96 -0x6.dfbeap-4 : -0x7.1661a2f837416e98p-4 : inexact-ok += sinh tonearest m68k96 -0x6.dfbeap-4 : -0x7.1661a2f837416e9p-4 : inexact-ok += sinh towardzero m68k96 -0x6.dfbeap-4 : -0x7.1661a2f837416e9p-4 : inexact-ok += sinh upward m68k96 -0x6.dfbeap-4 : -0x7.1661a2f837416e9p-4 : inexact-ok += sinh downward binary128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d4ccp-4 : inexact-ok += sinh tonearest binary128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d4c8p-4 : inexact-ok += sinh towardzero binary128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d4c8p-4 : inexact-ok += sinh upward binary128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d4c8p-4 : inexact-ok += sinh downward ibm128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d6p-4 : inexact-ok += sinh tonearest ibm128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d4p-4 : inexact-ok += sinh towardzero ibm128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d4p-4 : inexact-ok += sinh upward ibm128 -0x6.dfbeap-4 : -0x7.1661a2f837416e909121ab55d4p-4 : inexact-ok += sinh downward binary32 -0x6.dfbea8p-4 : -0x7.1661bp-4 : inexact-ok += sinh tonearest binary32 -0x6.dfbea8p-4 : -0x7.1661a8p-4 : inexact-ok += sinh towardzero binary32 -0x6.dfbea8p-4 : -0x7.1661a8p-4 : inexact-ok += sinh upward binary32 -0x6.dfbea8p-4 : -0x7.1661a8p-4 : inexact-ok += sinh downward binary64 -0x6.dfbea8p-4 : -0x7.1661abb8260e8p-4 : inexact-ok += sinh tonearest binary64 -0x6.dfbea8p-4 : -0x7.1661abb8260e8p-4 : inexact-ok += sinh towardzero binary64 -0x6.dfbea8p-4 : -0x7.1661abb8260e4p-4 : inexact-ok += sinh upward binary64 -0x6.dfbea8p-4 : -0x7.1661abb8260e4p-4 : inexact-ok += sinh downward intel96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76bp-4 : inexact-ok += sinh tonearest intel96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a8p-4 : inexact-ok += sinh towardzero intel96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a8p-4 : inexact-ok += sinh upward intel96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a8p-4 : inexact-ok += sinh downward m68k96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76bp-4 : inexact-ok += sinh tonearest m68k96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a8p-4 : inexact-ok += sinh towardzero m68k96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a8p-4 : inexact-ok += sinh upward m68k96 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a8p-4 : inexact-ok += sinh downward binary128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ebed8p-4 : inexact-ok += sinh tonearest binary128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ebed8p-4 : inexact-ok += sinh towardzero binary128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ebed4p-4 : inexact-ok += sinh upward binary128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ebed4p-4 : inexact-ok += sinh downward ibm128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ecp-4 : inexact-ok += sinh tonearest ibm128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ebep-4 : inexact-ok += sinh towardzero ibm128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ebep-4 : inexact-ok += sinh upward ibm128 -0x6.dfbea8p-4 : -0x7.1661abb8260e76a92049555ebep-4 : inexact-ok += sinh downward binary64 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20cp-4 : inexact-ok += sinh tonearest binary64 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20cp-4 : inexact-ok += sinh towardzero binary64 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed208p-4 : inexact-ok += sinh upward binary64 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed208p-4 : inexact-ok += sinh downward intel96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20cp-4 : inexact-ok += sinh tonearest intel96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20cp-4 : inexact-ok += sinh towardzero intel96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh upward intel96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh downward m68k96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20cp-4 : inexact-ok += sinh tonearest m68k96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20cp-4 : inexact-ok += sinh towardzero m68k96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh upward m68k96 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bff8p-4 : inexact-ok += sinh downward binary128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffeb48p-4 : inexact-ok += sinh tonearest binary128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffeb48p-4 : inexact-ok += sinh towardzero binary128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffeb44p-4 : inexact-ok += sinh upward binary128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffeb44p-4 : inexact-ok += sinh downward ibm128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffecp-4 : inexact-ok += sinh tonearest ibm128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffecp-4 : inexact-ok += sinh towardzero ibm128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffeap-4 : inexact-ok += sinh upward ibm128 -0x6.dfbea46457254p-4 : -0x7.1661a7c5ed20bfffffffffffeap-4 : inexact-ok +sinh 0x1.92a5c27afbe82p+4 += sinh downward binary32 0x1.92a5c4p+4 : 0x9.e410bp+32 : inexact-ok += sinh tonearest binary32 0x1.92a5c4p+4 : 0x9.e410cp+32 : inexact-ok += sinh towardzero binary32 0x1.92a5c4p+4 : 0x9.e410bp+32 : inexact-ok += sinh upward binary32 0x1.92a5c4p+4 : 0x9.e410cp+32 : inexact-ok += sinh downward binary64 0x1.92a5c4p+4 : 0x9.e410bd8d8c85p+32 : inexact-ok += sinh tonearest binary64 0x1.92a5c4p+4 : 0x9.e410bd8d8c85p+32 : inexact-ok += sinh towardzero binary64 0x1.92a5c4p+4 : 0x9.e410bd8d8c85p+32 : inexact-ok += sinh upward binary64 0x1.92a5c4p+4 : 0x9.e410bd8d8c858p+32 : inexact-ok += sinh downward intel96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh tonearest intel96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh towardzero intel96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh upward intel96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh downward m68k96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh tonearest m68k96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh towardzero m68k96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh upward m68k96 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh downward binary128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60e85p+32 : inexact-ok += sinh tonearest binary128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60e858p+32 : inexact-ok += sinh towardzero binary128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60e85p+32 : inexact-ok += sinh upward binary128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60e858p+32 : inexact-ok += sinh downward ibm128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60e8p+32 : inexact-ok += sinh tonearest ibm128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60e8p+32 : inexact-ok += sinh towardzero ibm128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60e8p+32 : inexact-ok += sinh upward ibm128 0x1.92a5c4p+4 : 0x9.e410bd8d8c8507a830e34d60ecp+32 : inexact-ok += sinh downward binary32 0x1.92a5c2p+4 : 0x9.e40f8p+32 : inexact-ok += sinh tonearest binary32 0x1.92a5c2p+4 : 0x9.e40f8p+32 : inexact-ok += sinh towardzero binary32 0x1.92a5c2p+4 : 0x9.e40f8p+32 : inexact-ok += sinh upward binary32 0x1.92a5c2p+4 : 0x9.e40f9p+32 : inexact-ok += sinh downward binary64 0x1.92a5c2p+4 : 0x9.e40f810b889bp+32 : inexact-ok += sinh tonearest binary64 0x1.92a5c2p+4 : 0x9.e40f810b889b8p+32 : inexact-ok += sinh towardzero binary64 0x1.92a5c2p+4 : 0x9.e40f810b889bp+32 : inexact-ok += sinh upward binary64 0x1.92a5c2p+4 : 0x9.e40f810b889b8p+32 : inexact-ok += sinh downward intel96 0x1.92a5c2p+4 : 0x9.e40f810b889b76bp+32 : inexact-ok += sinh tonearest intel96 0x1.92a5c2p+4 : 0x9.e40f810b889b76cp+32 : inexact-ok += sinh towardzero intel96 0x1.92a5c2p+4 : 0x9.e40f810b889b76bp+32 : inexact-ok += sinh upward intel96 0x1.92a5c2p+4 : 0x9.e40f810b889b76cp+32 : inexact-ok += sinh downward m68k96 0x1.92a5c2p+4 : 0x9.e40f810b889b76bp+32 : inexact-ok += sinh tonearest m68k96 0x1.92a5c2p+4 : 0x9.e40f810b889b76cp+32 : inexact-ok += sinh towardzero m68k96 0x1.92a5c2p+4 : 0x9.e40f810b889b76bp+32 : inexact-ok += sinh upward m68k96 0x1.92a5c2p+4 : 0x9.e40f810b889b76cp+32 : inexact-ok += sinh downward binary128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa46p+32 : inexact-ok += sinh tonearest binary128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa46p+32 : inexact-ok += sinh towardzero binary128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa46p+32 : inexact-ok += sinh upward binary128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa468p+32 : inexact-ok += sinh downward ibm128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa4p+32 : inexact-ok += sinh tonearest ibm128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa4p+32 : inexact-ok += sinh towardzero ibm128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa4p+32 : inexact-ok += sinh upward ibm128 0x1.92a5c2p+4 : 0x9.e40f810b889b76bfa9a8c69fa8p+32 : inexact-ok += sinh downward binary64 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh tonearest binary64 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh towardzero binary64 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh upward binary64 0x1.92a5c27afbe82p+4 : 0x9.e40fcd12392ap+32 : inexact-ok += sinh downward intel96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh tonearest intel96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh towardzero intel96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh upward intel96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd123929801p+32 : inexact-ok += sinh downward m68k96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh tonearest m68k96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh towardzero m68k96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298p+32 : inexact-ok += sinh upward m68k96 0x1.92a5c27afbe82p+4 : 0x9.e40fcd123929801p+32 : inexact-ok += sinh downward binary128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298000000000002118p+32 : inexact-ok += sinh tonearest binary128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd123929800000000000212p+32 : inexact-ok += sinh towardzero binary128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298000000000002118p+32 : inexact-ok += sinh upward binary128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd123929800000000000212p+32 : inexact-ok += sinh downward ibm128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298000000000002p+32 : inexact-ok += sinh tonearest ibm128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298000000000002p+32 : inexact-ok += sinh towardzero ibm128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd1239298000000000002p+32 : inexact-ok += sinh upward ibm128 0x1.92a5c27afbe82p+4 : 0x9.e40fcd12392980000000000024p+32 : inexact-ok +sinh -0x1.92a5c27afbe82p+4 += sinh downward binary32 -0x1.92a5c2p+4 : -0x9.e40f9p+32 : inexact-ok += sinh tonearest binary32 -0x1.92a5c2p+4 : -0x9.e40f8p+32 : inexact-ok += sinh towardzero binary32 -0x1.92a5c2p+4 : -0x9.e40f8p+32 : inexact-ok += sinh upward binary32 -0x1.92a5c2p+4 : -0x9.e40f8p+32 : inexact-ok += sinh downward binary64 -0x1.92a5c2p+4 : -0x9.e40f810b889b8p+32 : inexact-ok += sinh tonearest binary64 -0x1.92a5c2p+4 : -0x9.e40f810b889b8p+32 : inexact-ok += sinh towardzero binary64 -0x1.92a5c2p+4 : -0x9.e40f810b889bp+32 : inexact-ok += sinh upward binary64 -0x1.92a5c2p+4 : -0x9.e40f810b889bp+32 : inexact-ok += sinh downward intel96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76cp+32 : inexact-ok += sinh tonearest intel96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76cp+32 : inexact-ok += sinh towardzero intel96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bp+32 : inexact-ok += sinh upward intel96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bp+32 : inexact-ok += sinh downward m68k96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76cp+32 : inexact-ok += sinh tonearest m68k96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76cp+32 : inexact-ok += sinh towardzero m68k96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bp+32 : inexact-ok += sinh upward m68k96 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bp+32 : inexact-ok += sinh downward binary128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa468p+32 : inexact-ok += sinh tonearest binary128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa46p+32 : inexact-ok += sinh towardzero binary128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa46p+32 : inexact-ok += sinh upward binary128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa46p+32 : inexact-ok += sinh downward ibm128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa8p+32 : inexact-ok += sinh tonearest ibm128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa4p+32 : inexact-ok += sinh towardzero ibm128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa4p+32 : inexact-ok += sinh upward ibm128 -0x1.92a5c2p+4 : -0x9.e40f810b889b76bfa9a8c69fa4p+32 : inexact-ok += sinh downward binary32 -0x1.92a5c4p+4 : -0x9.e410cp+32 : inexact-ok += sinh tonearest binary32 -0x1.92a5c4p+4 : -0x9.e410cp+32 : inexact-ok += sinh towardzero binary32 -0x1.92a5c4p+4 : -0x9.e410bp+32 : inexact-ok += sinh upward binary32 -0x1.92a5c4p+4 : -0x9.e410bp+32 : inexact-ok += sinh downward binary64 -0x1.92a5c4p+4 : -0x9.e410bd8d8c858p+32 : inexact-ok += sinh tonearest binary64 -0x1.92a5c4p+4 : -0x9.e410bd8d8c85p+32 : inexact-ok += sinh towardzero binary64 -0x1.92a5c4p+4 : -0x9.e410bd8d8c85p+32 : inexact-ok += sinh upward binary64 -0x1.92a5c4p+4 : -0x9.e410bd8d8c85p+32 : inexact-ok += sinh downward intel96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh tonearest intel96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh towardzero intel96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh upward intel96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh downward m68k96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh tonearest m68k96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507bp+32 : inexact-ok += sinh towardzero m68k96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh upward m68k96 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507ap+32 : inexact-ok += sinh downward binary128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60e858p+32 : inexact-ok += sinh tonearest binary128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60e858p+32 : inexact-ok += sinh towardzero binary128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60e85p+32 : inexact-ok += sinh upward binary128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60e85p+32 : inexact-ok += sinh downward ibm128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60ecp+32 : inexact-ok += sinh tonearest ibm128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60e8p+32 : inexact-ok += sinh towardzero ibm128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60e8p+32 : inexact-ok += sinh upward ibm128 -0x1.92a5c4p+4 : -0x9.e410bd8d8c8507a830e34d60e8p+32 : inexact-ok += sinh downward binary64 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd12392ap+32 : inexact-ok += sinh tonearest binary64 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh towardzero binary64 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh upward binary64 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh downward intel96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd123929801p+32 : inexact-ok += sinh tonearest intel96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh towardzero intel96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh upward intel96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh downward m68k96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd123929801p+32 : inexact-ok += sinh tonearest m68k96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh towardzero m68k96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh upward m68k96 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298p+32 : inexact-ok += sinh downward binary128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd123929800000000000212p+32 : inexact-ok += sinh tonearest binary128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd123929800000000000212p+32 : inexact-ok += sinh towardzero binary128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298000000000002118p+32 : inexact-ok += sinh upward binary128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298000000000002118p+32 : inexact-ok += sinh downward ibm128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd12392980000000000024p+32 : inexact-ok += sinh tonearest ibm128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298000000000002p+32 : inexact-ok += sinh towardzero ibm128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298000000000002p+32 : inexact-ok += sinh upward ibm128 -0x1.92a5c27afbe82p+4 : -0x9.e40fcd1239298000000000002p+32 : inexact-ok diff --git a/misc/tsearch.c b/misc/tsearch.c index 9b2eb34b25..e517dfa712 100644 --- a/misc/tsearch.c +++ b/misc/tsearch.c @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include @@ -406,12 +407,13 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) int cmp; node *rootp = (node *) vrootp; node root, unchained; - /* Stack of nodes so we remember the parents without recursion. It's - _very_ unlikely that there are paths longer than 40 nodes. The tree - would need to have around 250.000 nodes. */ - int stacksize = 40; + /* Stack of nodes so we remember the parents without recursion. The + stack size is a conservative approximation of the maximum height + of a red-black tree, based on size of the address space. + Actual numbers are closer to 57 (32 bit) and 117 (63 bit). */ + enum { stacksize = 2 * UINTPTR_WIDTH }; int sp = 0; - node **nodestack = alloca (sizeof (node *) * stacksize); + node *nodestack[stacksize]; if (rootp == NULL) return NULL; @@ -424,14 +426,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) root = DEREFNODEPTR(rootp); while ((cmp = (*compar) (key, root->key)) != 0) { - if (sp == stacksize) - { - node **newstack; - stacksize += 20; - newstack = alloca (sizeof (node *) * stacksize); - nodestack = memcpy (newstack, nodestack, sp * sizeof (node *)); - } - + assert (sp < stacksize); nodestack[sp++] = rootp; p = DEREFNODEPTR(rootp); if (cmp < 0) @@ -470,13 +465,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) node upn; for (;;) { - if (sp == stacksize) - { - node **newstack; - stacksize += 20; - newstack = alloca (sizeof (node *) * stacksize); - nodestack = memcpy (newstack, nodestack, sp * sizeof (node *)); - } + assert (sp < stacksize); nodestack[sp++] = parentp; parentp = up; upn = DEREFNODEPTR(up); @@ -541,6 +530,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) SETNODEPTR(pp,q); /* Make sure pp is right if the case below tries to use it. */ + assert (sp < stacksize); nodestack[sp++] = pp = LEFTPTR(q); q = RIGHT(p); } @@ -625,6 +615,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) SETLEFT(p,RIGHT(q)); SETRIGHT(q,p); SETNODEPTR(pp,q); + assert (sp < stacksize); nodestack[sp++] = pp = RIGHTPTR(q); q = LEFT(p); } diff --git a/nptl/cancellation.c b/nptl/cancellation.c index 4368cb7231..63f09840ff 100644 --- a/nptl/cancellation.c +++ b/nptl/cancellation.c @@ -19,66 +19,6 @@ #include #include "pthreadP.h" -/* Called by the INTERNAL_SYSCALL_CANCEL macro, check for cancellation and - returns the syscall value or its negative error code. */ -long int -__internal_syscall_cancel (__syscall_arg_t a1, __syscall_arg_t a2, - __syscall_arg_t a3, __syscall_arg_t a4, - __syscall_arg_t a5, __syscall_arg_t a6, - __SYSCALL_CANCEL7_ARG_DEF - __syscall_arg_t nr) -{ - long int result; - struct pthread *pd = THREAD_SELF; - - /* If cancellation is not enabled, call the syscall directly and also - for thread terminatation to avoid call __syscall_do_cancel while - executing cleanup handlers. */ - int ch = atomic_load_relaxed (&pd->cancelhandling); - if (SINGLE_THREAD_P || !cancel_enabled (ch) || cancel_exiting (ch)) - { - result = INTERNAL_SYSCALL_NCS_CALL (nr, a1, a2, a3, a4, a5, a6 - __SYSCALL_CANCEL7_ARCH_ARG7); - if (INTERNAL_SYSCALL_ERROR_P (result)) - return -INTERNAL_SYSCALL_ERRNO (result); - return result; - } - - /* Call the arch-specific entry points that contains the globals markers - to be checked by SIGCANCEL handler. */ - result = __syscall_cancel_arch (&pd->cancelhandling, nr, a1, a2, a3, a4, a5, - a6 __SYSCALL_CANCEL7_ARCH_ARG7); - - /* If the cancellable syscall was interrupted by SIGCANCEL and it has no - side-effect, cancel the thread if cancellation is enabled. */ - ch = atomic_load_relaxed (&pd->cancelhandling); - /* The behaviour here assumes that EINTR is returned only if there are no - visible side effects. POSIX Issue 7 has not yet provided any stronger - language for close, and in theory the close syscall could return EINTR - and leave the file descriptor open (conforming and leaks). It expects - that no such kernel is used with glibc. */ - if (result == -EINTR && cancel_enabled_and_canceled (ch)) - __syscall_do_cancel (); - - return result; -} - -/* Called by the SYSCALL_CANCEL macro, check for cancellation and return the - syscall expected success value (usually 0) or, in case of failure, -1 and - sets errno to syscall return value. */ -long int -__syscall_cancel (__syscall_arg_t a1, __syscall_arg_t a2, - __syscall_arg_t a3, __syscall_arg_t a4, - __syscall_arg_t a5, __syscall_arg_t a6, - __SYSCALL_CANCEL7_ARG_DEF __syscall_arg_t nr) -{ - long int r = __internal_syscall_cancel (a1, a2, a3, a4, a5, a6, - __SYSCALL_CANCEL7_ARG nr); - return __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r)) - ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (r)) - : r; -} - /* Called by __syscall_cancel_arch or function above start the thread cancellation. */ _Noreturn void diff --git a/nptl/futex-internal.c b/nptl/futex-internal.c index fc6b11c8ad..07f1462abe 100644 --- a/nptl/futex-internal.c +++ b/nptl/futex-internal.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #include #include #include diff --git a/nptl/sem_waitcommon.c b/nptl/sem_waitcommon.c index b0cbe5cebf..82c686f020 100644 --- a/nptl/sem_waitcommon.c +++ b/nptl/sem_waitcommon.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include diff --git a/nscd/aicache.c b/nscd/aicache.c index ef15c373f5..d87e7e966f 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -102,7 +102,9 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, int32_t ttl = INT32_MAX; ssize_t total = 0; char *key_copy = NULL; - bool alloca_used = false; + /* If not NULL, dataset is a temporary dataset not inserted into the + database, and needs to be free'd. */ + void *dataset_alloc = NULL; time_t timeout = MAX_TIMEOUT_VALUE; while (!no_more) @@ -173,10 +175,12 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, /* We cannot permanently add the result in the moment. But we can provide the result as is. Store the data in some temporary memory. */ - dataset = (struct dataset *) alloca (total + req->key_len); + dataset = (struct dataset *) malloc (total + req->key_len); + if (dataset == NULL) + goto out; /* We cannot add this record to the permanent database. */ - alloca_used = true; + dataset_alloc = dataset; } /* Fill in the address and address families. */ @@ -345,10 +349,12 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, /* We cannot permanently add the result in the moment. But we can provide the result as is. Store the data in some temporary memory. */ - dataset = (struct dataset *) alloca (total + req->key_len); + dataset = (struct dataset *) malloc (total + req->key_len); + if (dataset == NULL) + goto out; /* We cannot add this record to the permanent database. */ - alloca_used = true; + dataset_alloc = dataset; } /* Fill in the address and address families. */ @@ -400,8 +406,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, resp)) == 0) { /* The data has not changed. We will just bump the - timeout value. Note that the new record has been - allocated on the stack and need not be freed. */ + timeout value. */ dh->timeout = dataset->head.timeout; dh->ttl = dataset->head.ttl; ++dh->nreloads; @@ -419,7 +424,9 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, key_copy = (char *) newp + (key_copy - (char *) dataset); dataset = memcpy (newp, dataset, total + req->key_len); - alloca_used = false; + + free (dataset_alloc); + dataset_alloc = NULL; } /* Mark the old record as obsolete. */ @@ -502,7 +509,7 @@ next_nip: out: __resolv_context_put (ctx); - if (dataset != NULL && !alloca_used) + if (dataset != NULL && dataset_alloc == NULL) { /* If necessary, we also propagate the data to disk. */ if (db->persistent) @@ -528,6 +535,8 @@ next_nip: scratch_buffer_free (&tmpbuf4); scratch_buffer_free (&canonbuf); + free (dataset_alloc); + return timeout; } diff --git a/nscd/hstcache.c b/nscd/hstcache.c index fe91818640..44ef80be77 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . */ -#include #include #include #include @@ -188,7 +187,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, /* Determine the I/O structure. */ size_t h_name_len = strlen (hst->h_name) + 1; size_t h_aliases_cnt; - uint32_t *h_aliases_len; + uint32_t *h_aliases_len = NULL; size_t h_addr_list_cnt; char *addresses; char *aliases; @@ -202,7 +201,13 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, for (cnt = 0; hst->h_aliases[cnt] != NULL; ++cnt) ++h_aliases_cnt; /* Determine the length of all aliases. */ - h_aliases_len = (uint32_t *) alloca (h_aliases_cnt * sizeof (uint32_t)); + if (h_aliases_cnt > 0) + { + h_aliases_len = (uint32_t *) reallocarray (NULL, h_aliases_cnt, + sizeof (uint32_t)); + if (h_aliases_len == NULL) + return MAX_TIMEOUT_VALUE; + } total = 0; for (cnt = 0; cnt < h_aliases_cnt; ++cnt) { @@ -216,8 +221,11 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, ++h_addr_list_cnt; if (h_addr_list_cnt == 0) - /* Invalid entry. */ - return MAX_TIMEOUT_VALUE; + { + /* Invalid entry. */ + free (h_aliases_len); + return MAX_TIMEOUT_VALUE; + } total += (sizeof (struct dataset) + h_name_len @@ -228,8 +236,10 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, change. Allocate memory on the cache since it is likely discarded anyway. If it turns out to be necessary to have a new record we can still allocate real memory. */ - bool alloca_used = false; dataset = NULL; + /* If not NULL, dataset is a temporary dataset not inserted into + the database, and needs to be free'd. */ + void *dataset_alloc = NULL; /* If the record contains more than one IP address (used for load balancing etc) don't cache the entry. This is something @@ -245,10 +255,15 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, /* We cannot permanently add the result in the moment. But we can provide the result as is. Store the data in some temporary memory. */ - dataset = (struct dataset *) alloca (total + req->key_len); + dataset = (struct dataset *) malloc (total + req->key_len); + if (dataset == NULL) + { + free (h_aliases_len); + return MAX_TIMEOUT_VALUE; + } /* We cannot add this record to the permanent database. */ - alloca_used = true; + dataset_alloc = dataset; } timeout = datahead_init_pos (&dataset->head, total + req->key_len, @@ -271,7 +286,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, cp = dataset->strdata; cp = mempcpy (cp, hst->h_name, h_name_len); - cp = mempcpy (cp, h_aliases_len, h_aliases_cnt * sizeof (uint32_t)); + if (h_aliases_cnt > 0) + cp = mempcpy (cp, h_aliases_len, h_aliases_cnt * sizeof (uint32_t)); /* The normal addresses first. */ addresses = cp; @@ -283,6 +299,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, for (cnt = 0; cnt < h_aliases_cnt; ++cnt) cp = mempcpy (cp, hst->h_aliases[cnt], h_aliases_len[cnt]); + free (h_aliases_len); + assert (cp == dataset->strdata + total - offsetof (struct dataset, strdata)); @@ -308,8 +326,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, dh->allocsize - offsetof (struct dataset, resp)) == 0) { /* The data has not changed. We will just bump the - timeout value. Note that the new record has been - allocated on the stack and need not be freed. */ + timeout value. */ assert (h_addr_list_cnt == 1); dh->ttl = dataset->head.ttl; dh->timeout = dataset->head.timeout; @@ -335,7 +352,9 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, key_copy = (char *) newp + (key_copy - (char *) dataset); dataset = memcpy (newp, dataset, total + req->key_len); - alloca_used = false; + + free (dataset_alloc); + dataset_alloc = NULL; } } @@ -363,7 +382,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, the current cache handling cannot handle and it is more than questionable whether it is worthwhile complicating the cache handling just for handling such a special case. */ - if (! alloca_used) + if (dataset_alloc == NULL) { /* If necessary, we also propagate the data to disk. */ if (db->persistent) @@ -394,6 +413,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, pthread_rwlock_unlock (&db->lock); } + free (dataset_alloc); + dataset_alloc = NULL; } if (__builtin_expect (!all_written, 0) && debug_level > 0) diff --git a/posix/Makefile b/posix/Makefile index 10d70ae0ae..7478cc2174 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -316,7 +316,6 @@ tests := \ tst-rxspencer-no-utf8 \ tst-sched_getaffinity \ tst-spawn-chdir \ - tst-spawn-chdir-posix \ tst-spawn4 \ tst-spawn5 \ tst-spawn6 \ diff --git a/posix/spawn.h b/posix/spawn.h index 0aabf5ebef..5e68752a66 100644 --- a/posix/spawn.h +++ b/posix/spawn.h @@ -200,26 +200,6 @@ extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t * int __fd, int __newfd) __THROW __nonnull ((1)); -#ifdef __USE_XOPEN2K24XSI - -/* Add an action changing the directory to PATH during spawn. This - affects the subsequent file actions. - Alias of posix_spawn_file_actions_addchdir_np. */ -extern int __REDIRECT_NTH (posix_spawn_file_actions_addchdir, - (posix_spawn_file_actions_t * __restrict __actions, - const char *__restrict __path), - posix_spawn_file_actions_addchdir_np); - -/* Add an action changing the directory to FD during spawn. This - affects the subsequent file actions. FD is not duplicated and must - be open when the file action is executed. - Alias of posix_spawn_file_actions_addfchdir_np. */ -extern int __REDIRECT_NTH (posix_spawn_file_actions_addfchdir, - (posix_spawn_file_actions_t *, int __fd), - posix_spawn_file_actions_addfchdir_np); - -#endif /* __USE_XOPEN2K24XSI */ - #ifdef __USE_MISC /* Add an action changing the directory to PATH during spawn. This affects the subsequent file actions. */ diff --git a/posix/tst-spawn-chdir-posix.c b/posix/tst-spawn-chdir-posix.c deleted file mode 100644 index 3f8d8952bb..0000000000 --- a/posix/tst-spawn-chdir-posix.c +++ /dev/null @@ -1,2 +0,0 @@ -#define USE_POSIX_ALIASES -#include "tst-spawn-chdir.c" diff --git a/posix/tst-spawn-chdir.c b/posix/tst-spawn-chdir.c index 166f835492..a3478d61f6 100644 --- a/posix/tst-spawn-chdir.c +++ b/posix/tst-spawn-chdir.c @@ -78,25 +78,12 @@ add_chdir (posix_spawn_file_actions_t *actions, const char *path, { TEST_COMPARE (posix_spawn_file_actions_addopen (actions, tmpfd, path, O_DIRECTORY | O_RDONLY, 0), 0); - -#ifdef USE_POSIX_ALIASES - int ret = posix_spawn_file_actions_addfchdir (actions, tmpfd); -#else - int ret = posix_spawn_file_actions_addfchdir_np (actions, tmpfd); -#endif - TEST_COMPARE (ret, 0); - + TEST_COMPARE (posix_spawn_file_actions_addfchdir_np + (actions, tmpfd), 0); TEST_COMPARE (posix_spawn_file_actions_addclose (actions, tmpfd), 0); } else - { -#ifdef USE_POSIX_ALIASES - int ret = posix_spawn_file_actions_addchdir (actions, path); -#else - int ret = posix_spawn_file_actions_addchdir_np (actions, path); -#endif - TEST_COMPARE (ret, 0); - } + TEST_COMPARE (posix_spawn_file_actions_addchdir_np (actions, path), 0); } static int diff --git a/posix/unistd.h b/posix/unistd.h index 06a6a88b52..dc5c2ec009 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -307,7 +307,7 @@ extern int execveat (int __fd, const char *__path, char *const __argv[], If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess', otherwise use real IDs like `access'. */ extern int faccessat (int __fd, const char *__file, int __type, int __flag) - __THROW __nonnull ((2)) __wur; + __THROW __wur; #endif /* Use GNU. */ @@ -510,7 +510,7 @@ extern int lchown (const char *__file, __uid_t __owner, __gid_t __group) on. */ extern int fchownat (int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag) - __THROW __nonnull ((2)) __wur; + __THROW __wur; #endif /* Use GNU. */ /* Change the process's working directory to PATH. */ diff --git a/posix/wordexp.c b/posix/wordexp.c index 8fdc8b8caf..9a49e102ee 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -35,7 +35,6 @@ #include #include <_itoa.h> #include -#include /* * This is a recursive-descent-style word expansion routine. @@ -2269,16 +2268,14 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags) { /* WRDE_APPEND with an existing word list: duplicate the array so that realloc during parsing does not invalidate the caller's pointer. The - strings themselves are shared. */ - size_t num_p; - char **dup; - if (INT_ADD_WRAPV (pwordexp->we_offs, pwordexp->we_wordc, &num_p) - || INT_ADD_WRAPV (num_p, 1, &num_p)) - return WRDE_NOSPACE; - dup = __libc_reallocarray (NULL, num_p, sizeof *dup); + strings themselves are shared an the array already holds + 'we_offs + we_wordc + 1 pointers' (so the size computation cannot + overflow). */ + size_t num_p = pwordexp->we_offs + pwordexp->we_wordc + 1; + char **dup = malloc (num_p * sizeof (char *)); if (dup == NULL) return WRDE_NOSPACE; - memcpy (dup, pwordexp->we_wordv, num_p * sizeof *dup); + memcpy (dup, pwordexp->we_wordv, num_p * sizeof (char *)); saved_wordv = pwordexp->we_wordv; pwordexp->we_wordv = dup; } diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c index d33f32ac1a..a688d4223b 100644 --- a/resolv/resolv_conf.c +++ b/resolv/resolv_conf.c @@ -281,8 +281,12 @@ resolv_conf_matches (const struct __res_state *resp, { if (resp->dnsrch[0] == NULL) { - /* Empty search list. No default domain name. */ - return conf->search_list_size == 0 && resp->defdname[0] == '\0'; + /* Empty search list, or the first entry does not fit in + resp->defdname. No default domain name. */ + return resp->defdname[0] == '\0' + && (conf->search_list_size == 0 + || (strlen (conf->search_list[0]) + 1 + > sizeof (resp->defdname))); } if (resp->dnsrch[0] != resp->defdname) @@ -309,11 +313,12 @@ resolv_conf_matches (const struct __res_state *resp, } else { - /* resp->dnsrch is truncated if the number of elements - exceeds MAXDNSRCH, or if the combined storage space for - the search list exceeds what can be stored in - resp->defdname. */ - if (i == MAXDNSRCH || search_list_size > sizeof (resp->dnsrch)) + /* resp->dnsrch is truncated if the number of elements exceeds + MAXDNSRCH, or if conf->search_list[i] does not fit in the + remaining space of resp->defdname. */ + if (i == MAXDNSRCH + || (search_list_size + strlen (conf->search_list[i]) + 1 + > sizeof (resp->defdname))) break; /* Otherwise, a mismatch indicates a match failure. */ return false; diff --git a/resolv/tst-resolv-res_init-skeleton.c b/resolv/tst-resolv-res_init-skeleton.c index 1e4c59dac9..e51a532c7e 100644 --- a/resolv/tst-resolv-res_init-skeleton.c +++ b/resolv/tst-resolv-res_init-skeleton.c @@ -724,6 +724,41 @@ struct test_case test_cases[] = "nameserver 192.0.2.1\n" "; nameserver[0]: [192.0.2.1]:53\n" }, +/* Search list entries which do not fit in the legacy 256-byte + resp->defdname buffer (bug 31026). LONG244 is 244 characters long, + so it does not fit after "example.com\0" (12 bytes). LONG256 is 256 + characters long, so it does not fit even as the first entry. */ +#define LBL63 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +#define LONG244 LBL63 "." LBL63 "." LBL63 "." \ + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +#define LONG256 LBL63 "." LBL63 "." LBL63 "." LBL63 "a" + {.name = "search list truncated at long entry after short entry", + .conf = "nameserver 192.0.2.1\n" + "search example.com " LONG244 "\n", + .expected = "search example.com\n" + "; search[0]: example.com\n" + "; search[1]: " LONG244 "\n" + "nameserver 192.0.2.1\n" + "; nameserver[0]: [192.0.2.1]:53\n" + }, + {.name = "search list truncated at long first entry", + .conf = "nameserver 192.0.2.1\n" + "search " LONG256 " example.com\n", + .expected = "; search[0]: " LONG256 "\n" + "; search[1]: example.com\n" + "nameserver 192.0.2.1\n" + "; nameserver[0]: [192.0.2.1]:53\n" + }, + {.name = "long first entry from the domain directive", + .conf = "nameserver 192.0.2.1\n" + "domain " LONG256 "\n", + .expected = "; search[0]: " LONG256 "\n" + "nameserver 192.0.2.1\n" + "; nameserver[0]: [192.0.2.1]:53\n" + }, +#undef LONG256 +#undef LONG244 +#undef LBL63 {.name = "trust-ad flag", .conf = "options trust-ad\n" "nameserver 192.0.2.1\n", diff --git a/scripts/check-symbol-version.awk b/scripts/check-symbol-version.awk new file mode 100644 index 0000000000..2ddaa0edc9 --- /dev/null +++ b/scripts/check-symbol-version.awk @@ -0,0 +1,67 @@ +# Copyright (C) 2026 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# . + +# This awk script expects to get command-line files that are each +# the output of 'readelf -W --dyn-syms' on a single shared object. +# It exits successfully (0) if there are versioned symbols with more +# than one default version in dynamic symbol table. +# It fails (1) if any did contain versioned symbols with more than one +# default version in dynamic symbol table. +# It fails (2) if the input did not take the expected form. + +BEGIN { result = incorrect = sanity = 0 } + +function check_one(name) { + if (!sanity) { + print name ": *** input did not look like readelf -d output"; + result = 2; + } else { + ok = 1; + if (incorrect) { + print name ": *** incorrect dynamic symbol table"; + result = result ? result : 1; + ok = 0; + } + if (ok) + print name ": OK"; + } + + delete version + incorrect = sanity = 0 +} + +FILENAME != lastfile { + if (lastfile) + check_one(lastfile); + lastfile = FILENAME; +} + +$1 == "Symbol" && $2 == "table" && $3 == "'.dynsym'" { sanity = 1 } +$8 ~ "@@" { + split($8,a,"@"); + if (version[a[1]] != "") { + incorrect = 1; + print a[1] " has 2 default versions: " version[a[1]] ", " a[3]; + } else { + version[a[1]] = a[3]; + } +} + +END { + check_one(lastfile); + exit(result); +} diff --git a/stdio-common/tst-printf-format-c.sh b/stdio-common/tst-printf-format-c.sh index 825c50ec42..73d28c5607 100644 --- a/stdio-common/tst-printf-format-c.sh +++ b/stdio-common/tst-printf-format-c.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" echo Verifying c (set -o pipefail diff --git a/stdio-common/tst-printf-format-char.sh b/stdio-common/tst-printf-format-char.sh index 7867bdd62f..aa4d211126 100644 --- a/stdio-common/tst-printf-format-char.sh +++ b/stdio-common/tst-printf-format-char.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=0 diff --git a/stdio-common/tst-printf-format-double.sh b/stdio-common/tst-printf-format-double.sh index 8157092dc4..051e4716c5 100644 --- a/stdio-common/tst-printf-format-double.sh +++ b/stdio-common/tst-printf-format-double.sh @@ -29,7 +29,7 @@ test_program_prefix=$1; shift # internally to process the conversion requested, so any bug in our code # would then be verified against itself, defeating the objective of doing # the verification against an independent implementation. -AWK="${AWK:-awk} -M" +AWK="env LC_ALL=C ${AWK:-awk} -M" status=77 diff --git a/stdio-common/tst-printf-format-int.sh b/stdio-common/tst-printf-format-int.sh index 8542ff4150..e9dcbedc04 100644 --- a/stdio-common/tst-printf-format-int.sh +++ b/stdio-common/tst-printf-format-int.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=77 diff --git a/stdio-common/tst-printf-format-ldouble.sh b/stdio-common/tst-printf-format-ldouble.sh index dbf78a98c6..7ee097ac0a 100644 --- a/stdio-common/tst-printf-format-ldouble.sh +++ b/stdio-common/tst-printf-format-ldouble.sh @@ -29,7 +29,7 @@ test_program_prefix=$1; shift # internally to process the conversion requested, so any bug in our code # would then be verified against itself, defeating the objective of doing # the verification against an independent implementation. -AWK="${AWK:-awk} -M" +AWK="env LC_ALL=C ${AWK:-awk} -M" status=77 diff --git a/stdio-common/tst-printf-format-llong.sh b/stdio-common/tst-printf-format-llong.sh index e1f5252c9a..98a79660cc 100644 --- a/stdio-common/tst-printf-format-llong.sh +++ b/stdio-common/tst-printf-format-llong.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=77 diff --git a/stdio-common/tst-printf-format-long.sh b/stdio-common/tst-printf-format-long.sh index 4b68ab1e04..89ac3302b8 100644 --- a/stdio-common/tst-printf-format-long.sh +++ b/stdio-common/tst-printf-format-long.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=77 diff --git a/stdio-common/tst-printf-format-s.sh b/stdio-common/tst-printf-format-s.sh index 65aa0cb675..015c730609 100644 --- a/stdio-common/tst-printf-format-s.sh +++ b/stdio-common/tst-printf-format-s.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" echo Verifying s (set -o pipefail diff --git a/stdio-common/tst-printf-format-short.sh b/stdio-common/tst-printf-format-short.sh index 30357baa02..a7df8b8e6d 100644 --- a/stdio-common/tst-printf-format-short.sh +++ b/stdio-common/tst-printf-format-short.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=0 diff --git a/stdio-common/tst-printf-format-uchar.sh b/stdio-common/tst-printf-format-uchar.sh index 08a6914b88..356de4217d 100644 --- a/stdio-common/tst-printf-format-uchar.sh +++ b/stdio-common/tst-printf-format-uchar.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=0 diff --git a/stdio-common/tst-printf-format-uint.sh b/stdio-common/tst-printf-format-uint.sh index 0ba203ccda..b496047a49 100644 --- a/stdio-common/tst-printf-format-uint.sh +++ b/stdio-common/tst-printf-format-uint.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=77 diff --git a/stdio-common/tst-printf-format-ullong.sh b/stdio-common/tst-printf-format-ullong.sh index 5b881ab924..f030f66a24 100644 --- a/stdio-common/tst-printf-format-ullong.sh +++ b/stdio-common/tst-printf-format-ullong.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=77 diff --git a/stdio-common/tst-printf-format-ulong.sh b/stdio-common/tst-printf-format-ulong.sh index f6aeb8e3c0..7102575ed2 100644 --- a/stdio-common/tst-printf-format-ulong.sh +++ b/stdio-common/tst-printf-format-ulong.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=77 diff --git a/stdio-common/tst-printf-format-ushort.sh b/stdio-common/tst-printf-format-ushort.sh index 07609128ab..5f612b5398 100644 --- a/stdio-common/tst-printf-format-ushort.sh +++ b/stdio-common/tst-printf-format-ushort.sh @@ -23,7 +23,7 @@ xprintf=$1; shift common_objpfx=$1; shift test_program_prefix=$1; shift -AWK=${AWK:-awk} +AWK="env LC_ALL=C ${AWK:-awk}" status=0 diff --git a/stdio-common/tst-printf-format.awk b/stdio-common/tst-printf-format.awk index 5d0324c551..57bea12621 100644 --- a/stdio-common/tst-printf-format.awk +++ b/stdio-common/tst-printf-format.awk @@ -32,6 +32,9 @@ BEGIN { # non-bignum mode unless a sign has been explicitly given. Keep # original 'val' for reporting. value = gensub(/^(INF|NAN|inf|nan)/, "+\\1", 1, val) + # Neither changes between the conversions applied to this value. + value_infnan = value ~ /(INF|NAN|inf|nan)/ + value_zero = value == 0 next } @@ -52,7 +55,7 @@ BEGIN { # Discard the '#' flag with the octal conversion if output starts with # 0 in the absence of this flag. In that case no extra 0 is supposed # to be produced, but gawk prepends it anyway. - if (format ~ /#.*o/) + if (index(format, "#") && format ~ /#.*o/) { tmpfmt = gensub(/#/, "", "g", format) tmpout = sprintf(tmpfmt, value) @@ -62,7 +65,7 @@ BEGIN { # Likewise with the hexadecimal conversion where zero value with the # precision of zero is supposed to produce no characters, but gawk # outputs 0 instead. - else if (format ~ /#.*[Xx]/) + else if (index(format, "#") && format ~ /#.*[Xx]/) { tmpfmt = gensub(/#/, "", "g", format) tmpout = sprintf(tmpfmt, value) @@ -78,7 +81,7 @@ BEGIN { # values and reprint the output produced using the string conversion, # with the field width carried over and the relevant flags handled by # hand. - if (format ~ /[EFGefg]/ && value ~ /(INF|NAN|inf|nan)/) + if (value_infnan && format ~ /[EFGefg]/) { minus = format ~ /-/ ? "-" : "" sign = value ~ /-/ ? "-" : format ~ /\+/ ? "+" : format ~ / / ? " " : "" @@ -94,7 +97,7 @@ BEGIN { # In that case "+" is always supposed to be produced, but with the # precision of zero gawk in the non-bignum mode produces any padding # requested only. - else if (format ~ /\+.*[di]/ && value == 0) + else if (value_zero && format ~ /\+.*[di]/) { output = gensub(/^( *) $/, format ~ /-/ ? "+\\1" : "\\1+", 1, output) output = gensub(/^$/, "+", 1, output) @@ -103,7 +106,7 @@ BEGIN { # conversion for zero value. In that case at least one " " is # supposed to be produced, but with the precision of zero gawk in the # non-bignum mode produces nothing. - else if (format ~ / .*[di]/ && value == 0) + else if (value_zero && format ~ / .*[di]/) { output = gensub(/^$/, " ", 1, output) } diff --git a/stdlib/Makefile b/stdlib/Makefile index addf7dc99f..16948eb512 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -347,6 +347,7 @@ tests := \ tst-stdc_leading_zeros \ tst-stdc_trailing_ones \ tst-stdc_trailing_zeros \ + tst-strfmon-bug34510 \ tst-strfmon_l \ tst-strfrom \ tst-strfrom-locale \ diff --git a/stdlib/setenv.c b/stdlib/setenv.c index 1f7a4498b0..cbf83f8f8e 100644 --- a/stdlib/setenv.c +++ b/stdlib/setenv.c @@ -384,9 +384,6 @@ clearenv (void) void __libc_setenv_freemem (void) { - /* Remove all traces. */ - clearenv (); - /* Clear all backing arrays. */ while (__environ_array_list != NULL) { diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c index f864289480..c39babaeae 100644 --- a/stdlib/strfmon_l.c +++ b/stdlib/strfmon_l.c @@ -549,7 +549,8 @@ __vstrfmon_l_buffer (struct __printf_buffer *buf, locale_t loc, /* Now test whether the output width is filled. */ if (buf->write_ptr - startp < width) { - size_t pad_width = width - (buf->write_ptr - startp); + size_t written_width = buf->write_ptr - startp; + size_t pad_width = width - written_width; __printf_buffer_pad (buf, ' ', pad_width); if (__printf_buffer_has_failed (buf)) /* Implies length check. */ @@ -558,7 +559,7 @@ __vstrfmon_l_buffer (struct __printf_buffer *buf, locale_t loc, Otherwise move the field contents in place. */ if (!left) { - memmove (startp + pad_width, startp, buf->write_ptr - startp); + memmove (startp + pad_width, startp, written_width); memset (startp, ' ', pad_width); } } diff --git a/stdlib/tst-strfmon-bug34510.c b/stdlib/tst-strfmon-bug34510.c new file mode 100644 index 0000000000..b187bde1f4 --- /dev/null +++ b/stdlib/tst-strfmon-bug34510.c @@ -0,0 +1,33 @@ +/* Test handling of right-padding in strfmon (bug 34510, CVE-2026-19499). + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +static int +do_test (void) +{ + struct support_next_to_fault ntf = support_next_to_fault_allocate (100); + TEST_COMPARE (strfmon (ntf.buffer, ntf.length, "%100n", 1.23), -1); + TEST_COMPARE (errno, E2BIG); + return 0; +} + +#include diff --git a/string/Makefile b/string/Makefile index aa0b0c2f57..bfda81daaa 100644 --- a/string/Makefile +++ b/string/Makefile @@ -244,8 +244,8 @@ endif # This test allocates a lot of memory and can run for a long time. xtests += tst-strcoll-overflow -# This test runs for a long time. -xtests += test-strncmp-nonarray +# These tests run for a long time. +xtests += test-strncasecmp-nonarray test-strncmp-nonarray # This test needs libdl. ifeq (yes,$(build-shared)) diff --git a/string/test-strcasecmp.c b/string/test-strcasecmp.c index a5235fa1bb..d090dcbf36 100644 --- a/string/test-strcasecmp.c +++ b/string/test-strcasecmp.c @@ -63,6 +63,9 @@ do_test (size_t align1, size_t align2, size_t len, int max_char, int exp_result) { size_t i; + size_t value = 0; + size_t step = 23U % (size_t) max_char; + size_t pattern_len; char *s1, *s2; if (len == 0) @@ -80,10 +83,25 @@ do_test (size_t align1, size_t align2, size_t len, int max_char, s1 = (char *) (buf1 + align1); s2 = (char *) (buf2 + align2); - for (i = 0; i < len; i++) + pattern_len + = len < (size_t) max_char ? len : (size_t) max_char; + + for (i = 0; i < pattern_len; i++) { - s1[i] = toupper (1 + 23 * i % max_char); + s1[i] = toupper (1 + value); s2[i] = tolower (s1[i]); + value += step; + if (value >= (size_t) max_char) + value -= max_char; + } + + while (i < len) + { + size_t copy = i < len - i ? i : len - i; + + memcpy (s1 + i, s1, copy); + memcpy (s2 + i, s2, copy); + i += copy; } s1[len] = s2[len] = 0; diff --git a/string/test-strcmp.c b/string/test-strcmp.c index 76ccff46e2..ca52827b11 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -156,6 +156,10 @@ do_test (size_t align1, size_t align2, size_t len, int max_char, int exp_result) { size_t i; + size_t value = 0; + size_t pattern_len; + size_t step + = (23U << ((CHARBYTES - 1) * 8)) % (size_t) max_char; CHAR *s1, *s2; @@ -179,8 +183,28 @@ do_test (size_t align1, size_t align2, size_t len, int max_char, i = align2 + CHARBYTES * (len + 2); s2 = (CHAR *)(buf2 + ((page_size - i) / 16 * 16) + align2); - for (i = 0; i < len; i++) - s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % max_char; + /* The generated sequence repeats after at most max_char elements. */ + pattern_len + = len < (size_t) max_char ? len : (size_t) max_char; + + for (i = 0; i < pattern_len; i++) + { + s1[i] = 1 + value; + + value += step; + if (value >= (size_t) max_char) + value -= max_char; + } + + while (i < len) + { + size_t copy = i < len - i ? i : len - i; + + MEMCPY (s1 + i, s1, copy); + i += copy; + } + + MEMCPY (s2, s1, len); s1[len] = s2[len] = 0; s1[len + 1] = 23; diff --git a/string/test-strncasecmp-nonarray.c b/string/test-strncasecmp-nonarray.c new file mode 100644 index 0000000000..d68e58d5ec --- /dev/null +++ b/string/test-strncasecmp-nonarray.c @@ -0,0 +1,4 @@ +#define TEST_IDENTIFIER strncasecmp +#define TEST_NAME "strncasecmp" +typedef char CHAR; +#include "test-Xncmp-nonarray.c" diff --git a/string/test-strncasecmp.c b/string/test-strncasecmp.c index 035c680532..6b00113e66 100644 --- a/string/test-strncasecmp.c +++ b/string/test-strncasecmp.c @@ -83,6 +83,9 @@ do_test (size_t align1, size_t align2, size_t n, size_t len, int max_char, int exp_result) { size_t i; + size_t value = 0; + size_t step = 23U % (size_t) max_char; + size_t pattern_len; char *s1, *s2; if (len == 0) @@ -100,10 +103,26 @@ do_test (size_t align1, size_t align2, size_t n, size_t len, int max_char, s1 = (char *) (buf1 + align1); s2 = (char *) (buf2 + align2); - for (i = 0; i < len; i++) + pattern_len + = len < (size_t) max_char ? len : (size_t) max_char; + + for (i = 0; i < pattern_len; i++) { - s1[i] = toupper (1 + 23 * i % max_char); + s1[i] = toupper (1 + value); s2[i] = tolower (s1[i]); + + value += step; + if (value >= (size_t) max_char) + value -= max_char; + } + + while (i < len) + { + size_t copy = i < len - i ? i : len - i; + + memcpy (s1 + i, s1, copy); + memcpy (s2 + i, s2, copy); + i += copy; } s1[len] = s2[len] = 0; diff --git a/string/test-strncmp.c b/string/test-strncmp.c index 54ada39eb2..9da0f21f60 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -190,6 +190,9 @@ do_test_n (size_t align1, size_t align2, size_t len, size_t n, int n_in_bounds, { size_t i, buf_bound; CHAR *s1, *s2, *s1_end, *s2_end; + size_t value = 0; + size_t pattern_len; + size_t step = (23U << ((CHARBYTES - 1) * 8)) % (size_t) max_char; align1 &= ~(CHARBYTES - 1); align2 &= ~(CHARBYTES - 1); @@ -216,8 +219,29 @@ do_test_n (size_t align1, size_t align2, size_t len, size_t n, int n_in_bounds, s2[n] = 23; } - for (i = 0; i < buf_bound; i++) - s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % max_char; + /* The generated sequence repeats after at most max_char elements. */ + pattern_len + = buf_bound < (size_t) max_char + ? buf_bound : (size_t) max_char; + + for (i = 0; i < pattern_len; i++) + { + s1[i] = 1 + value; + + value += step; + if (value >= (size_t) max_char) + value -= max_char; + } + + while (i < buf_bound) + { + size_t copy = i < buf_bound - i ? i : buf_bound - i; + + MEMCPY (s1 + i, s1, copy); + i += copy; + } + + MEMCPY (s2, s1, buf_bound); s1[len] = 0; s2[len] = 0; diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S index b40d8bb31b..412fb85906 100644 --- a/sysdeps/aarch64/dl-trampoline.S +++ b/sysdeps/aarch64/dl-trampoline.S @@ -321,7 +321,9 @@ _dl_runtime_profile: add sp, sp, SF_SIZE + 16 cfi_adjust_cfa_offset (- SF_SIZE - 16) - br lr + /* Use ret instead of br: the caller's return site is not a BTI + landing pad. */ + ret cfi_endproc .size _dl_runtime_profile, .-_dl_runtime_profile diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile index 60a369e255..faa59ab27a 100644 --- a/sysdeps/alpha/Makefile +++ b/sysdeps/alpha/Makefile @@ -53,6 +53,20 @@ CFLAGS-s_lrint.c += -mieee-with-inexact CFLAGS-test-misc.c += -mieee-with-inexact # Avoid "conflicting types for built-in function" warnings CFLAGS-s_isnan.c += -fno-builtin-isnanf + +# _Float32x and _Float64 are both binary64 on Alpha, so this narrowing +# divide is a plain divide and the hardware alone decides whether to +# signal underflow. IEEE 754 determines tininess after rounding from the +# result rounded as if the exponent range were unbounded, but Alpha +# determines it from the delivered result. For a quotient that is tiny +# but rounds up to the smallest normal -- DBL_MIN / (1 + 2^-52) under a +# rounding mode that rounds away from zero -- the unbounded rounding +# stays below DBL_MIN, because that binade has a finer spacing than the +# subnormals, while the delivered result is DBL_MIN and looks normal. +# Alpha raises no underflow for it. No trap is taken, so the kernel +# emulation cannot correct this, and the operation has no wider +# intermediate for libm to examine. +test-xfail-test-float32x-float64-div = yes endif # Build everything with full IEEE math support, and with dynamic rounding; diff --git a/sysdeps/alpha/fpu/bits/fenv.h b/sysdeps/alpha/fpu/bits/fenv.h index b1135f1f0a..530f298914 100644 --- a/sysdeps/alpha/fpu/bits/fenv.h +++ b/sysdeps/alpha/fpu/bits/fenv.h @@ -121,7 +121,7 @@ typedef unsigned long int fenv_t; #ifdef __USE_GNU /* Floating-point environment where none of the exceptions are masked. */ -# define FE_NOMASK_ENV ((const fenv_t *) 0x880000000000003eUL) +# define FE_NOMASK_ENV ((const fenv_t *) 0x880000000000007eUL) /* Floating-point environment with (processor-dependent) non-IEEE floating point. In this case, mapping denormals to zero. */ diff --git a/sysdeps/arm/Makefile b/sysdeps/arm/Makefile index 0bb1b6e05b..9042315492 100644 --- a/sysdeps/arm/Makefile +++ b/sysdeps/arm/Makefile @@ -10,6 +10,11 @@ shared-only-routines += aeabi_unwind_cpp_pr1 $(objpfx)libgcc-stubs.a: $(objpfx)aeabi_unwind_cpp_pr1.os $(build-extra-lib) +# The rtld link recipes in elf/Makefile use $(gnulib), which here +# includes libgcc-stubs.a, but they cannot name it as a prerequisite: +# gnulib-arch is only defined once this file is included from Makerules. +$(objpfx)librtld.map $(objpfx)librtld.os: | $(objpfx)libgcc-stubs.a + lib-noranlib: $(objpfx)libgcc-stubs.a ifeq ($(build-shared),yes) diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h index 972ab32b86..b1de245438 100644 --- a/sysdeps/generic/dl-cache.h +++ b/sysdeps/generic/dl-cache.h @@ -321,6 +321,9 @@ cache_extension_load (const struct cache_file_new *cache, struct cache_extension_all_loaded *loaded) { memset (loaded, 0, sizeof (*loaded)); + if (cache == NULL) + /* Old-format cache without a new-format header, so no extensions. */ + return true; if (cache->extension_offset == 0) /* No extensions present. This is not a format error. */ return true; diff --git a/sysdeps/ieee754/dbl-64/e_sinh.c b/sysdeps/ieee754/dbl-64/e_sinh.c index 1643f3f504..638e3d6a6d 100644 --- a/sysdeps/ieee754/dbl-64/e_sinh.c +++ b/sysdeps/ieee754/dbl-64/e_sinh.c @@ -213,7 +213,7 @@ __sinh (double x) ml = (ul + 8) & MANTISSA_MASK; th += tl; th *= 2; - th *= asuint64 (sp); + th *= sp; if (ml <= 16 || eh - el > 103) return as_sinh_database (x, th); return th; diff --git a/sysdeps/ieee754/dbl-64/e_sinh_data.c b/sysdeps/ieee754/dbl-64/e_sinh_data.c index ca61e311f1..d4fd41d934 100644 --- a/sysdeps/ieee754/dbl-64/e_sinh_data.c +++ b/sysdeps/ieee754/dbl-64/e_sinh_data.c @@ -35,12 +35,13 @@ const double __sinh_data_ch[][2] = { 0x1.ae64567f54482p-26, -0x1.defcf17a6ab79p-81 } }; -const double __sinh_data_db[49][3] = +const double __sinh_data_db[51][3] = { { 0x1.364303e1ad8f6p-2, 0x1.3b07e0c779ddap-2, -0x1.bcp-106 }, { 0x1.4169f234f23b9p-2, 0x1.46b7b3b358f99p-2, -0x1p-56 }, { 0x1.616cc75d49226p-2, 0x1.687bd068c1c1ep-2, 0x1.ap-111 }, { 0x1.ae3773250e7d2p-2, 0x1.bafc3479fc9ccp-2, -0x1p-105 }, + { 0x1.b7efa91915c95p-2, 0x1.c59869f17b483p-2, -0x1p-104 }, { 0x1.d68039861ab53p-2, 0x1.e73b46abb01e1p-2, -0x1.2p-109 }, { 0x1.e90f16eb88c09p-2, 0x1.fbdd4a37760b7p-2, -0x1.f8p-108 }, { 0x1.a3fc7e4dd47d1p-1, 0x1.d4b21ebf542fp-1, 0x1.ep-107 }, @@ -62,6 +63,7 @@ const double __sinh_data_db[49][3] = { 0x1.43a81752eabe7p+3, 0x1.81d364845ecfap+13, -0x1p-90 }, { 0x1.16369cd53bb69p+4, 0x1.0fbc6c02b1c9p+24, -0x1.9p-81 }, { 0x1.20e29ea8b51e2p+4, 0x1.08b8abba28abcp+25, 0x1.9bp-79 }, + { 0x1.92a5c27afbe82p+4, 0x1.3c81f9a247253p+35, 0x1p-67 }, { 0x1.a1e4f11b513d7p+4, 0x1.9a65b6c2e2185p+36, -0x1.bcp-70 }, { 0x1.c089fcf166171p+4, 0x1.5c452e0e37569p+39, 0x1.4p-69 }, { 0x1.e42a98b3a0be5p+4, 0x1.938768ca4f8aap+42, 0x1.6dp-62 }, diff --git a/sysdeps/ieee754/dbl-64/e_sinh_data.h b/sysdeps/ieee754/dbl-64/e_sinh_data.h index 16f7e0da5a..c34848fd54 100644 --- a/sysdeps/ieee754/dbl-64/e_sinh_data.h +++ b/sysdeps/ieee754/dbl-64/e_sinh_data.h @@ -29,7 +29,7 @@ SOFTWARE. extern const double __sinh_data_ch[][2] attribute_hidden; #define CH __sinh_data_ch -extern const double __sinh_data_db[49][3] attribute_hidden; +extern const double __sinh_data_db[51][3] attribute_hidden; #define DB __sinh_data_db #endif diff --git a/sysdeps/ieee754/dbl-64/s_tanh.c b/sysdeps/ieee754/dbl-64/s_tanh.c index 2029de8fa5..ef80b9edb6 100644 --- a/sysdeps/ieee754/dbl-64/s_tanh.c +++ b/sysdeps/ieee754/dbl-64/s_tanh.c @@ -283,4 +283,6 @@ __tanh (double x) return as_tanh_database (x, res); return res; } +#ifndef __tanh libm_alias_double (__tanh, tanh) +#endif diff --git a/sysdeps/ieee754/ldbl-opt/configure b/sysdeps/ieee754/ldbl-opt/configure old mode 100644 new mode 100755 index bc6552da0b..7769cc9781 --- a/sysdeps/ieee754/ldbl-opt/configure +++ b/sysdeps/ieee754/ldbl-opt/configure @@ -13,17 +13,10 @@ CFLAGS="$CFLAGS -mlong-double-128" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -int -main (void) -{ - #ifndef __LONG_DOUBLE_128__ # error "compiler did not predefine __LONG_DOUBLE_128__ as expected" #endif long double foobar (long double x) { return x; } - ; - return 0; -} _ACEOF if ac_fn_c_try_compile "$LINENO" then : diff --git a/sysdeps/ieee754/ldbl-opt/configure.ac b/sysdeps/ieee754/ldbl-opt/configure.ac index 70e3b32dc6..1c500ad581 100644 --- a/sysdeps/ieee754/ldbl-opt/configure.ac +++ b/sysdeps/ieee754/ldbl-opt/configure.ac @@ -6,7 +6,7 @@ AC_CACHE_CHECK(whether $CC $CFLAGS supports -mlong-double-128, libc_cv_mlong_double_128, [dnl save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mlong-double-128" -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef __LONG_DOUBLE_128__ # error "compiler did not predefine __LONG_DOUBLE_128__ as expected" #endif diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S index 191f03320a..302cb6894a 100644 --- a/sysdeps/loongarch/__longjmp.S +++ b/sysdeps/loongarch/__longjmp.S @@ -23,9 +23,9 @@ ENTRY (__longjmp) #ifdef PTR_MANGLE REG_L t0, a0, 0*SZREG - PTR_DEMANGLE (ra, t0, t1) + PTR_DEMANGLE (ra, t0, t1, t2) REG_L t0, a0, 1*SZREG - PTR_DEMANGLE2 (sp, t0, t1) + PTR_DEMANGLE2 (sp, t0, t1, t2) #else REG_L ra, a0, 0*SZREG REG_L sp, a0, 1*SZREG diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S index 591e0d2709..58c1ee02b2 100644 --- a/sysdeps/loongarch/setjmp.S +++ b/sysdeps/loongarch/setjmp.S @@ -31,9 +31,9 @@ END (setjmp) ENTRY (__sigsetjmp) #ifdef PTR_MANGLE - PTR_MANGLE (t0, ra, t1) + PTR_MANGLE (t0, ra, t1, t2) REG_S t0, a0, 0*SZREG - PTR_MANGLE2 (t0, sp, t1) + PTR_MANGLE2 (t0, sp, t1, t2) REG_S t0, a0, 1*SZREG #else REG_S ra, a0, 0*SZREG diff --git a/sysdeps/m68k/m680x0/fpu/e_fmod.c b/sysdeps/m68k/m680x0/fpu/e_fmod.c index 9ad6924422..faac7c79e3 100644 --- a/sysdeps/m68k/m680x0/fpu/e_fmod.c +++ b/sysdeps/m68k/m680x0/fpu/e_fmod.c @@ -33,7 +33,7 @@ __fmod (double x, double y) && !is_nan (hx))) return __math_invalid (x); - return __m81_u(fmod)(x, y); + return __m81_u(__ieee754_fmod)(x, y); } strong_alias (__fmod, __ieee754_fmod) libm_alias_finite (__ieee754_fmod, __fmod) diff --git a/sysdeps/m68k/m680x0/fpu/e_fmodf.c b/sysdeps/m68k/m680x0/fpu/e_fmodf.c index a3bd24b71f..98797e0887 100644 --- a/sysdeps/m68k/m680x0/fpu/e_fmodf.c +++ b/sysdeps/m68k/m680x0/fpu/e_fmodf.c @@ -34,7 +34,7 @@ __fmodf (float x, float y) && !is_nan (hx))) return __math_invalidf (x); - return __m81_u(fmodf)(x, y); + return __m81_u(__ieee754_fmodf)(x, y); } strong_alias (__fmodf, __ieee754_fmodf) versioned_symbol (libm, __fmodf, fmodf, GLIBC_2_43); diff --git a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c b/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c deleted file mode 100644 index 57f38091e6..0000000000 --- a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c +++ /dev/null @@ -1,15 +0,0 @@ -/* m68k provides an optimized __ieee752_fmod. */ -#include -#ifdef SHARED -# undef SHLIB_COMPAT -# define SHLIB_COMPAT(a, b, c) 1 -# undef LIBM_SVID_COMPAT -# define LIBM_SVID_COMPAT 1 -# undef compat_symbol -# define compat_symbol(a, b, c, d) -#include -libm_alias_double (__fmod_compat, fmod) -#else -#include -#include -#endif diff --git a/sysdeps/mach/hurd/i386/localplt.data b/sysdeps/mach/hurd/i386/localplt.data index 2befcd3748..5b9413422d 100644 --- a/sysdeps/mach/hurd/i386/localplt.data +++ b/sysdeps/mach/hurd/i386/localplt.data @@ -25,14 +25,14 @@ ld.so: __writev ld.so: __libc_lseek64 ld.so: __mmap ld.so: __fstat64 -ld.so: __fstatat64 +ld.so: __fstatat64 ? ld.so: __stat64 ld.so: __access ld.so: __getpid ld.so: __getcwd ld.so: _exit ? ld.so: abort -ld.so: readlink +ld.so: readlink ? ld.so: _hurd_intr_rpc_mach_msg ld.so: __errno_location ld.so: _dl_init_first diff --git a/sysdeps/mach/hurd/i386/longjmp-ts.c b/sysdeps/mach/hurd/i386/longjmp-ts.c index 93450e86b4..340104b832 100644 --- a/sysdeps/mach/hurd/i386/longjmp-ts.c +++ b/sysdeps/mach/hurd/i386/longjmp-ts.c @@ -38,7 +38,6 @@ _hurd_longjmp_thread_state (void *state, jmp_buf env, int val) ts->eip = env[0].__jmpbuf[JB_PC]; ts->eax = val ?: 1; - PTR_DEMANGLE (ts->ebp); PTR_DEMANGLE (ts->uesp); PTR_DEMANGLE (ts->eip); } diff --git a/sysdeps/mach/hurd/kernel_stat.h b/sysdeps/mach/hurd/kernel_stat.h new file mode 100644 index 0000000000..aa8c26b1d9 --- /dev/null +++ b/sysdeps/mach/hurd/kernel_stat.h @@ -0,0 +1,23 @@ +/* Internal definitions for stat functions. Hurd version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* struct stat and struct stat64 never have the same layout: on 32-bit + ABIs st_ino, st_size, and st_blocks are narrower in struct stat, and + on 64-bit ABIs the two structures still differ in the amount of + trailing spare space (see _SPARE_SIZE in bits/stat.h). */ +#define XSTAT_IS_XSTAT64 0 diff --git a/sysdeps/mach/hurd/x86/Makefile b/sysdeps/mach/hurd/x86/Makefile index 97e3287c87..1d94f3a1c1 100644 --- a/sysdeps/mach/hurd/x86/Makefile +++ b/sysdeps/mach/hurd/x86/Makefile @@ -3,11 +3,7 @@ sysdep_routines += ioperm sysdep_headers += sys/io.h endif -ifeq ($(subdir),debug) -gen-as-const-headers += signal-defines.sym -endif - -ifeq ($(subdir),setjmp) +ifeq ($(subdir),csu) gen-as-const-headers += signal-defines.sym endif diff --git a/sysdeps/mach/hurd/x86_64/localplt.data b/sysdeps/mach/hurd/x86_64/localplt.data index fda28cd983..cc39118d12 100644 --- a/sysdeps/mach/hurd/x86_64/localplt.data +++ b/sysdeps/mach/hurd/x86_64/localplt.data @@ -24,14 +24,14 @@ ld.so: __writev ld.so: __libc_lseek64 ld.so: __mmap ld.so: __fstat64 -ld.so: __fstatat64 +ld.so: __fstatat64 ? ld.so: __stat64 ld.so: __access ld.so: __getpid ld.so: __getcwd ld.so: _exit ? ld.so: abort -ld.so: readlink +ld.so: readlink ? ld.so: _hurd_intr_rpc_mach_msg ld.so: __errno_location ld.so: _dl_init_first diff --git a/sysdeps/powerpc/powerpc32/__longjmp-common.S b/sysdeps/powerpc/powerpc32/__longjmp-common.S index eb228bf4fe..f1da933704 100644 --- a/sysdeps/powerpc/powerpc32/__longjmp-common.S +++ b/sysdeps/powerpc/powerpc32/__longjmp-common.S @@ -30,13 +30,13 @@ ENTRY (__longjmp_symbol) #if defined PTR_DEMANGLE || defined CHECK_SP lwz r24,(JB_GPR1*4)(r3) +# ifdef PTR_DEMANGLE + PTR_DEMANGLE (r24, r25) +# endif # ifdef CHECK_SP -# ifdef PTR_DEMANGLE - PTR_DEMANGLE3 (r24, r24, r25) -# endif CHECK_SP (r24) - mr r1,r24 # endif + mr r1,r24 #else lwz r1,(JB_GPR1*4)(r3) #endif @@ -49,9 +49,6 @@ ENTRY (__longjmp_symbol) lwz r19,((JB_GPRS+19-14)*4)(r3) lwz r20,((JB_GPRS+20-14)*4)(r3) #ifdef PTR_DEMANGLE -# ifndef CHECK_SP - PTR_DEMANGLE3 (r1, r24, r25) -# endif PTR_DEMANGLE2 (r0, r25) #endif /* longjmp/longjmp_target probe expects longjmp first argument (4@3), diff --git a/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S b/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S index c5acc1610c..8e383cc997 100644 --- a/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S +++ b/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S @@ -114,13 +114,13 @@ L(no_vmx): #endif #if defined PTR_DEMANGLE || defined CHECK_SP lwz r24,(JB_GPR1*4)(r3) +# ifdef PTR_DEMANGLE + PTR_DEMANGLE (r24, r25) +# endif # ifdef CHECK_SP -# ifdef PTR_DEMANGLE - PTR_DEMANGLE3 (r24, r24, r25) -# endif CHECK_SP (r24) - mr r1,r24 # endif + mr r1,r24 #else lwz r1,(JB_GPR1*4)(r3) #endif @@ -140,9 +140,6 @@ L(no_vmx): lwz r20,((JB_GPRS+6)*4)(r3) lfd fp20,((JB_FPRS+6*2)*4)(r3) #ifdef PTR_DEMANGLE -# ifndef CHECK_SP - PTR_DEMANGLE3 (r1, r24, r25) -# endif PTR_DEMANGLE2 (r0, r25) #endif /* longjmp/longjmp_target probe expects longjmp first argument (4@3), diff --git a/sysdeps/powerpc/powerpc64/__longjmp-common.S b/sysdeps/powerpc/powerpc64/__longjmp-common.S index 99b2718677..fe8488fcac 100644 --- a/sysdeps/powerpc/powerpc64/__longjmp-common.S +++ b/sysdeps/powerpc/powerpc64/__longjmp-common.S @@ -115,19 +115,15 @@ L(no_vmx): #endif #if defined PTR_DEMANGLE || defined CHECK_SP ld r22,(JB_GPR1*8)(r3) -#else - ld r1,(JB_GPR1*8)(r3) -#endif -#ifdef PTR_DEMANGLE -# ifdef CHECK_SP - PTR_DEMANGLE3 (r22, r22, r25) -# else - PTR_DEMANGLE3 (r1, r22, r25) +# ifdef PTR_DEMANGLE + PTR_DEMANGLE (r22, r25) # endif -#endif -#ifdef CHECK_SP +# ifdef CHECK_SP CHECK_SP (r22) +# endif mr r1,r22 +#else + ld r1,(JB_GPR1*8)(r3) #endif ld r2,(JB_GPR2*8)(r3) ld r0,(JB_LR*8)(r3) diff --git a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S index 3c45e9ea50..8de75fb7e5 100644 --- a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S +++ b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S @@ -355,6 +355,14 @@ L(bytebybyte): offset and string descriptors are only updated in the end of loop unrolling. */ ld rLOC, LOCALE_CTYPE_TOLOWER(rLOC) +#ifdef USE_AS_STRNCASECMP + /* This entry point can be reached from the vector loop with + r5 == 0 (the last vector chunk ended exactly at the `n' + boundary). Do not read s1[0]/s2[0] in that case: those + bytes are s1[n]/s2[n], one past the caller's bound. */ + cmpdi cr7, r5, 0 + beq cr7, L(retnull) +#endif lbz rCHAR1, 0(rSTR1) /* Load char from s1 */ lbz rCHAR2, 0(rSTR2) /* Load char from s2 */ #ifdef USE_AS_STRNCASECMP @@ -405,19 +413,23 @@ L(loop): cmpw cr1, rLWR1, rLWR2 crorc 4*cr1+eq,eq,4*cr1+eq beq cr1, L(done) +#ifdef USE_AS_STRNCASECMP + /* Test the remaining count before touching the next byte. */ + bdnz L(loop_load) + b L(lessthan4) +L(loop_load): +#endif lbz rCHAR1, 0(rSTR1) /* Load char from s1 */ lbz rCHAR2, 0(rSTR2) /* Load char from s2 */ -#ifdef USE_AS_STRNCASECMP - bdnz L(loop) -#else b L(loop) -#endif #ifdef USE_AS_STRNCASECMP L(lessthan4): clrldi r5, r5, 62 cmpdi cr7, r5, 0 beq cr7, L(retnull) mtctr r5 + lbz rCHAR1, 0(rSTR1) + lbz rCHAR2, 0(rSTR2) L(loop1): cmpdi rCHAR1, 0 sldi rADDR1, rCHAR1, 2 @@ -427,11 +439,14 @@ L(loop1): cmpw cr1, rLWR1, rLWR2 crorc 4*cr1+eq,eq,4*cr1+eq beq cr1, L(done) + bdnz L(loop1_load) + b L(retnull) +L(loop1_load): addi rSTR1, rSTR1, 1 addi rSTR2, rSTR2, 1 lbz rCHAR1, 0(rSTR1) lbz rCHAR2, 0(rSTR2) - bdnz L(loop1) + b L(loop1) #endif L(done): subf r0, rLWR2, rLWR1 diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h index a6ce5348ec..f0f271ec02 100644 --- a/sysdeps/unix/sysdep.h +++ b/sysdeps/unix/sysdep.h @@ -154,42 +154,31 @@ # define __SYSCALL_CANCEL7_ARG7 # define __SYSCALL_CANCEL7_ARCH_ARG7 #endif -long int __internal_syscall_cancel (__syscall_arg_t a1, __syscall_arg_t a2, - __syscall_arg_t a3, __syscall_arg_t a4, - __syscall_arg_t a5, __syscall_arg_t a6, - __SYSCALL_CANCEL7_ARG_DEF - __syscall_arg_t nr) attribute_hidden; - -long int __syscall_cancel (__syscall_arg_t arg1, __syscall_arg_t arg2, - __syscall_arg_t arg3, __syscall_arg_t arg4, - __syscall_arg_t arg5, __syscall_arg_t arg6, - __SYSCALL_CANCEL7_ARG_DEF - __syscall_arg_t nr) attribute_hidden; #define __SYSCALL_CANCEL0(name) \ - __syscall_cancel (0, 0, 0, 0, 0, 0, __SYSCALL_CANCEL7_ARG __NR_##name) + syscall_cancel (0, 0, 0, 0, 0, 0, __SYSCALL_CANCEL7_ARG __NR_##name) #define __SYSCALL_CANCEL1(name, a1) \ - __syscall_cancel (__SSC (a1), 0, 0, 0, 0, 0, \ - __SYSCALL_CANCEL7_ARG __NR_##name) + syscall_cancel (__SSC (a1), 0, 0, 0, 0, 0, \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __SYSCALL_CANCEL2(name, a1, a2) \ - __syscall_cancel (__SSC (a1), __SSC (a2), 0, 0, 0, 0, \ - __SYSCALL_CANCEL7_ARG __NR_##name) + syscall_cancel (__SSC (a1), __SSC (a2), 0, 0, 0, 0, \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __SYSCALL_CANCEL3(name, a1, a2, a3) \ - __syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), 0, 0, 0, \ - __SYSCALL_CANCEL7_ARG __NR_##name) + syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), 0, 0, 0, \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __SYSCALL_CANCEL4(name, a1, a2, a3, a4) \ - __syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ - __SSC(a4), 0, 0, __SYSCALL_CANCEL7_ARG __NR_##name) + syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ + __SSC(a4), 0, 0, __SYSCALL_CANCEL7_ARG __NR_##name) #define __SYSCALL_CANCEL5(name, a1, a2, a3, a4, a5) \ - __syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), __SSC(a4), \ - __SSC (a5), 0, __SYSCALL_CANCEL7_ARG __NR_##name) + syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), __SSC(a4), \ + __SSC (a5), 0, __SYSCALL_CANCEL7_ARG __NR_##name) #define __SYSCALL_CANCEL6(name, a1, a2, a3, a4, a5, a6) \ - __syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), __SSC (a4), \ - __SSC (a5), __SSC (a6), __SYSCALL_CANCEL7_ARG \ - __NR_##name) + syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), __SSC (a4), \ + __SSC (a5), __SSC (a6), __SYSCALL_CANCEL7_ARG \ + __NR_##name) #define __SYSCALL_CANCEL7(name, a1, a2, a3, a4, a5, a6, a7) \ - __syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), __SSC (a4), \ - __SSC (a5), __SSC (a6), __SSC (a7), __NR_##name) + syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), __SSC (a4), \ + __SSC (a5), __SSC (a6), __SSC (a7), __NR_##name) #define __SYSCALL_CANCEL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n #define __SYSCALL_CANCEL_NARGS(...) \ @@ -206,33 +195,33 @@ long int __syscall_cancel (__syscall_arg_t arg1, __syscall_arg_t arg2, __SYSCALL_CANCEL_DISP (__SYSCALL_CANCEL, __VA_ARGS__) #define __INTERNAL_SYSCALL_CANCEL0(name) \ - __internal_syscall_cancel (0, 0, 0, 0, 0, 0, __SYSCALL_CANCEL7_ARG \ + internal_syscall_cancel (0, 0, 0, 0, 0, 0, __SYSCALL_CANCEL7_ARG \ __NR_##name) #define __INTERNAL_SYSCALL_CANCEL1(name, a1) \ - __internal_syscall_cancel (__SSC (a1), 0, 0, 0, 0, 0, \ - __SYSCALL_CANCEL7_ARG __NR_##name) + internal_syscall_cancel (__SSC (a1), 0, 0, 0, 0, 0, \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __INTERNAL_SYSCALL_CANCEL2(name, a1, a2) \ - __internal_syscall_cancel (__SSC (a1), __SSC (a2), 0, 0, 0, 0, \ - __SYSCALL_CANCEL7_ARG __NR_##name) + internal_syscall_cancel (__SSC (a1), __SSC (a2), 0, 0, 0, 0, \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __INTERNAL_SYSCALL_CANCEL3(name, a1, a2, a3) \ - __internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), 0, \ - 0, 0, __SYSCALL_CANCEL7_ARG __NR_##name) + internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), 0, \ + 0, 0, __SYSCALL_CANCEL7_ARG __NR_##name) #define __INTERNAL_SYSCALL_CANCEL4(name, a1, a2, a3, a4) \ - __internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ - __SSC(a4), 0, 0, \ - __SYSCALL_CANCEL7_ARG __NR_##name) + internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ + __SSC(a4), 0, 0, \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __INTERNAL_SYSCALL_CANCEL5(name, a1, a2, a3, a4, a5) \ - __internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ - __SSC(a4), __SSC (a5), 0, \ - __SYSCALL_CANCEL7_ARG __NR_##name) + internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ + __SSC(a4), __SSC (a5), 0, \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __INTERNAL_SYSCALL_CANCEL6(name, a1, a2, a3, a4, a5, a6) \ - __internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ - __SSC (a4), __SSC (a5), __SSC (a6), \ - __SYSCALL_CANCEL7_ARG __NR_##name) + internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ + __SSC (a4), __SSC (a5), __SSC (a6), \ + __SYSCALL_CANCEL7_ARG __NR_##name) #define __INTERNAL_SYSCALL_CANCEL7(name, a1, a2, a3, a4, a5, a6, a7) \ - __internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ - __SSC (a4), __SSC (a5), __SSC (a6), \ - __SSC (a7), __NR_##name) + internal_syscall_cancel (__SSC (a1), __SSC (a2), __SSC (a3), \ + __SSC (a4), __SSC (a5), __SSC (a6), \ + __SSC (a7), __NR_##name) /* Issue a cancellable syscall defined by syscall number NAME plus any other argument required. If an error occurs its value is returned as an negative diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 14a56d5cc3..005847db7a 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -432,6 +432,7 @@ sysdep_headers += \ # sysdep_headers tests += \ + tst-tcgetattr-stack \ tst-termios-linux \ # tests endif diff --git a/sysdeps/unix/sysv/linux/alpha/makecontext.S b/sysdeps/unix/sysv/linux/alpha/makecontext.S index b0479315d5..1de0dd2653 100644 --- a/sysdeps/unix/sysv/linux/alpha/makecontext.S +++ b/sysdeps/unix/sysv/linux/alpha/makecontext.S @@ -38,6 +38,9 @@ ENTRY(__makecontext) s8addq $1, 0, $2 subq $8, $2, $8 + /* The Alpha ABI requires a 16-byte-aligned stack pointer. */ + bic $8, 15, $8 + /* Copy all parameters. Switch statement header here. */ ldah $3, $jumptable($29) !gprelhigh cmple $18, 6, $1 diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux-fortify.h b/sysdeps/unix/sysv/linux/bits/fcntl-linux-fortify.h index 4c8f3a874e..b12b5b75da 100644 --- a/sysdeps/unix/sysv/linux/bits/fcntl-linux-fortify.h +++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux-fortify.h @@ -25,7 +25,7 @@ extern int __REDIRECT (__openat2_alias, (int __dfd, const char *__filename, const struct open_how *__how, size_t __usize), openat2) - __nonnull ((2, 3)); + __nonnull ((3)); #if !__fortify_use_clang __errordecl (__openat2_invalid_size, diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h index 587b815124..6aaa6cc4e7 100644 --- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h +++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h @@ -485,7 +485,7 @@ extern int open_by_handle_at (int __mountdirfd, struct file_handle *__handle, extern int openat2 (int __dfd, const char * __filename, const struct open_how * __how, __SIZE_TYPE__ __usize) - __nonnull ((2, 3)); + __nonnull ((3)); #endif /* use GNU */ diff --git a/sysdeps/unix/sysv/linux/epoll_pwait2.c b/sysdeps/unix/sysv/linux/epoll_pwait2.c index 4da03e3e69..76ec1f8a71 100644 --- a/sysdeps/unix/sysv/linux/epoll_pwait2.c +++ b/sysdeps/unix/sysv/linux/epoll_pwait2.c @@ -17,7 +17,7 @@ . */ #include -#include +#include int __epoll_pwait2_time64 (int fd, struct epoll_event *ev, int maxev, diff --git a/sysdeps/unix/sysv/linux/loongarch/dl-cache.h b/sysdeps/unix/sysv/linux/loongarch/dl-cache.h index 955f0dc68f..e52c6e2090 100644 --- a/sysdeps/unix/sysv/linux/loongarch/dl-cache.h +++ b/sysdeps/unix/sysv/linux/loongarch/dl-cache.h @@ -33,6 +33,8 @@ LoongArch, libraries can be found in paths ending in: - /lib64 - /lib64/sf + - /lib32 + - /lib32/sf so this will add all of those paths. */ #define add_system_dir(dir) \ @@ -41,6 +43,8 @@ static const char* lib_dirs[] = { \ "/lib64", \ "/lib64/sf", \ + "/lib32", \ + "/lib32/sf", \ NULL, \ }; \ const size_t lib_len = sizeof ("/lib") - 1; \ diff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h index 75498545cb..006b713f9c 100644 --- a/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h +++ b/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h @@ -24,24 +24,40 @@ || (!defined SHARED && (IS_IN (libc) \ || IS_IN (libpthread)))) # define PTR_MANGLE_LOAD(guard) \ - LOAD_LOCAL (guard, __pointer_chk_guard_local); + LOAD_LOCAL (guard, __pointer_chk_guard_local); # else # define PTR_MANGLE_LOAD(guard) \ - LOAD_GLOBAL (guard, __pointer_chk_guard); + LOAD_GLOBAL (guard, __pointer_chk_guard); # endif -# define PTR_MANGLE(dst, src, guard) \ - PTR_MANGLE_LOAD (guard); \ - PTR_MANGLE2 (dst, src, guard); -# define PTR_DEMANGLE(dst, src, guard) \ - PTR_MANGLE_LOAD (guard); \ - PTR_DEMANGLE2 (dst, src, guard); + +# define PTR_MANGLE(dst, src, guard, tmp) \ + PTR_MANGLE_LOAD (guard); \ + PTR_MANGLE2 (dst, src, guard, tmp); +# define PTR_DEMANGLE(dst, src, guard, tmp) \ + PTR_MANGLE_LOAD (guard); \ + PTR_DEMANGLE2 (dst, src, guard, tmp); + +# if __loongarch_grlen == 64 /* Use PTR_MANGLE2 for efficiency if guard is already loaded. */ -# define PTR_MANGLE2(dst, src, guard) \ - xor dst, src, guard; \ - rotri.d dst, dst, 47; -# define PTR_DEMANGLE2(dst, src, guard) \ - rotri.d dst, src, 17; \ - xor dst, dst, guard; +# define PTR_MANGLE2(dst, src, guard, tmp) \ + xor tmp, src, guard; \ + rotri.d dst, tmp, 47; +# define PTR_DEMANGLE2(dst, src, guard, tmp) \ + rotri.d tmp, src, 17; \ + xor dst, tmp, guard; +# elif __loongarch_grlen == 32 /* __loongarch_grlen == 64 */ +# define PTR_MANGLE2(dst, src, guard, tmp) \ + xor tmp, src, guard; \ + slli.w dst, tmp, 9; \ + srli.w tmp, tmp, 23; \ + or dst, dst, tmp; +# define PTR_DEMANGLE2(dst, src, guard, tmp) \ + srli.w tmp, src, 9; \ + slli.w src, src, 23; \ + or tmp, tmp, src; \ + xor dst, tmp, guard; +# endif /* __loongarch_grlen == 64 */ + #endif #endif /* POINTER_GUARD_ASM_H */ diff --git a/sysdeps/unix/sysv/linux/powerpc/configure b/sysdeps/unix/sysv/linux/powerpc/configure index ef2055db92..eb8578404f 100644 --- a/sysdeps/unix/sysv/linux/powerpc/configure +++ b/sysdeps/unix/sysv/linux/powerpc/configure @@ -12,18 +12,12 @@ else case e in #( CFLAGS="$CFLAGS -mlong-double-128" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -int -main (void) -{ +#include #if LDBL_MANT_DIG != 106 # error "compiler doesn't implement IBM extended format of long double" #endif long double foobar (long double x) { return x; } - ; - return 0; -} _ACEOF if ac_fn_c_try_compile "$LINENO" then : diff --git a/sysdeps/unix/sysv/linux/powerpc/configure.ac b/sysdeps/unix/sysv/linux/powerpc/configure.ac index 42347a66fc..ca0f82da08 100644 --- a/sysdeps/unix/sysv/linux/powerpc/configure.ac +++ b/sysdeps/unix/sysv/linux/powerpc/configure.ac @@ -6,7 +6,8 @@ AC_CACHE_CHECK(whether $CC $CFLAGS -mlong-double-128 uses IBM extended format, libc_cv_mlong_double_128ibm, [dnl save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mlong-double-128" -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +#include #if LDBL_MANT_DIG != 106 # error "compiler doesn't implement IBM extended format of long double" #endif diff --git a/sysdeps/unix/sysv/linux/powerpc/pointer_guard-asm.h b/sysdeps/unix/sysv/linux/powerpc/pointer_guard-asm.h index 962ad10e59..cb3e031467 100644 --- a/sysdeps/unix/sysv/linux/powerpc/pointer_guard-asm.h +++ b/sysdeps/unix/sysv/linux/powerpc/pointer_guard-asm.h @@ -65,10 +65,6 @@ # define PTR_MANGLE2(reg, tmpreg) \ xor reg,tmpreg,reg; \ PTR_ROT_MANGLE (reg, reg) -# define PTR_MANGLE3(destreg, reg, tmpreg) \ - PTR_GUARD_LOAD (tmpreg); \ - xor destreg,tmpreg,reg; \ - PTR_ROT_MANGLE (destreg, destreg) # define PTR_DEMANGLE(reg, tmpreg) \ PTR_GUARD_LOAD (tmpreg); \ PTR_ROT_DEMANGLE (reg, reg); \ @@ -76,10 +72,6 @@ # define PTR_DEMANGLE2(reg, tmpreg) \ PTR_ROT_DEMANGLE (reg, reg); \ xor reg,tmpreg,reg -# define PTR_DEMANGLE3(destreg, reg, tmpreg) \ - PTR_GUARD_LOAD (tmpreg); \ - PTR_ROT_DEMANGLE (destreg, reg); \ - xor destreg,tmpreg,destreg #endif #endif /* POINTER_GUARD_ASM_H */ diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index 6fbe4b80aa..6a89f914c2 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -16,7 +16,7 @@ . */ #include -#include +#include #include static int diff --git a/sysdeps/unix/sysv/linux/sh/Makefile b/sysdeps/unix/sysv/linux/sh/Makefile index dd3b382ac1..8c4cb73824 100644 --- a/sysdeps/unix/sysv/linux/sh/Makefile +++ b/sysdeps/unix/sysv/linux/sh/Makefile @@ -6,7 +6,9 @@ ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym endif -ifeq ($(subdir),misc) +# is only used by ____longjmp_chk.S, which is +# built in the debug subdirectory. +ifeq ($(subdir),debug) gen-as-const-headers += sigaltstack-offsets.sym endif diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index a4fa8e9e8e..c2c5e2c0f2 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -16,7 +16,7 @@ . */ #include -#include +#include int __sigtimedwait64 (const sigset_t *set, siginfo_t *info, diff --git a/sysdeps/unix/sysv/linux/sparc/termios_arch.h b/sysdeps/unix/sysv/linux/sparc/termios_arch.h index ce8369847d..b230424943 100644 --- a/sysdeps/unix/sysv/linux/sparc/termios_arch.h +++ b/sysdeps/unix/sysv/linux/sparc/termios_arch.h @@ -17,7 +17,10 @@ License along with the GNU C Library; if not, see . */ -#define _TERMIOS2_NCCS 19 +/* The kernel's struct termios2 has 19 c_cc entries, but TCGETS2 and + TCSETS2 only transfer the first 17. The size and layout are the same + either way, since c_ispeed is aligned to 4 bytes. */ +#define _TERMIOS2_NCCS 17 #define _HAVE_TERMIOS2_C_CC_BEFORE_C_LINE 0 #define _HAVE_STRUCT_OLD_TERMIOS 1 diff --git a/sysdeps/unix/sysv/linux/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sysdep-cancel.h index 7fd8258ba5..4b7278915a 100644 --- a/sysdeps/unix/sysv/linux/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/sysdep-cancel.h @@ -21,5 +21,66 @@ #define _SYSDEP_CANCEL_H #include +#include "pthreadP.h" + +/* Called by the INTERNAL_SYSCALL_CANCEL macro, check for cancellation and + returns the syscall value or its negative error code. */ +static __always_inline long int +internal_syscall_cancel (__syscall_arg_t a1, __syscall_arg_t a2, + __syscall_arg_t a3, __syscall_arg_t a4, + __syscall_arg_t a5, __syscall_arg_t a6, + __SYSCALL_CANCEL7_ARG_DEF + __syscall_arg_t nr) +{ + long int result; + struct pthread *pd = THREAD_SELF; + + /* If cancellation is not enabled, call the syscall directly and also + for thread terminatation to avoid call __syscall_do_cancel while + executing cleanup handlers. */ + int ch = atomic_load_relaxed (&pd->cancelhandling); + if (SINGLE_THREAD_P || !cancel_enabled (ch) || cancel_exiting (ch)) + { + result = INTERNAL_SYSCALL_NCS_CALL (nr, a1, a2, a3, a4, a5, a6 + __SYSCALL_CANCEL7_ARCH_ARG7); + if (INTERNAL_SYSCALL_ERROR_P (result)) + return -INTERNAL_SYSCALL_ERRNO (result); + return result; + } + + /* Call the arch-specific entry points that contains the globals markers + to be checked by SIGCANCEL handler. */ + result = __syscall_cancel_arch (&pd->cancelhandling, nr, a1, a2, a3, a4, a5, + a6 __SYSCALL_CANCEL7_ARCH_ARG7); + + /* If the cancellable syscall was interrupted by SIGCANCEL and it has no + side-effect, cancel the thread if cancellation is enabled. */ + ch = atomic_load_relaxed (&pd->cancelhandling); + /* The behaviour here assumes that EINTR is returned only if there are no + visible side effects. POSIX Issue 7 has not yet provided any stronger + language for close, and in theory the close syscall could return EINTR + and leave the file descriptor open (conforming and leaks). It expects + that no such kernel is used with glibc. */ + if (result == -EINTR && cancel_enabled_and_canceled (ch)) + __syscall_do_cancel (); + + return result; +} + +/* Called by the SYSCALL_CANCEL macro, check for cancellation and return the + syscall expected success value (usually 0) or, in case of failure, -1 and + sets errno to syscall return value. */ +static __always_inline long int +syscall_cancel (__syscall_arg_t a1, __syscall_arg_t a2, + __syscall_arg_t a3, __syscall_arg_t a4, + __syscall_arg_t a5, __syscall_arg_t a6, + __SYSCALL_CANCEL7_ARG_DEF __syscall_arg_t nr) +{ + long int r = internal_syscall_cancel (a1, a2, a3, a4, a5, a6, + __SYSCALL_CANCEL7_ARG nr); + return __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r)) + ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (r)) + : r; +} #endif diff --git a/sysdeps/unix/sysv/linux/tst-tcgetattr-stack.c b/sysdeps/unix/sysv/linux/tst-tcgetattr-stack.c new file mode 100644 index 0000000000..b3cace6e85 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-tcgetattr-stack.c @@ -0,0 +1,68 @@ +/* Check that tcgetattr does not return uninitialized stack contents. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include +#include + +/* Fill the stack below the caller with PATTERN, so that whatever + tcgetattr leaves uninitialized in its own frame differs between + two calls. */ +static void __attribute__ ((noinline, noclone)) +dirty_stack (int pattern) +{ + char buf[4096]; + memset (buf, pattern, sizeof buf); + __asm__ volatile ("" : : "r" (buf) : "memory"); +} + +static void +get (int fd, int pattern, struct termios *tio) +{ + memset (tio, pattern, sizeof *tio); + dirty_stack (pattern); + TEST_COMPARE (tcgetattr (fd, tio), 0); +} + +static int +do_test (void) +{ + struct termios a, b; + int outer, inner; + + support_openpty (&outer, &inner, NULL, NULL, NULL); + + get (inner, 0x5a, &a); + get (inner, 0xa5, &b); + TEST_COMPARE_BLOB (&a, sizeof a, &b, sizeof b); + + cfmakeraw (&a); + TEST_COMPARE (tcsetattr (inner, TCSANOW, &a), 0); + get (inner, 0x5a, &a); + get (inner, 0xa5, &b); + TEST_COMPARE_BLOB (&a, sizeof a, &b, sizeof b); + + close (inner); + close (outer); + return 0; +} + +#include diff --git a/sysdeps/unix/sysv/linux/x86_64/Makefile b/sysdeps/unix/sysv/linux/x86_64/Makefile index 6938382801..528fd951b2 100644 --- a/sysdeps/unix/sysv/linux/x86_64/Makefile +++ b/sysdeps/unix/sysv/linux/x86_64/Makefile @@ -10,7 +10,9 @@ ifeq ($(subdir),csu) gen-as-const-headers += ucontext_i.sym endif -ifeq ($(subdir),misc) +# is only used by ____longjmp_chk.S, which is +# built in the debug subdirectory. +ifeq ($(subdir),debug) gen-as-const-headers += sigaltstack-offsets.sym endif diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 232e388d32..b4434deb0c 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -1,5 +1,12 @@ ifeq ($(subdir),csu) -gen-as-const-headers += cpu-features-offsets.sym features-offsets.sym +# is used by the setjmp/longjmp implementations in the +# setjmp subdirectory and also by ____longjmp_chk.S in the debug +# subdirectory. +gen-as-const-headers += \ + cpu-features-offsets.sym \ + features-offsets.sym \ + jmp_buf-ssp.sym \ + # gen-as-const-headers endif ifeq ($(subdir),elf) @@ -171,7 +178,6 @@ tests += \ endif # $(subdir) == math ifeq ($(subdir),setjmp) -gen-as-const-headers += jmp_buf-ssp.sym sysdep_routines += __longjmp_cancel endif diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h index 674545c796..2d6b979215 100644 --- a/sysdeps/x86/dl-cacheinfo.h +++ b/sysdeps/x86/dl-cacheinfo.h @@ -1,5 +1,6 @@ /* Initialize x86 cache info. Copyright (C) 2020-2026 Free Software Foundation, Inc. + Copyright The GNU Toolchain Authors. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -1281,7 +1282,14 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) Use 3/8 of the shared cache size per thread for memcpy and memmove. The memset threshold has already been initialized above and is intentionally left unchanged. */ - non_temporal_threshold = shared_per_thread * 3 / 8; + unsigned long int hygon_non_temporal_threshold + = shared_per_thread * 3 / 8; + + /* Missing cache information makes shared_per_thread zero. Do not + replace the 64 MiB fallback with an invalid threshold. */ + if (hygon_non_temporal_threshold >= minimum_non_temporal_threshold + && hygon_non_temporal_threshold <= maximum_non_temporal_threshold) + non_temporal_threshold = hygon_non_temporal_threshold; } tunable_size = TUNABLE_GET (x86_memset_non_temporal_threshold, long int, NULL); diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index ff0463d7ca..dfb344d74a 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -467,10 +467,12 @@ $(objpfx)tst-shstk-legacy-1e-static.out: \ $(SHELL) $< $(common-objpfx) 2> $@; \ $(evaluate-test) tst-shstk-legacy-1f-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK +LDFLAGS-tst-shstk-legacy-1f = -Wl,--no-as-needed $(objpfx)tst-shstk-legacy-1f: $(objpfx)tst-shstk-legacy-mod-1.so $(objpfx)tst-shstk-legacy-mod-1.so: \ $(objpfx)tst-shstk-legacy-mod-1.os \ $(objpfx)tst-shstk-legacy-1-extra.os +LDFLAGS-tst-shstk-legacy-1g = -Wl,--no-as-needed $(objpfx)tst-shstk-legacy-1g: $(objpfx)tst-shstk-legacy-mod-1.so $(objpfx)tst-shstk-legacy-1g.out: \ $(..)/sysdeps/x86_64/tst-shstk-legacy-1g.sh $(objpfx)tst-shstk-legacy-1g diff --git a/sysdeps/x86_64/fpu/multiarch/s_tanh-fma.c b/sysdeps/x86_64/fpu/multiarch/s_tanh-fma.c index 1b808b1227..1e6b33740a 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_tanh-fma.c +++ b/sysdeps/x86_64/fpu/multiarch/s_tanh-fma.c @@ -1,10 +1,4 @@ #define __tanh __tanh_fma -#define __expm1 __expm1_fma - -/* NB: __expm1 may be expanded to __expm1_fma in the following - prototypes. */ -extern long double __expm1l (long double); -extern long double __expm1f128 (long double); #define SECTION __attribute__ ((section (".text.fma"))) diff --git a/sysdeps/x86_64/fpu/multiarch/s_tanh.c b/sysdeps/x86_64/fpu/multiarch/s_tanh.c index ec8826f634..9048c977c1 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_tanh.c +++ b/sysdeps/x86_64/fpu/multiarch/s_tanh.c @@ -25,10 +25,9 @@ extern double __redirect_tanh (double); # define SYMBOL_NAME tanh # include "ifunc-fma.h" -libc_ifunc_redirected (__redirect_tanh, tanh, IFUNC_SELECTOR ()); +libc_ifunc_redirected (__redirect_tanh, __tanh, IFUNC_SELECTOR ()); +libm_alias_double (__tanh, tanh) # define __tanh __tanh_sse2 -# undef libm_alias_double -# define libm_alias_double(a, b) #endif #include