From patchwork Wed Jul 5 14:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=bm0BkKZm; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1nZ2yH1z20ZQ for ; Thu, 6 Jul 2023 00:12:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D04D3850221 for ; Wed, 5 Jul 2023 14:12:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D04D3850221 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566336; bh=VksUBVz0HEB9CVaCVPdz+2wc2NNsYAz+2UJlbHfJzDE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=bm0BkKZm9PpMSN0Q2DThitmswnCHneiCnLNz6W6Co480nUUG/tnIDP0C1I0GWGbBV HlL22P8wT2SCDGkgNMQYitreolv1iY0piYrDtuT9eyu62Yq5J5949bR/6Q3ur4VvPz C/0mmNCFxLHCNTvRGT2WEdCn/DaZ+0iisCe1GUmQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id AF32F3858421 for ; Wed, 5 Jul 2023 14:11:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF32F3858421 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-1p6oJsJDPgisueqDu1766g-1; Wed, 05 Jul 2023 10:11:08 -0400 X-MC-Unique: 1p6oJsJDPgisueqDu1766g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C15A873210; Wed, 5 Jul 2023 14:11:08 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2135F5CF0; Wed, 5 Jul 2023 14:11:07 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com Subject: [PATCH v5 01/14] Allow glibc to be built with _FORTIFY_SOURCE Date: Wed, 5 Jul 2023 16:10:36 +0200 Message-ID: <20230705141055.274575-2-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Add --enable-fortify-source option. It is now possible to enable fortification through a configure option. The level may be given as parameter, if none is provided, the configure script will determine what is the highest level possible that can be set considering GCC built-ins availability and set it. If level is explicitly set to 3, configure checks if the compiler supports the built-in function necessary for it or raise an error if it isn't. If the configure option isn't explicitly enabled, it _FORTIFY_SOURCE is forcibly undefined (and therefore disabled). The result of the configure checks are new variables, ${fortify_source} and ${no_fortify_source} that can be used to appropriately populate CFLAGS. A dedicated patch will follow to make use of this variable in Makefiles when necessary. Updated NEWS and INSTALL. Adding dedicated x86_64 variant that enables the configuration. --- INSTALL | 8 ++++ Makeconfig | 35 +++++++++++++-- NEWS | 6 +++ config.make.in | 3 +- configure | 83 ++++++++++++++++++++++++++++-------- configure.ac | 60 ++++++++++++++++++-------- elf/rtld-Rules | 2 +- manual/install.texi | 8 ++++ scripts/build-many-glibcs.py | 4 +- 9 files changed, 167 insertions(+), 42 deletions(-) diff --git a/INSTALL b/INSTALL index fe591c7dae..51297189c0 100644 --- a/INSTALL +++ b/INSTALL @@ -276,6 +276,14 @@ if ‘CFLAGS’ is specified it must enable optimization. For example: the GNU C Library. The default value refers to the main bug-reporting information for the GNU C Library. +‘--enable-fortify-source’ +‘--enable-fortify-source=LEVEL’ + Use -D_FORTIFY_SOURCE=‘LEVEL’ to control hardening in the GNU C + Library. If not provided, ‘LEVEL’ defaults to highest possible + value supported by the build compiler. + + Default is to disable fortification. + To build the library and related programs, type ‘make’. This will produce a lot of output, some of which may look like errors from ‘make’ but aren’t. Look for error messages from ‘make’ containing ‘***’. diff --git a/Makeconfig b/Makeconfig index 2514db35f6..77d7fd14df 100644 --- a/Makeconfig +++ b/Makeconfig @@ -543,12 +543,13 @@ endif # +link # ARM, gcc always produces different debugging symbols when invoked with # a -O greater than 0 than when invoked with -O0, regardless of anything else # we're using to suppress optimizations. Therefore, we need to explicitly pass -# -O0 to it through CFLAGS. +# -O0 to it through CFLAGS. As a result, any fortification needs to be disabled +# as it needs -O greater than 0. # Additionally, the build system will try to -include $(common-objpfx)/config.h # when compiling the tests, which will throw an error if some special macros # (such as __OPTIMIZE__ and IS_IN_build) aren't defined. To avoid this, we # tell gcc to define IS_IN_build. -CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build +CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build $(no-fortify-source) ifeq (yes,$(build-shared)) # These indicate whether to link using the built ld.so or the installed one. @@ -901,6 +902,16 @@ define elide-stack-protector $(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector)) endef +# We might want to compile with fortify-source +ifneq ($(fortify-source),) ++fortify-source=$(fortify-source) +endif + +# Some routine can't be fortified like the ones used by fortify +define elide-fortify-source +$(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-fortify-source)) +endef + # The program that makes Emacs-style TAGS files. ETAGS := etags @@ -961,6 +972,18 @@ endif # $(+cflags) == "" $(+stack-protector) -fno-common +gcc-nowarn := -w +# We must filter out elf because the early bootstrap of the dynamic loader +# cannot be fortified. Likewise we exclude dlfcn because it is entangled +# with the loader. We must filter out csu because early startup, like the +# loader, cannot be fortified. Lastly debug is the fortification routines +# themselves and they cannot be fortified. +do-fortify = $(filter-out elf dlfcn csu debug,$(subdir)) +ifeq ($(do-fortify),$(subdir)) ++cflags += $(+fortify-source) +else ++cflags += $(no-fortify-source) +endif + # Each sysdeps directory can contain header files that both will be # used to compile and will be installed. Each can also contain an # include/ subdirectory, whose header files will be used to compile @@ -1010,7 +1033,7 @@ module-cppflags = $(if $(filter %.mk.i %.v.i,$(@F)),,$(module-cppflags-real)) # Note that we can't use -std=* in CPPFLAGS, because it overrides # the implicit -lang-asm and breaks cpp behavior for .S files--notably # it causes cpp to stop predefining __ASSEMBLER__. -CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \ +CPPFLAGS = $(config-extra-cppflags) $(CPPFLAGS-config) \ $($(subdir)-CPPFLAGS) \ $(+includes) $(defines) $(module-cppflags) \ -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \ @@ -1049,6 +1072,8 @@ object-suffixes := CPPFLAGS-.o = $(pic-default) # libc.a must be compiled with -fPIE/-fpie for static PIE. CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default) +CFLAGS-.o += $(call elide-fortify-source,.o,$(routines_no_fortify)) +CFLAGS-.o += $(call elide-fortify-source,_chk.o,$(routines_no_fortify)) libtype.o := lib%.a object-suffixes += .o ifeq (yes,$(build-shared)) @@ -1058,6 +1083,8 @@ object-suffixes += .os pic-cppflags = -DPIC -DSHARED CPPFLAGS-.os = $(pic-cppflags) CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag) +CFLAGS-.os += $(call elide-fortify-source,.os,$(routines_no_fortify)) +CFLAGS-.os += $(call elide-fortify-source,_chk.os,$(routines_no_fortify)) libtype.os := lib%_pic.a # This can be changed by a sysdep makefile pic-ccflag = -fPIC @@ -1077,6 +1104,8 @@ object-suffixes += .op CPPFLAGS-.op = -DPROF $(pic-default) # libc_p.a must be compiled with -fPIE/-fpie for static PIE. CFLAGS-.op = -pg $(pie-default) +CFLAGS-.op += $(call elide-fortify-source,.op,$(routines_no_fortify)) +CFLAGS-.op += $(call elide-fortify-source,_chk.op,$(routines_no_fortify)) libtype.op = lib%_p.a endif diff --git a/NEWS b/NEWS index 709ee40e50..c056386d59 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,12 @@ Major new features: * The strlcpy and strlcat functions have been added. They are derived from OpenBSD, and are expected to be added to a future POSIX version. +* A new configure option, "--enable-fortify-source", can be used to build GLIBC + with _FORTIFY_SOURCE. The level of fortification can either be provided, or + is set to the highest value supported by the compiler. If not explicitly + enabled, then fortify source is forcibly disabled so to keep original + behavior unchanged. + Deprecated and removed features, and other changes affecting compatibility: * In the Linux kernel for the hppa/parisc architecture some of the diff --git a/config.make.in b/config.make.in index 4afd37feaf..d487a4f4e9 100644 --- a/config.make.in +++ b/config.make.in @@ -64,6 +64,8 @@ have-fpie = @libc_cv_fpie@ have-ssp = @libc_cv_ssp@ stack-protector = @stack_protector@ no-stack-protector = @no_stack_protector@ +fortify-source = @fortify_source@ +no-fortify-source = @no_fortify_source@ have-selinux = @have_selinux@ have-libaudit = @have_libaudit@ have-libcap = @have_libcap@ @@ -101,7 +103,6 @@ CXX = @CXX@ BUILD_CC = @BUILD_CC@ CFLAGS = @CFLAGS@ CPPFLAGS-config = @CPPFLAGS@ -CPPUNDEFS = @CPPUNDEFS@ extra-nonshared-cflags = @extra_nonshared_cflags@ rtld-early-cflags = @rtld_early_cflags@ ASFLAGS-config = @ASFLAGS_config@ diff --git a/configure b/configure index f84040644b..1833a4ce66 100755 --- a/configure +++ b/configure @@ -611,7 +611,10 @@ libc_cv_gcc_unwind_find_fde libc_extra_cppflags libc_extra_cflags libc_cv_cxx_thread_local -CPPUNDEFS +fortify_source +no_fortify_source +libc_cv_fortify_source +enable_fortify_source have_selinux have_libcap have_libaudit @@ -782,6 +785,7 @@ enable_pt_chown enable_mathvec enable_cet enable_scv +enable_fortify_source with_cpu ' ac_precious_vars='build_alias @@ -1452,6 +1456,10 @@ Optional Features: (CET), x86 only --disable-scv syscalls will not use scv instruction, even if the kernel supports it, powerpc only + --enable-fortify-source[=1|2|3] + Use -D_FORTIFY_SOURCE=[1|2|3] to control code + hardening, defaults to highest possible value + supported by the build compiler. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -3717,6 +3725,18 @@ if test "$use_scv" != "no"; then : fi +# Check whether --enable-fortify-source was given. +if test "${enable_fortify_source+set}" = set; then : + enableval=$enable_fortify_source; enable_fortify_source=$enableval +else + enable_fortify_source=no +fi + +case "$enable_fortify_source" in +1|2|3|no|yes) ;; +*) as_fn_error $? "Not a valid argument for --enable-fortify-source: \"$enable_fortify_source\"" "$LINENO" 5;; +esac + # We keep the original values in `$config_*' and never modify them, so we # can write them unchanged into config.make. Everything else uses # $machine, $vendor, and $os, and changes them whenever convenient. @@ -6353,40 +6373,67 @@ $as_echo "#define HAVE_LIBCAP 1" >>confdefs.h fi -CPPUNDEFS= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FORTIFY_SOURCE predefine" >&5 -$as_echo_n "checking for _FORTIFY_SOURCE predefine... " >&6; } -if ${libc_cv_predef_fortify_source+:} false; then : +no_fortify_source="-Wp,-U_FORTIFY_SOURCE" +fortify_source="${no_fortify_source}" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_dynamic_object_size" >&5 +$as_echo_n "checking for __builtin_dynamic_object_size... " >&6; } +if ${libc_cv___builtin_dynamic_object_size+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { - -#ifdef _FORTIFY_SOURCE -# error bogon -#endif +__builtin_dynamic_object_size("", 0) ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - libc_cv_predef_fortify_source=no +if ac_fn_c_try_link "$LINENO"; then : + libc_cv___builtin_dynamic_object_size=yes + if test "$enable_fortify_source" = yes; then : + enable_fortify_source=3 +fi else - libc_cv_predef_fortify_source=yes + libc_cv___builtin_dynamic_object_size=no + if test "$enable_fortify_source" = yes; then : + enable_fortify_source=2 fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_predef_fortify_source" >&5 -$as_echo "$libc_cv_predef_fortify_source" >&6; } -if test $libc_cv_predef_fortify_source = yes; then - CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE" +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv___builtin_dynamic_object_size" >&5 +$as_echo "$libc_cv___builtin_dynamic_object_size" >&6; } + +case $enable_fortify_source in #( + 1|2) : + libc_cv_fortify_source=yes ;; #( + 3) : + if test "$libc_cv___builtin_dynamic_object_size" = yes; then : + libc_cv_fortify_source=yes +else + as_fn_error $? "Compiler doesn't provide necessary support for _FORTIFY_SOURCE=3" "$LINENO" 5 +fi ;; #( + *) : + libc_cv_fortify_source=no ;; +esac + +if test "$libc_cv_fortify_source" = yes; then : + fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}" + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the assembler requires one version per symbol" >&5 $as_echo_n "checking whether the assembler requires one version per symbol... " >&6; } if ${libc_cv_symver_needs_alias+:} false; then : diff --git a/configure.ac b/configure.ac index 21879c933c..860109e60a 100644 --- a/configure.ac +++ b/configure.ac @@ -466,6 +466,17 @@ AC_ARG_ENABLE([scv], AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)]) +dnl Build glibc with _FORTIFY_SOURCE +AC_ARG_ENABLE(fortify-source, + AS_HELP_STRING([--enable-fortify-source@<:@=1|2|3@:>@], + [Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler.]), + [enable_fortify_source=$enableval], + [enable_fortify_source=no]) +case "$enable_fortify_source" in +1|2|3|no|yes) ;; +*) AC_MSG_ERROR([Not a valid argument for --enable-fortify-source: "$enable_fortify_source"]);; +esac + # We keep the original values in `$config_*' and never modify them, so we # can write them unchanged into config.make. Everything else uses # $machine, $vendor, and $os, and changes them whenever convenient. @@ -1559,24 +1570,37 @@ if test "x$have_selinux" = xyes; then fi AC_SUBST(have_selinux) -CPPUNDEFS= -dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE. -dnl Since we are building the implementations of the fortified functions here, -dnl having the macro defined interacts very badly. -dnl _FORTIFY_SOURCE requires compiler optimization level 1 (gcc -O1) -dnl and above (see "man FEATURE_TEST_MACROS"). -dnl So do NOT replace AC_COMPILE_IFELSE with AC_PREPROC_IFELSE. -AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source, -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ -#ifdef _FORTIFY_SOURCE -# error bogon -#endif]])], - [libc_cv_predef_fortify_source=no], - [libc_cv_predef_fortify_source=yes])]) -if test $libc_cv_predef_fortify_source = yes; then - CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE" -fi -AC_SUBST(CPPUNDEFS) +dnl Check if we support the requested _FORTIFY_SOURCE level +dnl If not, then don't use it. +dnl Note that _FORTIFY_SOURCE may have been set through FLAGS too. +dnl _FORTIFY_SOURCE value will be selectively disabled for function that can't +dnl support it +no_fortify_source="-Wp,-U_FORTIFY_SOURCE" +fortify_source="${no_fortify_source}" + +AC_CACHE_CHECK([for __builtin_dynamic_object_size], [libc_cv___builtin_dynamic_object_size], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_dynamic_object_size("", 0)])], + [libc_cv___builtin_dynamic_object_size=yes + AS_IF([test "$enable_fortify_source" = yes], [enable_fortify_source=3])], + [libc_cv___builtin_dynamic_object_size=no + AS_IF([test "$enable_fortify_source" = yes], [enable_fortify_source=2])]) +]) + +AS_CASE([$enable_fortify_source], + [1|2], [libc_cv_fortify_source=yes], + [3], [AS_IF([test "$libc_cv___builtin_dynamic_object_size" = yes], + [libc_cv_fortify_source=yes], + [AC_MSG_ERROR([Compiler doesn't provide necessary support for _FORTIFY_SOURCE=3])])], + [libc_cv_fortify_source=no]) + +AS_IF([test "$libc_cv_fortify_source" = yes], + [fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}"] + ) + +AC_SUBST(enable_fortify_source) +AC_SUBST(libc_cv_fortify_source) +AC_SUBST(no_fortify_source) +AC_SUBST(fortify_source) dnl Starting with binutils 2.35, GAS can attach multiple symbol versions dnl to one symbol (PR 23840). diff --git a/elf/rtld-Rules b/elf/rtld-Rules index 56bc4543de..365a3408f3 100644 --- a/elf/rtld-Rules +++ b/elf/rtld-Rules @@ -144,6 +144,6 @@ cpp-srcs-left := $(rtld-modules:%.os=%) lib := rtld include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left)) -rtld-CFLAGS += $(no-stack-protector) +rtld-CFLAGS += $(no-stack-protector) $(no-fortify-source) endif diff --git a/manual/install.texi b/manual/install.texi index a44a552d1f..e9c66ba499 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -303,6 +303,14 @@ Specify the URL that users should visit if they wish to report a bug, to be included in @option{--help} output from programs installed with @theglibc{}. The default value refers to the main bug-reporting information for @theglibc{}. + +@item --enable-fortify-source +@itemx --enable-fortify-source=@var{LEVEL} +Use -D_FORTIFY_SOURCE=@option{LEVEL} to control hardening in the GNU C Library. +If not provided, @option{LEVEL} defaults to highest possible value supported by +the build compiler. + +Default is to disable fortification. @end table To build the library and related programs, type @code{make}. This will diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index e022abe284..e4eaec01e3 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -464,7 +464,9 @@ class Context(object): {'arch': 'i486', 'ccopts': '-m32 -march=i486'}, {'arch': 'i586', - 'ccopts': '-m32 -march=i586'}]) + 'ccopts': '-m32 -march=i586'}, + {'variant': 'enable-fortify-source', + 'cfg': ['--enable-fortify-source']}]) self.add_config(arch='x86_64', os_name='gnu', gcc_cfg=['--disable-multilib']) From patchwork Wed Jul 5 14:10:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803722 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=OFNGvDBv; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1pR1fdBz20ZQ for ; Thu, 6 Jul 2023 00:13:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23E94388265F for ; Wed, 5 Jul 2023 14:13:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23E94388265F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566381; bh=0SOYp6t3R20Gg1BCFE1FDVi9LLKXUYr/edgRKItaQRA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=OFNGvDBvssq/lXjKY/B8ZAA0k2IXjxhAd5+NvTmXC2SQy2iFmuCt2LO19xWRKGB1y KDjLDP4sFowxKa8IRJeAJnVZrewTkUmF9J3rvzAHPUva7GopiR782VbwCR9fklRcfB K8g1+XNuUcN1xP//Ns3H9SaQPrJUcVHi2v0VpzoU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B66CA385735D for ; Wed, 5 Jul 2023 14:11:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B66CA385735D Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-306-tGdos1TEPrGpmE4Zw0KkUw-1; Wed, 05 Jul 2023 10:11:10 -0400 X-MC-Unique: tGdos1TEPrGpmE4Zw0KkUw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3BA1104458F; Wed, 5 Jul 2023 14:11:09 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA7A6F5CF0; Wed, 5 Jul 2023 14:11:08 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 02/14] Exclude routines from fortification Date: Wed, 5 Jul 2023 16:10:37 +0200 Message-ID: <20230705141055.274575-3-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Since the _FORTIFY_SOURCE feature uses some routines of Glibc, they need to be excluded from the fortification. On top of that: - some tests explicitly verify that some level of fortification works appropriately, we therefore shouldn't modify the level set for them. - some objects need to be build with optimization disabled, which prevents _FORTIFY_SOURCE to be used for them. Assembler files that implement architecture specific versions of the fortified routines were not excluded from _FORTIFY_SOURCE as there is no C header included that would impact their behavior. Reviewed-by: Siddhesh Poyarekar --- debug/Makefile | 12 +-- io/Makefile | 16 ++++ libio/Makefile | 23 +++++- login/Makefile | 6 ++ misc/Makefile | 7 ++ posix/Makefile | 11 +++ rt/Makefile | 5 ++ setjmp/Makefile | 9 +++ socket/Makefile | 6 ++ stdio-common/Makefile | 15 +++- stdlib/Makefile | 7 ++ string/Makefile | 17 +++++ sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 81 +++++++++++++++++---- sysdeps/ieee754/ldbl-opt/Makefile | 29 ++++++++ sysdeps/pthread/Makefile | 4 + sysdeps/unix/sysv/linux/Makefile | 3 + wcsmbs/Makefile | 23 +++++- 17 files changed, 248 insertions(+), 26 deletions(-) diff --git a/debug/Makefile b/debug/Makefile index 9d658e3002..434e52f780 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -171,13 +171,13 @@ CFLAGS-recvfrom_chk.c += -fexceptions -fasynchronous-unwind-tables # set up for us, so keep the CFLAGS/CPPFLAGS split logical as the order is: # CFLAGS-tst-longjmp_chk.c += -fexceptions -fasynchronous-unwind-tables -CPPFLAGS-tst-longjmp_chk.c += -D_FORTIFY_SOURCE=1 +CPPFLAGS-tst-longjmp_chk.c += $(no-fortify-source),-D_FORTIFY_SOURCE=1 CFLAGS-tst-longjmp_chk2.c += -fexceptions -fasynchronous-unwind-tables -CPPFLAGS-tst-longjmp_chk2.c += -D_FORTIFY_SOURCE=1 +CPPFLAGS-tst-longjmp_chk2.c += $(no-fortify-source),-D_FORTIFY_SOURCE=1 CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables -CPPFLAGS-tst-longjmp_chk3.c += -D_FORTIFY_SOURCE=1 -CPPFLAGS-tst-realpath-chk.c += -D_FORTIFY_SOURCE=2 -CPPFLAGS-tst-chk-cancel.c += -D_FORTIFY_SOURCE=2 +CPPFLAGS-tst-longjmp_chk3.c += $(no-fortify-source),-D_FORTIFY_SOURCE=1 +CPPFLAGS-tst-realpath-chk.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 +CPPFLAGS-tst-chk-cancel.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 # _FORTIFY_SOURCE tests. # Auto-generate tests for _FORTIFY_SOURCE for different levels, compilers and @@ -215,7 +215,7 @@ src-chk-nongnu = \#undef _GNU_SOURCE # cannot be disabled via pragmas, so require -Wno-error to be used. define gen-chk-test tests-$(1)-$(4)-chk += tst-fortify-$(1)-$(2)-$(3)-$(4) -CFLAGS-tst-fortify-$(1)-$(2)-$(3)-$(4).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \ +CFLAGS-tst-fortify-$(1)-$(2)-$(3)-$(4).$(1) += $(no-fortify-source),-D_FORTIFY_SOURCE=$(3) -Wno-format \ -Wno-deprecated-declarations \ -Wno-error $(eval $(call cflags-$(2),$(1),$(3),$(4))) diff --git a/io/Makefile b/io/Makefile index d573064ecc..6ccc0e8691 100644 --- a/io/Makefile +++ b/io/Makefile @@ -149,6 +149,22 @@ routines := \ write \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + getcwd \ + getwd \ + open \ + open64 \ + openat \ + openat64 \ + poll \ + ppoll \ + read \ + readlink \ + readlinkat \ + ttyname_r \ + # routines_no_fortify + others := \ pwd \ # others diff --git a/libio/Makefile b/libio/Makefile index 2877fec484..287ec11338 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -53,6 +53,21 @@ routines := \ gen-as-const-headers += libio-macros.sym +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + fwprintf \ + iofgets \ + iofgets_u \ + iofgetws \ + iofgetws_u \ + swprintf \ + vasprintf \ + vsnprintf \ + vswprintf \ + vwprintf \ + wprintf \ + # routines_no_fortify + tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 \ tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \ @@ -165,11 +180,15 @@ CFLAGS-iofgets_u.c += $(config-cflags-wno-ignored-attributes) CFLAGS-iofputs_u.c += $(config-cflags-wno-ignored-attributes) # XXX Do we need filedoalloc and wfiledoalloc? Others? +# Prevent fortification as these are built with -O0 +CFLAGS-tst-bz24051.c += $(no-fortify-source) +CFLAGS-tst-bz24153.c += $(no-fortify-source) + CFLAGS-tst_putwc.c += -DOBJPFX=\"$(objpfx)\" # These test cases intentionally use overlapping arguments -CFLAGS-tst-sprintf-ub.c += -Wno-restrict -CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict +CFLAGS-tst-sprintf-ub.c += -Wno-restrict $(no-fortify-source) +CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict $(no-fortify-source) LDFLAGS-tst-bz24228 = -Wl,--version-script=tst-bz24228.map diff --git a/login/Makefile b/login/Makefile index 13b155d344..74216cbcb2 100644 --- a/login/Makefile +++ b/login/Makefile @@ -66,6 +66,12 @@ include ../Rules CFLAGS-getpt.c += -fexceptions CFLAGS-getlogin_r.c += $(config-cflags-wno-ignored-attributes) +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + getlogin_r \ + ptsname_r \ + # routines_no_fortify + ifeq (yesyes,$(have-fpie)$(build-shared)) pt_chown-cflags += $(pie-ccflag) endif diff --git a/misc/Makefile b/misc/Makefile index 84aa4cb0ad..36ba7a0bad 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -205,6 +205,13 @@ routines := \ writev \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + getdomain \ + gethostname \ + syslog \ + # routines_no_fortify + generated += \ tst-allocate_once-mem.out \ tst-allocate_once.mtrace \ diff --git a/posix/Makefile b/posix/Makefile index ad43cbdec6..5113ee3b74 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -183,6 +183,14 @@ routines := \ wordexp \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + confstr \ + getgroups \ + pread \ + pread64 \ + # routines_no_fortify + aux := \ environ \ init-posix \ @@ -604,6 +612,9 @@ bug-glob1-ARGS = "$(objpfx)" tst-execvp3-ARGS = --test-dir=$(objpfx) CFLAGS-tst-spawn3.c += -DOBJPFX=\"$(objpfx)\" +# Test voluntarily overflows struct dirent +CFLAGS-bug-glob2.c += $(no-fortify-source) + $(objpfx)testcases.h: TESTS TESTS2C.sed LC_ALL=C sed -f TESTS2C.sed < $< > $@T mv $@T $@ diff --git a/rt/Makefile b/rt/Makefile index a97333dc02..3d4a3f0eec 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -100,6 +100,11 @@ CFLAGS-aio_suspend.c += -fexceptions CFLAGS-mq_timedreceive.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-mq_timedsend.c += -fexceptions -fasynchronous-unwind-tables +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + mq_open \ + # routines_no_fortify + LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete $(objpfx)librt.so: $(shared-thread-library) diff --git a/setjmp/Makefile b/setjmp/Makefile index e5733a8c52..363fb6673c 100644 --- a/setjmp/Makefile +++ b/setjmp/Makefile @@ -38,4 +38,13 @@ gen-as-const-headers += jmp_buf-macros.sym include ../Rules +# This test messes the stack on purpose, which triggers longjump fortify +# failure +CFLAGS-bug269-setjmp.c += $(no-fortify-source) + +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + longjmp \ + # routines_no_fortify + $(objpfx)tst-setjmp-fp: $(libm) diff --git a/socket/Makefile b/socket/Makefile index d9b0b4af64..08f20118cd 100644 --- a/socket/Makefile +++ b/socket/Makefile @@ -60,6 +60,12 @@ routines := \ socketpair \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + recv \ + recvfrom \ + # routines_no_fortify + tests := \ tst-accept4 \ tst-cmsg_cloexec \ diff --git a/stdio-common/Makefile b/stdio-common/Makefile index 8871ec7668..fe304b8373 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -117,6 +117,19 @@ routines := \ wprintf_function_invoke \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + asprintf \ + dprintf \ + fprintf \ + printf \ + snprintf \ + sprintf \ + vfprintf \ + vfwprintf \ + vprintf \ + # routines_no_fortify + aux := \ errlist \ errlist-data \ @@ -461,7 +474,7 @@ CFLAGS-tst-gets.c += -Wno-deprecated-declarations # BZ #11319 was first fixed for regular vdprintf, then reopened because # the fortified version had the same bug. -CFLAGS-tst-bz11319-fortify2.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 +CFLAGS-tst-bz11319-fortify2.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf diff --git a/stdlib/Makefile b/stdlib/Makefile index 0975f55ee6..25e42a77e7 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -145,6 +145,13 @@ routines := \ xpg_basename \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + mbstowcs \ + wcstombs \ + wctomb \ + # routines_no_fortify + aux = \ grouping \ groupingwc \ diff --git a/string/Makefile b/string/Makefile index d3106d10a9..8cdfd5b000 100644 --- a/string/Makefile +++ b/string/Makefile @@ -118,6 +118,23 @@ routines := \ xpg-strerror \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + explicit_bzero \ + memcpy \ + memmove \ + mempcpy \ + memset \ + stpcpy \ + stpncpy \ + strcat \ + strcpy \ + strlcat \ + strlcpy \ + strncat \ + strncpy \ + # routines_no_fortify + tests := \ bug-envz1 \ bug-strcoll1 \ diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 42cca25a09..34273a5f58 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -88,13 +88,19 @@ tests-internal += test-wprintf-ieee128 test-wprintf-ibm128 CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +# The following tests are setting _FORTIFY_SOURCE internally tests-internal += test-obstack-ieee128 test-obstack-ibm128 -CFLAGS-test-obstack-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -CFLAGS-test-obstack-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-test-obstack-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi \ + $(no-fortify-source) +CFLAGS-test-obstack-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + $(no-fortify-source) +# The following tests are setting _FORTIFY_SOURCE internally tests-internal += test-obstack-chk-ieee128 test-obstack-chk-ibm128 -CFLAGS-test-obstack-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -CFLAGS-test-obstack-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-test-obstack-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi \ + $(no-fortify-source) +CFLAGS-test-obstack-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + $(no-fortify-source) tests-internal += test-scanf-ieee128 test-scanf-ibm128 CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -std=c89 -D_GNU_SOURCE @@ -216,25 +222,37 @@ ldbl-extra-routines += asprintf_chk \ obstack_chk \ vobstack_chk +# The following tests are setting _FORTIFY_SOURCE internally tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128 -CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -CFLAGS-test-printf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi \ + $(no-fortify-source) +CFLAGS-test-printf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + $(no-fortify-source) +# The following tests are setting _FORTIFY_SOURCE internally tests-internal += test-printf-chk-redir-ieee128 test-printf-chk-redir-ibm128 CFLAGS-test-printf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \ - -Wno-psabi -Wno-unused-result + -Wno-psabi -Wno-unused-result \ + $(no-fortify-source) CFLAGS-test-printf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ - -Wno-unused-result + -Wno-unused-result \ + $(no-fortify-source) +# The following tests are setting _FORTIFY_SOURCE internally tests-internal += test-wprintf-chk-ieee128 test-wprintf-chk-ibm128 -CFLAGS-test-wprintf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -CFLAGS-test-wprintf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-test-wprintf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi \ + $(no-fortify-source) +CFLAGS-test-wprintf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + $(no-fortify-source) +# The following tests are setting _FORTIFY_SOURCE internally tests-internal += test-wprintf-chk-redir-ieee128 test-wprintf-chk-redir-ibm128 CFLAGS-test-wprintf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \ - -Wno-psabi -Wno-unused-result + -Wno-psabi -Wno-unused-result \ + $(no-fortify-source) CFLAGS-test-wprintf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ - -Wno-unused-result + -Wno-unused-result \ + $(no-fortify-source) endif ifeq ($(subdir),argp) @@ -281,13 +299,19 @@ CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-tst-ieee128-efgcvt.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-tst-ieee128-errorfptr.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +# The following tests are setting _FORTIFY_SOURCE internally tests-container += test-syslog-ieee128 test-syslog-ibm128 -CFLAGS-test-syslog-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -CFLAGS-test-syslog-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-test-syslog-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi \ + $(no-fortify-source) +CFLAGS-test-syslog-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + $(no-fortify-source) +# The following tests are setting _FORTIFY_SOURCE internally tests-container += test-syslog-chk-ieee128 test-syslog-chk-ibm128 -CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi \ + $(no-fortify-source) +CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + $(no-fortify-source) endif ifeq ($(subdir),stdlib) @@ -395,6 +419,31 @@ endif # Add IEEE binary128 files as make targets. routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) +routines_no_fortify += \ + ieee128-asprintf \ + ieee128-dprintf \ + ieee128-fprintf \ + ieee128-fwprintf \ + ieee128-obstack \ + ieee128-printf \ + ieee128-snprintf \ + ieee128-sprintf \ + ieee128-swprintf \ + ieee128-syslog \ + ieee128-vasprintf \ + ieee128-vdprintf \ + ieee128-vfprintf \ + ieee128-vfwprintf \ + ieee128-vobstack \ + ieee128-vprintf \ + ieee128-vsnprintf \ + ieee128-vsprintf \ + ieee128-vswprintf \ + ieee128-vsyslog \ + ieee128-vwprintf \ + ieee128-wprintf \ + # routines_no_fortify + # On powerpc64le, the routines responsible for converting between long # double and string (e.g.: printf, scanf, strtold, strfroml) default to # IBM long double mode. When support for TS 18661-3 was added, several diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile index 22e778ad0e..0ed1cd2cae 100644 --- a/sysdeps/ieee754/ldbl-opt/Makefile +++ b/sysdeps/ieee754/ldbl-opt/Makefile @@ -269,3 +269,32 @@ CFLAGS-tst-nldbl-wscanf-binary-gnu89.c += -mlong-double-64 -std=gnu89 \ -DOBJPFX=\"$(objpfx)\" endif + +routines_no_fortify += \ + nldbl-asprintf \ + nldbl-dprintf \ + nldbl-fprintf \ + nldbl-fwprintf \ + nldbl-obstack_printf \ + nldbl-obstack_vprintf \ + nldbl-printf \ + nldbl-snprintf \ + nldbl-sprintf \ + nldbl-swprintf \ + nldbl-syslog \ + nldbl-vasprintf \ + nldbl-vdprintf \ + nldbl-vfprintf \ + nldbl-vfwprintf \ + nldbl-vprintf \ + nldbl-vsnprintf \ + nldbl-vsprintf \ + nldbl-vswprintf \ + nldbl-vsyslog \ + nldbl-vwprintf \ + nldbl-wprintf \ + # routines_no_fortify + +# We can't rely on Makeconfig here for whatever reason +CFLAGS-.oS += $(call elide-fortify-source,.oS,$(routines_no_fortify)) +CFLAGS-.oS += $(call elide-fortify-source,_chk.oS,$(routines_no_fortify)) diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index 32cf4eb119..31028406d5 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -304,6 +304,10 @@ tests-nolibpthread += \ CFLAGS-tst-cleanup2.c += -fno-builtin CFLAGS-tst-cleanupx2.c += -fno-builtin +# Disable fortification due to sprintf(NULL,...) +CFLAGS-tst-cleanup2.c += $(no-fortify-source) +CFLAGS-tst-cleanupx2.c += $(no-fortify-source) + tests += \ tst-cancelx2 \ tst-cancelx3 \ diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 23a84cf225..be801e3be4 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -120,6 +120,9 @@ CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-pselect32.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))" +# The test triggers FORTIFY abortion due to purposely wrong parameters +CFLAGS-test-errno-linux.c += $(no-fortify-source) + sysdep_headers += \ bits/a.out.h \ bits/epoll.h \ diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index 22192985e1..d25a2214f8 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -121,6 +121,27 @@ routines := \ wmemset \ # routines +# Exclude fortified routines from being built with _FORTIFY_SOURCE +routines_no_fortify += \ + mbsnrtowcs \ + mbsrtowcs \ + wcpcpy \ + wcpncpy \ + wcrtomb \ + wcscat \ + wcscpy \ + wcslcat \ + wcslcpy \ + wcsncat \ + wcsncpy \ + wcsnrtombs \ + wcsrtombs \ + wmemcpy \ + wmemmove \ + wmempcpy \ + wmemset \ + # routines_no_fortify + tests := \ test-c8rtomb \ test-char-types \ @@ -231,7 +252,7 @@ CFLAGS-wcstod_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) CFLAGS-wcstold_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) CFLAGS-wcstof128_l.c += $(strtox-CFLAGS) CFLAGS-wcstof_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) -CPPFLAGS-tst-wchar-h.c += -D_FORTIFY_SOURCE=2 +CPPFLAGS-tst-wchar-h.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 CFLAGS-wcschr.c += $(config-cflags-wno-ignored-attributes) CFLAGS-wmemchr.c += $(config-cflags-wno-ignored-attributes) From patchwork Wed Jul 5 14:10:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Uhnco1bL; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1nH2hDVz20ZQ for ; Thu, 6 Jul 2023 00:12:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D526385E03D for ; Wed, 5 Jul 2023 14:12:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D526385E03D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566321; bh=kJ2dRhgCD2bXX136yX7vIGUR9KR9+DgPK+hyqAj25x8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Uhnco1bLmWGcLOkU0bIQ0S1MijcJ2LUDu5cGropGtbMJ1pJq1naFY91Mp+3227/rF 3I5WHa2cN+P0bK3woszlqq24o/r4Zu6Cx4UW1iK15At/VQF6KOaDEkkKXGP2Kj8c0w Ox/+tBamFyxrVyeX/pne2yCS7cn7VFBUlMk9dQ+k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C0ED03856DC7 for ; Wed, 5 Jul 2023 14:11:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0ED03856DC7 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-L6S-DyyvPvqngZ0GBnhyZw-1; Wed, 05 Jul 2023 10:11:11 -0400 X-MC-Unique: L6S-DyyvPvqngZ0GBnhyZw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6A76101A528; Wed, 5 Jul 2023 14:11:10 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04D39F5CF0; Wed, 5 Jul 2023 14:11:09 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar , "Paul E . Murphy" Subject: [PATCH v5 03/14] sysdeps: Ensure ieee128*_chk routines to be properly named Date: Wed, 5 Jul 2023 16:10:38 +0200 Message-ID: <20230705141055.274575-4-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The *_chk routines naming doesn't match the name that would be generated using libc_hidden_ldbl_proto. Since the macro is needed for some of these *_chk functions for _FORTIFY_SOURCE to be enabled, that needed to be fixed. While at it, all the *_chk function get renamed appropriately for consistency, even if not strictly necessary. Reviewed-by: Siddhesh Poyarekar Reviewed-by: Paul E. Murphy --- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c | 8 ++++---- .../ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c | 4 ++-- .../ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c | 4 ++-- .../ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c | 4 ++-- .../ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c | 4 ++-- sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c | 4 ++-- 19 files changed, 40 insertions(+), 40 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c index a50e334a2c..fbf953a728 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_asprintf_chk (char **string_ptr, int flag, const char *format, ...) +___ieee128___asprintf_chk (char **string_ptr, int flag, const char *format, ...) { va_list ap; int done; @@ -35,4 +35,4 @@ ___ieee128_asprintf_chk (char **string_ptr, int flag, const char *format, ...) return done; } -strong_alias (___ieee128_asprintf_chk, __asprintf_chkieee128) +strong_alias (___ieee128___asprintf_chk, __asprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c index b53b06a513..7121020ed5 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_dprintf_chk (int d, int flag, const char *format, ...) +___ieee128___dprintf_chk (int d, int flag, const char *format, ...) { va_list ap; int done; @@ -35,4 +35,4 @@ ___ieee128_dprintf_chk (int d, int flag, const char *format, ...) return done; } -strong_alias (___ieee128_dprintf_chk, __dprintf_chkieee128) +strong_alias (___ieee128___dprintf_chk, __dprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c index 44eed0de99..bd10e9c3db 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_fprintf_chk (FILE *fp, int flag, const char *format, ...) +___ieee128___fprintf_chk (FILE *fp, int flag, const char *format, ...) { va_list ap; int done; @@ -35,4 +35,4 @@ ___ieee128_fprintf_chk (FILE *fp, int flag, const char *format, ...) return done; } -strong_alias (___ieee128_fprintf_chk, __fprintf_chkieee128) +strong_alias (___ieee128___fprintf_chk, __fprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c index 83c2f8e8d7..5b6cc3e768 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_fwprintf_chk (FILE *fp, int flag, const wchar_t *format, ...) +___ieee128___fwprintf_chk (FILE *fp, int flag, const wchar_t *format, ...) { va_list ap; int done; @@ -35,4 +35,4 @@ ___ieee128_fwprintf_chk (FILE *fp, int flag, const wchar_t *format, ...) return done; } -strong_alias (___ieee128_fwprintf_chk, __fwprintf_chkieee128) +strong_alias (___ieee128___fwprintf_chk, __fwprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c index ab5fe59c37..333f4e14b1 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_printf_chk (int flag, const char *format, ...) +___ieee128___printf_chk (int flag, const char *format, ...) { va_list ap; int done; @@ -35,4 +35,4 @@ ___ieee128_printf_chk (int flag, const char *format, ...) return done; } -strong_alias (___ieee128_printf_chk, __printf_chkieee128) +strong_alias (___ieee128___printf_chk, __printf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c index 0ff2486642..a65f193dc1 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_snprintf_chk (char *s, size_t maxlen, int flag, size_t slen, +___ieee128___snprintf_chk (char *s, size_t maxlen, int flag, size_t slen, const char *format, ...) { va_list ap; @@ -39,4 +39,4 @@ ___ieee128_snprintf_chk (char *s, size_t maxlen, int flag, size_t slen, return done; } -strong_alias (___ieee128_snprintf_chk, __snprintf_chkieee128) +strong_alias (___ieee128___snprintf_chk, __snprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c index a0e598db42..0039c3b53d 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_sprintf_chk (char *s, int flag, size_t slen, +___ieee128___sprintf_chk (char *s, int flag, size_t slen, const char *format, ...) { va_list ap; @@ -43,4 +43,4 @@ ___ieee128_sprintf_chk (char *s, int flag, size_t slen, return done; } -strong_alias (___ieee128_sprintf_chk, __sprintf_chkieee128) +strong_alias (___ieee128___sprintf_chk, __sprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c index 2453c231b8..b81e9ccc05 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_swprintf_chk (wchar_t *string, size_t maxlen, int flag, +___ieee128___swprintf_chk (wchar_t *string, size_t maxlen, int flag, size_t slen, const wchar_t *format, ...) { va_list ap; @@ -39,4 +39,4 @@ ___ieee128_swprintf_chk (wchar_t *string, size_t maxlen, int flag, return done; } -strong_alias (___ieee128_swprintf_chk, __swprintf_chkieee128) +strong_alias (___ieee128___swprintf_chk, __swprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c index 4ed4621b96..18aa7f707f 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c @@ -40,7 +40,7 @@ ___ieee128_vsyslog (int pri, const char *fmt, va_list ap) strong_alias (___ieee128_vsyslog, __vsyslogieee128) void -___ieee128_syslog_chk (int pri, int flag, const char *fmt, ...) +___ieee128___syslog_chk (int pri, int flag, const char *fmt, ...) { va_list ap; @@ -52,10 +52,10 @@ ___ieee128_syslog_chk (int pri, int flag, const char *fmt, ...) __vsyslog_internal (pri, fmt, ap, mode); va_end (ap); } -strong_alias (___ieee128_syslog_chk, __syslog_chkieee128) +strong_alias (___ieee128___syslog_chk, __syslog_chkieee128) void -___ieee128_vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) +___ieee128___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; if (flag > 0) @@ -63,4 +63,4 @@ ___ieee128_vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) __vsyslog_internal (pri, fmt, ap, mode); } -strong_alias (___ieee128_vsyslog_chk, __vsyslog_chkieee128) +strong_alias (___ieee128___vsyslog_chk, __vsyslog_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c index 5350e777f3..a5a048f2b5 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vasprintf_chk (char **result_ptr, int flag, const char *format, +___ieee128___vasprintf_chk (char **result_ptr, int flag, const char *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; @@ -28,4 +28,4 @@ ___ieee128_vasprintf_chk (char **result_ptr, int flag, const char *format, return __vasprintf_internal (result_ptr, format, ap, mode); } -strong_alias (___ieee128_vasprintf_chk, __vasprintf_chkieee128) +strong_alias (___ieee128___vasprintf_chk, __vasprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c index 7e38917cb5..ac7f26ec6d 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vdprintf_chk (int d, int flag, const char *format, va_list ap) +___ieee128___vdprintf_chk (int d, int flag, const char *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; if (flag > 0) @@ -27,4 +27,4 @@ ___ieee128_vdprintf_chk (int d, int flag, const char *format, va_list ap) return __vdprintf_internal (d, format, ap, mode); } -strong_alias (___ieee128_vdprintf_chk, __vdprintf_chkieee128) +strong_alias (___ieee128___vdprintf_chk, __vdprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c index bf2ace508f..50c12265bc 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap) +___ieee128___vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; if (flag > 0) @@ -27,4 +27,4 @@ ___ieee128_vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap) return __vfprintf_internal (fp, format, ap, mode); } -strong_alias (___ieee128_vfprintf_chk, __vfprintf_chkieee128) +strong_alias (___ieee128___vfprintf_chk, __vfprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c index b2379176f2..a5005927dc 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vfwprintf_chk (FILE *fp, int flag, const wchar_t *format, +___ieee128___vfwprintf_chk (FILE *fp, int flag, const wchar_t *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; @@ -28,4 +28,4 @@ ___ieee128_vfwprintf_chk (FILE *fp, int flag, const wchar_t *format, return __vfwprintf_internal (fp, format, ap, mode); } -strong_alias (___ieee128_vfwprintf_chk, __vfwprintf_chkieee128) +strong_alias (___ieee128___vfwprintf_chk, __vfwprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c index ca718d06bb..1281e41b6f 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vprintf_chk (int flag, const char *format, va_list ap) +___ieee128___vprintf_chk (int flag, const char *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; if (flag > 0) @@ -27,4 +27,4 @@ ___ieee128_vprintf_chk (int flag, const char *format, va_list ap) return __vfprintf_internal (stdout, format, ap, mode); } -strong_alias (___ieee128_vprintf_chk, __vprintf_chkieee128) +strong_alias (___ieee128___vprintf_chk, __vprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c index 79d359b5d4..d91e8fa956 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vsnprintf_chk (char *string, size_t maxlen, int flag, +___ieee128___vsnprintf_chk (char *string, size_t maxlen, int flag, size_t slen, const char *format, va_list ap) { if (__glibc_unlikely (slen < maxlen)) @@ -31,4 +31,4 @@ ___ieee128_vsnprintf_chk (char *string, size_t maxlen, int flag, return __vsnprintf_internal (string, maxlen, format, ap, mode); } -strong_alias (___ieee128_vsnprintf_chk, __vsnprintf_chkieee128) +strong_alias (___ieee128___vsnprintf_chk, __vsnprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c index b4b2b2d14f..22137269c0 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vsprintf_chk (char *string, int flag, size_t slen, +___ieee128___vsprintf_chk (char *string, int flag, size_t slen, const char *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; @@ -35,4 +35,4 @@ ___ieee128_vsprintf_chk (char *string, int flag, size_t slen, return __vsprintf_internal (string, slen, format, ap, mode); } -strong_alias (___ieee128_vsprintf_chk, __vsprintf_chkieee128) +strong_alias (___ieee128___vsprintf_chk, __vsprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c index 9cd56ba5d4..888513d3c6 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vswprintf_chk (wchar_t *string, size_t maxlen, int flag, +___ieee128___vswprintf_chk (wchar_t *string, size_t maxlen, int flag, size_t slen, const wchar_t *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; @@ -31,4 +31,4 @@ ___ieee128_vswprintf_chk (wchar_t *string, size_t maxlen, int flag, return __vswprintf_internal (string, maxlen, format, ap, mode); } -strong_alias (___ieee128_vswprintf_chk, __vswprintf_chkieee128) +strong_alias (___ieee128___vswprintf_chk, __vswprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c index 3861edf480..f61f2d6c44 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c @@ -19,7 +19,7 @@ #include extern int -___ieee128_vwprintf_chk (int flag, const wchar_t *format, va_list ap) +___ieee128___vwprintf_chk (int flag, const wchar_t *format, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; if (flag > 0) @@ -27,4 +27,4 @@ ___ieee128_vwprintf_chk (int flag, const wchar_t *format, va_list ap) return __vfwprintf_internal (stdout, format, ap, mode); } -strong_alias (___ieee128_vwprintf_chk, __vwprintf_chkieee128) +strong_alias (___ieee128___vwprintf_chk, __vwprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c index 440e0691cb..19d9a92dd2 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_wprintf_chk (int flag, const wchar_t *format, ...) +___ieee128___wprintf_chk (int flag, const wchar_t *format, ...) { va_list ap; int done; @@ -35,4 +35,4 @@ ___ieee128_wprintf_chk (int flag, const wchar_t *format, ...) return done; } -strong_alias (___ieee128_wprintf_chk, __wprintf_chkieee128) +strong_alias (___ieee128___wprintf_chk, __wprintf_chkieee128) From patchwork Wed Jul 5 14:10:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=W1NVT6by; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1qk3tGTz20ZQ for ; Thu, 6 Jul 2023 00:14:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D9B63889E12 for ; Wed, 5 Jul 2023 14:14:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D9B63889E12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566448; bh=kqs+rZsZWO4NfSXpCqvrPjXPsvRCljePEcFqPuLV7ec=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=W1NVT6by+hhnTNJuBNNeRnte0r0a7f5g2TkV0x5/FzdzxDup4umkpsomxxRfp3s+f uqVHlX2Xxed4KGCiJVetnbeCKb9tb7iyCGU3MrIukVyOYOTtz2diYuIYx2WJ8y8SpU 76+flewvRlFmKfTEDyHn9Ia1thn1lXNiiJPiiOZo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id AEA873856967 for ; Wed, 5 Jul 2023 14:11:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEA873856967 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-PP4z45i4MoiB0ctiOAOhlQ-1; Wed, 05 Jul 2023 10:11:19 -0400 X-MC-Unique: PP4z45i4MoiB0ctiOAOhlQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AACF03811F30; Wed, 5 Jul 2023 14:11:11 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06F0EF5CF0; Wed, 5 Jul 2023 14:11:10 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 04/14] string: Ensure *_chk routines have their hidden builtin definition available Date: Wed, 5 Jul 2023 16:10:39 +0200 Message-ID: <20230705141055.274575-5-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" If libc_hidden_builtin_{def,proto} isn't properly set for *_chk routines, there are unwanted PLT entries in libc.so. Reviewed-by: Siddhesh Poyarekar --- debug/memcpy_chk.c | 1 + debug/memmove_chk.c | 1 + debug/mempcpy_chk.c | 1 + debug/memset_chk.c | 1 + debug/stpcpy_chk.c | 1 + include/string.h | 7 +++++++ sysdeps/i386/i586/memcpy.S | 1 + sysdeps/i386/i586/memset.S | 1 + sysdeps/i386/i686/memcpy.S | 1 + sysdeps/i386/i686/memmove.S | 1 + sysdeps/i386/i686/mempcpy.S | 1 + sysdeps/i386/i686/memset.S | 1 + sysdeps/i386/i686/multiarch/memcpy_chk.c | 4 ++++ sysdeps/i386/i686/multiarch/memmove_chk.c | 4 ++++ sysdeps/i386/i686/multiarch/mempcpy_chk.c | 4 ++++ sysdeps/i386/i686/multiarch/memset_chk.c | 5 ++++- sysdeps/i386/memcpy_chk.S | 1 + sysdeps/i386/memmove_chk.S | 1 + sysdeps/i386/mempcpy_chk.S | 1 + sysdeps/i386/memset_chk.S | 1 + sysdeps/x86_64/memcpy_chk.S | 1 + sysdeps/x86_64/memmove_chk.S | 1 + sysdeps/x86_64/mempcpy_chk.S | 1 + sysdeps/x86_64/memset_chk.S | 1 + sysdeps/x86_64/multiarch/memcpy_chk.c | 4 ++++ sysdeps/x86_64/multiarch/memmove_chk.c | 4 ++++ sysdeps/x86_64/multiarch/mempcpy_chk.c | 4 ++++ sysdeps/x86_64/multiarch/memset_chk.c | 4 ++++ 28 files changed, 58 insertions(+), 1 deletion(-) diff --git a/debug/memcpy_chk.c b/debug/memcpy_chk.c index c6dd94c83f..1e4a82c063 100644 --- a/debug/memcpy_chk.c +++ b/debug/memcpy_chk.c @@ -28,3 +28,4 @@ __memcpy_chk (void *dstpp, const void *srcpp, size_t len, size_t dstlen) return memcpy (dstpp, srcpp, len); } +libc_hidden_builtin_def (__memcpy_chk) diff --git a/debug/memmove_chk.c b/debug/memmove_chk.c index 8922a1ba26..b714aa474c 100644 --- a/debug/memmove_chk.c +++ b/debug/memmove_chk.c @@ -32,3 +32,4 @@ MEMMOVE_CHK (void *dest, const void *src, size_t len, size_t destlen) return memmove (dest, src, len); } +libc_hidden_builtin_def (MEMMOVE_CHK) diff --git a/debug/mempcpy_chk.c b/debug/mempcpy_chk.c index 17a46a3b4d..b47b14ee9a 100644 --- a/debug/mempcpy_chk.c +++ b/debug/mempcpy_chk.c @@ -29,3 +29,4 @@ __mempcpy_chk (void *dstpp, const void *srcpp, size_t len, size_t dstlen) return __mempcpy (dstpp, srcpp, len); } +libc_hidden_builtin_def (__mempcpy_chk) diff --git a/debug/memset_chk.c b/debug/memset_chk.c index 4fc0b55d82..93901f5f34 100644 --- a/debug/memset_chk.c +++ b/debug/memset_chk.c @@ -26,3 +26,4 @@ __memset_chk (void *dstpp, int c, size_t len, size_t dstlen) return memset (dstpp, c, len); } +libc_hidden_builtin_def (__memset_chk) diff --git a/debug/stpcpy_chk.c b/debug/stpcpy_chk.c index 230b52bd01..518dd78dca 100644 --- a/debug/stpcpy_chk.c +++ b/debug/stpcpy_chk.c @@ -32,3 +32,4 @@ __stpcpy_chk (char *dest, const char *src, size_t destlen) return memcpy (dest, src, len + 1) + len; } +libc_hidden_builtin_def (__stpcpy_chk) diff --git a/include/string.h b/include/string.h index 0c78ad2539..659530d1aa 100644 --- a/include/string.h +++ b/include/string.h @@ -208,6 +208,13 @@ extern char *__strcat_chk (char *__restrict __dest, extern char *__strncat_chk (char *__restrict __dest, const char *__restrict __src, size_t __len, size_t __destlen) __THROW; + +libc_hidden_builtin_proto (__memcpy_chk) +libc_hidden_builtin_proto (__memmove_chk) +libc_hidden_builtin_proto (__mempcpy_chk) +libc_hidden_builtin_proto (__memset_chk) +libc_hidden_builtin_proto (__stpcpy_chk) + #endif #endif diff --git a/sysdeps/i386/i586/memcpy.S b/sysdeps/i386/i586/memcpy.S index 58061d5adf..e3405e577c 100644 --- a/sysdeps/i386/i586/memcpy.S +++ b/sysdeps/i386/i586/memcpy.S @@ -32,6 +32,7 @@ ENTRY (__memcpy_chk) cmpl %eax, 16(%esp) jb HIDDEN_JUMPTARGET (__chk_fail) END (__memcpy_chk) +libc_hidden_builtin_def (__memcpy_chk) #endif ENTRY (memcpy) diff --git a/sysdeps/i386/i586/memset.S b/sysdeps/i386/i586/memset.S index 413e8ec6a9..f1f0e1a99b 100644 --- a/sysdeps/i386/i586/memset.S +++ b/sysdeps/i386/i586/memset.S @@ -33,6 +33,7 @@ ENTRY (__memset_chk) cmpl %eax, 16(%esp) jb HIDDEN_JUMPTARGET (__chk_fail) END (__memset_chk) +libc_hidden_builtin_def (__memset_chk) #endif ENTRY (memset) diff --git a/sysdeps/i386/i686/memcpy.S b/sysdeps/i386/i686/memcpy.S index 604d3088f6..9b48ec0ea1 100644 --- a/sysdeps/i386/i686/memcpy.S +++ b/sysdeps/i386/i686/memcpy.S @@ -33,6 +33,7 @@ ENTRY_CHK (__memcpy_chk) cmpl %eax, 16(%esp) jb HIDDEN_JUMPTARGET (__chk_fail) END_CHK (__memcpy_chk) +libc_hidden_builtin_def (__memcpy_chk) #endif ENTRY (memcpy) diff --git a/sysdeps/i386/i686/memmove.S b/sysdeps/i386/i686/memmove.S index cff06c27e5..06fe2a7668 100644 --- a/sysdeps/i386/i686/memmove.S +++ b/sysdeps/i386/i686/memmove.S @@ -35,6 +35,7 @@ ENTRY_CHK (__memmove_chk) cmpl %eax, 16(%esp) jb HIDDEN_JUMPTARGET (__chk_fail) END_CHK (__memmove_chk) +libc_hidden_builtin_def (__memmove_chk) #endif ENTRY (memmove) diff --git a/sysdeps/i386/i686/mempcpy.S b/sysdeps/i386/i686/mempcpy.S index af3f2cca08..26f8501e7d 100644 --- a/sysdeps/i386/i686/mempcpy.S +++ b/sysdeps/i386/i686/mempcpy.S @@ -33,6 +33,7 @@ ENTRY_CHK (__mempcpy_chk) cmpl %eax, 16(%esp) jb HIDDEN_JUMPTARGET (__chk_fail) END_CHK (__mempcpy_chk) +libc_hidden_builtin_def (__mempcpy_chk) #endif ENTRY (__mempcpy) diff --git a/sysdeps/i386/i686/memset.S b/sysdeps/i386/i686/memset.S index d4891880d7..0b5e671d83 100644 --- a/sysdeps/i386/i686/memset.S +++ b/sysdeps/i386/i686/memset.S @@ -33,6 +33,7 @@ ENTRY_CHK (__memset_chk) cmpl %eax, 16(%esp) jb HIDDEN_JUMPTARGET (__chk_fail) END_CHK (__memset_chk) +libc_hidden_builtin_def (__memset_chk) #endif ENTRY (memset) diff --git a/sysdeps/i386/i686/multiarch/memcpy_chk.c b/sysdeps/i386/i686/multiarch/memcpy_chk.c index 5ac5cb1d7a..ec945dc91f 100644 --- a/sysdeps/i386/i686/multiarch/memcpy_chk.c +++ b/sysdeps/i386/i686/multiarch/memcpy_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_memcpy_chk, __memcpy_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__memcpy_chk, __GI___memcpy_chk, __redirect_memcpy_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memcpy_chk); +# endif #endif diff --git a/sysdeps/i386/i686/multiarch/memmove_chk.c b/sysdeps/i386/i686/multiarch/memmove_chk.c index 28161d3c27..55c7601d5d 100644 --- a/sysdeps/i386/i686/multiarch/memmove_chk.c +++ b/sysdeps/i386/i686/multiarch/memmove_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_memmove_chk, __memmove_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__memmove_chk, __GI___memmove_chk, __redirect_memmove_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memmove_chk); +# endif #endif diff --git a/sysdeps/i386/i686/multiarch/mempcpy_chk.c b/sysdeps/i386/i686/multiarch/mempcpy_chk.c index 36c81ae61a..83569cf9d9 100644 --- a/sysdeps/i386/i686/multiarch/mempcpy_chk.c +++ b/sysdeps/i386/i686/multiarch/mempcpy_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_mempcpy_chk, __mempcpy_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__mempcpy_chk, __GI___mempcpy_chk, __redirect_mempcpy_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__mempcpy_chk); +# endif #endif diff --git a/sysdeps/i386/i686/multiarch/memset_chk.c b/sysdeps/i386/i686/multiarch/memset_chk.c index cf3e811327..1a7503858d 100644 --- a/sysdeps/i386/i686/multiarch/memset_chk.c +++ b/sysdeps/i386/i686/multiarch/memset_chk.c @@ -28,5 +28,8 @@ libc_ifunc_redirected (__redirect_memset_chk, __memset_chk, IFUNC_SELECTOR ()); - +# ifdef SHARED +__hidden_ver1 (__memset_chk, __GI___memset_chk, __redirect_memset_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memset_chk); +# endif #endif diff --git a/sysdeps/i386/memcpy_chk.S b/sysdeps/i386/memcpy_chk.S index b5244cc69b..7b12c12aba 100644 --- a/sysdeps/i386/memcpy_chk.S +++ b/sysdeps/i386/memcpy_chk.S @@ -31,4 +31,5 @@ ENTRY (__memcpy_chk) jb __chk_fail jmp memcpy END (__memcpy_chk) +libc_hidden_builtin_def (__memcpy_chk) #endif diff --git a/sysdeps/i386/memmove_chk.S b/sysdeps/i386/memmove_chk.S index 517d8cb15a..604aea8305 100644 --- a/sysdeps/i386/memmove_chk.S +++ b/sysdeps/i386/memmove_chk.S @@ -30,4 +30,5 @@ ENTRY (__memmove_chk) jb __chk_fail jmp memmove END (__memmove_chk) +libc_hidden_builtin_def (MEMMOVE_CHK) #endif diff --git a/sysdeps/i386/mempcpy_chk.S b/sysdeps/i386/mempcpy_chk.S index 1e9bf71bfb..276eab1e8a 100644 --- a/sysdeps/i386/mempcpy_chk.S +++ b/sysdeps/i386/mempcpy_chk.S @@ -30,4 +30,5 @@ ENTRY (__mempcpy_chk) jb __chk_fail jmp __mempcpy END (__mempcpy_chk) +libc_hidden_builtin_def (__mempcpy_chk) #endif diff --git a/sysdeps/i386/memset_chk.S b/sysdeps/i386/memset_chk.S index 0e6060a0a6..a2e9208e1c 100644 --- a/sysdeps/i386/memset_chk.S +++ b/sysdeps/i386/memset_chk.S @@ -30,4 +30,5 @@ ENTRY (__memset_chk) jb __chk_fail jmp memset END (__memset_chk) +libc_hidden_builtin_def (__memset_chk) #endif diff --git a/sysdeps/x86_64/memcpy_chk.S b/sysdeps/x86_64/memcpy_chk.S index 25cbeb37ee..43843a7abb 100644 --- a/sysdeps/x86_64/memcpy_chk.S +++ b/sysdeps/x86_64/memcpy_chk.S @@ -30,4 +30,5 @@ ENTRY (__memcpy_chk) jb __chk_fail jmp memcpy END (__memcpy_chk) +libc_hidden_builtin_def (__memcpy_chk) #endif diff --git a/sysdeps/x86_64/memmove_chk.S b/sysdeps/x86_64/memmove_chk.S index 165d42cfa8..37e2c30ba8 100644 --- a/sysdeps/x86_64/memmove_chk.S +++ b/sysdeps/x86_64/memmove_chk.S @@ -30,4 +30,5 @@ ENTRY (__memmove_chk) jb __chk_fail jmp memmove END (__memmove_chk) +libc_hidden_builtin_def (MEMMOVE_CHK) #endif diff --git a/sysdeps/x86_64/mempcpy_chk.S b/sysdeps/x86_64/mempcpy_chk.S index b60ee4ff08..facdac50d8 100644 --- a/sysdeps/x86_64/mempcpy_chk.S +++ b/sysdeps/x86_64/mempcpy_chk.S @@ -30,4 +30,5 @@ ENTRY (__mempcpy_chk) jb __chk_fail jmp __mempcpy END (__mempcpy_chk) +libc_hidden_builtin_def (__mempcpy_chk) #endif diff --git a/sysdeps/x86_64/memset_chk.S b/sysdeps/x86_64/memset_chk.S index ed53b8927f..c927884b1a 100644 --- a/sysdeps/x86_64/memset_chk.S +++ b/sysdeps/x86_64/memset_chk.S @@ -30,4 +30,5 @@ ENTRY (__memset_chk) jb __chk_fail jmp memset END (__memset_chk) +libc_hidden_builtin_def (__memset_chk) #endif diff --git a/sysdeps/x86_64/multiarch/memcpy_chk.c b/sysdeps/x86_64/multiarch/memcpy_chk.c index 5ac5cb1d7a..ec945dc91f 100644 --- a/sysdeps/x86_64/multiarch/memcpy_chk.c +++ b/sysdeps/x86_64/multiarch/memcpy_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_memcpy_chk, __memcpy_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__memcpy_chk, __GI___memcpy_chk, __redirect_memcpy_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memcpy_chk); +# endif #endif diff --git a/sysdeps/x86_64/multiarch/memmove_chk.c b/sysdeps/x86_64/multiarch/memmove_chk.c index 28161d3c27..55c7601d5d 100644 --- a/sysdeps/x86_64/multiarch/memmove_chk.c +++ b/sysdeps/x86_64/multiarch/memmove_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_memmove_chk, __memmove_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__memmove_chk, __GI___memmove_chk, __redirect_memmove_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memmove_chk); +# endif #endif diff --git a/sysdeps/x86_64/multiarch/mempcpy_chk.c b/sysdeps/x86_64/multiarch/mempcpy_chk.c index 36c81ae61a..83569cf9d9 100644 --- a/sysdeps/x86_64/multiarch/mempcpy_chk.c +++ b/sysdeps/x86_64/multiarch/mempcpy_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_mempcpy_chk, __mempcpy_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__mempcpy_chk, __GI___mempcpy_chk, __redirect_mempcpy_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__mempcpy_chk); +# endif #endif diff --git a/sysdeps/x86_64/multiarch/memset_chk.c b/sysdeps/x86_64/multiarch/memset_chk.c index d81147a70c..1a7503858d 100644 --- a/sysdeps/x86_64/multiarch/memset_chk.c +++ b/sysdeps/x86_64/multiarch/memset_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_memset_chk, __memset_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__memset_chk, __GI___memset_chk, __redirect_memset_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memset_chk); +# endif #endif From patchwork Wed Jul 5 14:10:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803715 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=mjX7q9pp; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1mx1wYmz20ZQ for ; Thu, 6 Jul 2023 00:11:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28B66385559B for ; Wed, 5 Jul 2023 14:11:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28B66385559B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566303; bh=fuFh1ahxiS+6FbY3BpgRqlPN2BEvEKYXG2bSdyjeTFA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=mjX7q9ppAEU5UenOxZiNXEh51cH+nglMeQ3YDYKJW3HK2HnTWsb1TDoHLWmucmvLl iia9JUpRxDFB1/1Q36PJiJ0ldbteb8A+TWw3F1vcrMd9/W3+DHcdXY6D0shDb0nW1H naLG7GgAEMxY7bT8YXMimEGkJcR4ugPAyUs5bYd4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2CC043857C48 for ; Wed, 5 Jul 2023 14:11:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2CC043857C48 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-428-z0B8AKpcMr2TeR4kFnl7JA-1; Wed, 05 Jul 2023 10:11:13 -0400 X-MC-Unique: z0B8AKpcMr2TeR4kFnl7JA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6836185A7A7; Wed, 5 Jul 2023 14:11:12 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2064F6403; Wed, 5 Jul 2023 14:11:11 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Carlos O'Donell Subject: [PATCH v5 05/14] stdio: Ensure *_chk routines have their hidden builtin definition available Date: Wed, 5 Jul 2023 16:10:40 +0200 Message-ID: <20230705141055.274575-6-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" If libc_hidden_builtin_{def,proto} isn't properly set for *_chk routines, there are unwanted PLT entries in libc.so. There is a special case with __asprintf_chk: If ldbl_* macros are used for asprintf, ABI gets broken on s390x, if it isn't, ppc64le isn't building due to multiple asm redirections. This is due to the inclusion of bits/stdio-lbdl.h for ppc64le whereas it isn't for s390x. This header creates redirections, which are not compatible with the ones generated using libc_hidden_def. Yet, we can't use libc_hidden_ldbl_proto on s390x since it will not create a simple strong alias (e.g. as done on x86_64), but a versioned alias, leading to ABI breakage. This results in errors on s390x: /usr/bin/ld: glibc/iconv/../libio/bits/stdio2.h:137: undefined reference to `__asprintf_chk' Original __asprintf_chk symbols: 00000000001395b0 T __asprintf_chk 0000000000177e90 T __nldbl___asprintf_chk __asprintf_chk symbols with ldbl_* macros: 000000000012d590 t ___asprintf_chk 000000000012d590 t __asprintf_chk@@GLIBC_2.4 000000000012d590 t __GI___asprintf_chk 000000000012d590 t __GL____asprintf_chk___asprintf_chk 0000000000172240 T __nldbl___asprintf_chk __asprintf_chk symbols with the patch: 000000000012d590 t ___asprintf_chk 000000000012d590 T __asprintf_chk 000000000012d590 t __GI___asprintf_chk 0000000000172240 T __nldbl___asprintf_chk Reviewed-by: Carlos O'Donell --- debug/asprintf_chk.c | 18 +++++++++++++++++- debug/fgets_u_chk.c | 1 + debug/fprintf_chk.c | 1 + debug/sprintf_chk.c | 1 + include/stdio.h | 13 ++++++++++++- .../ldbl-128ibm-compat/ieee128-asprintf_chk.c | 1 + .../ldbl-128ibm-compat/ieee128-fprintf_chk.c | 1 + .../ldbl-128ibm-compat/ieee128-sprintf_chk.c | 1 + .../ldbl-128ibm-compat/ieee128-vsprintf_chk.c | 1 + 9 files changed, 36 insertions(+), 2 deletions(-) diff --git a/debug/asprintf_chk.c b/debug/asprintf_chk.c index 651c2cd76b..e233d5d737 100644 --- a/debug/asprintf_chk.c +++ b/debug/asprintf_chk.c @@ -22,7 +22,7 @@ /* Write formatted output from FORMAT to a string which is allocated with malloc and stored in *STRING_PTR. */ int -__asprintf_chk (char **result_ptr, int flag, const char *format, ...) +___asprintf_chk (char **result_ptr, int flag, const char *format, ...) { /* For flag > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n can only come from read-only format strings. */ @@ -36,3 +36,19 @@ __asprintf_chk (char **result_ptr, int flag, const char *format, ...) return ret; } +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +/* This is needed since is included in this case, leading to + * multiple asm redirection of the same symbol + */ +ldbl_hidden_def (___asprintf_chk, __asprintf_chk) +ldbl_strong_alias (___asprintf_chk, __asprintf_chk) +#else +/* On some systems introduction of ldbl_* macros lead to ABI breakage due to the + * long_double_symbol aliasing, e.g. on s390x: + * /usr/bin/ld: glibc/iconv/../libio/bits/stdio2.h:137: undefined reference to + * `__asprintf_chk' + * Due to __asprintf_chk@@GLIBC_2.4 alias replacing __asprintf_chk. + */ +strong_alias (___asprintf_chk, __asprintf_chk) +libc_hidden_def (__asprintf_chk) +#endif diff --git a/debug/fgets_u_chk.c b/debug/fgets_u_chk.c index a16ba655e6..74275381f5 100644 --- a/debug/fgets_u_chk.c +++ b/debug/fgets_u_chk.c @@ -56,3 +56,4 @@ __fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp) fp->_flags |= old_error; return result; } +libc_hidden_builtin_def (__fgets_unlocked_chk) diff --git a/debug/fprintf_chk.c b/debug/fprintf_chk.c index b57d538d03..273051ef91 100644 --- a/debug/fprintf_chk.c +++ b/debug/fprintf_chk.c @@ -35,4 +35,5 @@ ___fprintf_chk (FILE *fp, int flag, const char *format, ...) return ret; } +ldbl_hidden_def (___fprintf_chk, __fprintf_chk) ldbl_strong_alias (___fprintf_chk, __fprintf_chk) diff --git a/debug/sprintf_chk.c b/debug/sprintf_chk.c index b27f4afae8..e45f1e7b3b 100644 --- a/debug/sprintf_chk.c +++ b/debug/sprintf_chk.c @@ -42,4 +42,5 @@ ___sprintf_chk (char *s, int flag, size_t slen, const char *format, ...) return ret; } +ldbl_hidden_def (___sprintf_chk, __sprintf_chk) ldbl_strong_alias (___sprintf_chk, __sprintf_chk) diff --git a/include/stdio.h b/include/stdio.h index da47d1ce99..6755877911 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -276,7 +276,18 @@ extern FILE *__open_memstream (char **, size_t *) __THROW __wur; libc_hidden_proto (__open_memstream) libc_hidden_proto (__libc_fatal) rtld_hidden_proto (__libc_fatal) -libc_hidden_proto (__vsprintf_chk) + +libc_hidden_proto (__fgets_unlocked_chk) + +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +libc_hidden_ldbl_proto (__asprintf_chk) +#else +libc_hidden_proto (__asprintf_chk) +#endif + +libc_hidden_ldbl_proto (__fprintf_chk) +libc_hidden_ldbl_proto (__sprintf_chk) +libc_hidden_ldbl_proto (__vsprintf_chk) extern FILE * __fmemopen (void *buf, size_t len, const char *mode); libc_hidden_proto (__fmemopen) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c index fbf953a728..6e93ee81fc 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c @@ -35,4 +35,5 @@ ___ieee128___asprintf_chk (char **string_ptr, int flag, const char *format, ...) return done; } +hidden_def (___ieee128___asprintf_chk) strong_alias (___ieee128___asprintf_chk, __asprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c index bd10e9c3db..e0865b6663 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c @@ -35,4 +35,5 @@ ___ieee128___fprintf_chk (FILE *fp, int flag, const char *format, ...) return done; } +hidden_def (___ieee128___fprintf_chk) strong_alias (___ieee128___fprintf_chk, __fprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c index 0039c3b53d..762757a5c7 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c @@ -43,4 +43,5 @@ ___ieee128___sprintf_chk (char *s, int flag, size_t slen, return done; } +hidden_def (___ieee128___sprintf_chk) strong_alias (___ieee128___sprintf_chk, __sprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c index 22137269c0..c251b60d4e 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c @@ -35,4 +35,5 @@ ___ieee128___vsprintf_chk (char *string, int flag, size_t slen, return __vsprintf_internal (string, slen, format, ap, mode); } +hidden_def (___ieee128___vsprintf_chk) strong_alias (___ieee128___vsprintf_chk, __vsprintf_chkieee128) From patchwork Wed Jul 5 14:10:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803716 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=JaGQzqsw; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1n65RPhz20ZQ for ; Thu, 6 Jul 2023 00:11:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BFDDD385DC2B for ; Wed, 5 Jul 2023 14:11:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFDDD385DC2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566312; bh=3r1dA9r5XC8L+AYxjIKqvmstUq5BL66NzVu9Vj1PRnw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=JaGQzqswE2kHSiRrY/lifKjsSx54W10ab0x2bIAaxEZIIJgUa9CuaSltn5KfuL80V D77hKUh5ZbQRuM2fWK+KxlRSksNjt3JYBdveIAOis+7o+zVBHOvFSVJ8yCgZSOArTC vQM3/txv757PSlKbJN6lZI+91DcXAbh23mC5BbGg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id EE9133857353 for ; Wed, 5 Jul 2023 14:11:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE9133857353 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-VHlZsnFUOya-TqrdmoervQ-1; Wed, 05 Jul 2023 10:11:14 -0400 X-MC-Unique: VHlZsnFUOya-TqrdmoervQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A1B03C1EF37; Wed, 5 Jul 2023 14:11:13 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA152F5CF0; Wed, 5 Jul 2023 14:11:12 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 06/14] misc/sys/cdefs.h: Create FORTIFY redirects for internal calls Date: Wed, 5 Jul 2023 16:10:41 +0200 Message-ID: <20230705141055.274575-7-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The __REDIRECT* macros are creating aliases which may lead to unwanted PLT entries when fortification is enabled. To prevent these entries, the REDIRECT alias should be set to point to the existing __GI_* aliases. This is done transparently by creating a __REDIRECT_FORTIFY* version of these macros, that can be overwritten internally when necessary. Reviewed-by: Siddhesh Poyarekar --- include/sys/cdefs.h | 14 ++++++++++++++ misc/sys/cdefs.h | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h index 56adb231aa..b84ad34a70 100644 --- a/include/sys/cdefs.h +++ b/include/sys/cdefs.h @@ -40,6 +40,20 @@ rtld_hidden_proto (__chk_fail) #endif +#if defined SHARED +#if IS_IN (libc) && __USE_FORTIFY_LEVEL > 0 && defined __fortify_function + +#undef __REDIRECT_FORTIFY +#define __REDIRECT_FORTIFY(name, proto, alias) \ + __REDIRECT(name, proto, __GI_##alias) + +#undef __REDIRECT_FORTIFY_NTH +#define __REDIRECT_FORTIFY_NTH(name, proto, alias) \ + __REDIRECT_NTH(name, proto, __GI_##alias) + +#endif +#endif /* defined SHARED */ + #endif /* !defined _ISOMAC */ #endif diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 393d9091d9..90c21e2703 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -268,6 +268,14 @@ # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname) # define __ASMNAME2(prefix, cname) __STRING (prefix) cname +#ifndef __REDIRECT_FORTIFY +#define __REDIRECT_FORTIFY __REDIRECT +#endif + +#ifndef __REDIRECT_FORTIFY_NTH +#define __REDIRECT_FORTIFY_NTH __REDIRECT_NTH +#endif + /* #elif __SOME_OTHER_COMPILER__ From patchwork Wed Jul 5 14:10:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=L7Y3tuil; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1pB1n7jz20ZQ for ; Thu, 6 Jul 2023 00:12:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BBA13388201A for ; Wed, 5 Jul 2023 14:12:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBA13388201A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566367; bh=AIucYjPzEegIO0CE/a6GnBJhRrCxtZME5yIOl6RoV2w=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=L7Y3tuilPjb8aiIaVdwsbwAxW+3HTd3IrO+B+Kq7fiXIiBRWkX5RWiF80gNQXXKDp LFlI1rLpDpOxFHe1IlVPF0IYz4vw3urXzh8TFh9mksQZgODTyvUrsDg3mTp2K9bpLY zmn6BHbIHpqNjgELYgR7HzLJci+iGnSZhmjxtkFs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 49E8C385771F for ; Wed, 5 Jul 2023 14:11:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49E8C385771F Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-173-fvd5nvZOM0u7KXvIpfApEg-1; Wed, 05 Jul 2023 10:11:14 -0400 X-MC-Unique: fvd5nvZOM0u7KXvIpfApEg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FE322800176; Wed, 5 Jul 2023 14:11:14 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEFCAF640B; Wed, 5 Jul 2023 14:11:13 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 07/14] wchar: Avoid PLT entries with _FORTIFY_SOURCE Date: Wed, 5 Jul 2023 16:10:42 +0200 Message-ID: <20230705141055.274575-8-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The change is meant to avoid unwanted PLT entries for the wmemset and wcrtomb routines when _FORTIFY_SOURCE is set. On top of that, ensure that *_chk routines have their hidden builtin definitions available. Reviewed-by: Siddhesh Poyarekar --- debug/wcrtomb_chk.c | 1 + debug/wmemset_chk.c | 1 + include/wchar.h | 15 +++++++++++++++ sysdeps/x86_64/multiarch/wmemset_chk.c | 4 ++++ wcsmbs/bits/wchar2-decl.h | 4 ++-- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/debug/wcrtomb_chk.c b/debug/wcrtomb_chk.c index 657be7471d..c156fe09c1 100644 --- a/debug/wcrtomb_chk.c +++ b/debug/wcrtomb_chk.c @@ -28,3 +28,4 @@ __wcrtomb_chk (char *s, wchar_t wchar, mbstate_t *ps, size_t buflen) { return __wcrtomb_internal (s, wchar, ps, buflen); } +libc_hidden_def (__wcrtomb_chk) diff --git a/debug/wmemset_chk.c b/debug/wmemset_chk.c index e11a92815e..1e7fc4fdea 100644 --- a/debug/wmemset_chk.c +++ b/debug/wmemset_chk.c @@ -26,3 +26,4 @@ __wmemset_chk (wchar_t *s, wchar_t c, size_t n, size_t dstlen) return wmemset (s, c, n); } +libc_hidden_builtin_def (__wmemset_chk) diff --git a/include/wchar.h b/include/wchar.h index 7b763bc24f..484e6b3fef 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -166,6 +166,8 @@ libc_hidden_proto (putwc) libc_hidden_proto (mbrtowc) libc_hidden_proto (wcrtomb) +libc_hidden_proto (__wcrtomb_chk) + extern int __wcscmp (const wchar_t *__s1, const wchar_t *__s2) __THROW __attribute_pure__; libc_hidden_proto (__wcscmp) @@ -260,16 +262,25 @@ extern wchar_t *__wcschrnul (const wchar_t *__s, wchar_t __wc) extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n, size_t __ns) __THROW; +libc_hidden_builtin_proto (__wmemset_chk) extern int __vfwscanf (__FILE *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) attribute_hidden /* __attribute__ ((__format__ (__wscanf__, 2, 0)) */; + +extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n, + int __flag, size_t __s_len, + const wchar_t *__restrict __format, ...) + __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */; + extern int __fwprintf (__FILE *__restrict __s, const wchar_t *__restrict __format, ...) attribute_hidden /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */; +extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format, + ...); extern int __vfwprintf_chk (FILE *__restrict __s, int __flag, const wchar_t *__restrict __format, __gnuc_va_list __arg) @@ -279,6 +290,10 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, const wchar_t *__restrict __format, __gnuc_va_list __arg) /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; +extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag, + const wchar_t *__restrict __format, ...); +extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format, + __gnuc_va_list __ap); extern int __isoc99_fwscanf (__FILE *__restrict __stream, const wchar_t *__restrict __format, ...); diff --git a/sysdeps/x86_64/multiarch/wmemset_chk.c b/sysdeps/x86_64/multiarch/wmemset_chk.c index ac93a1f376..00edf44918 100644 --- a/sysdeps/x86_64/multiarch/wmemset_chk.c +++ b/sysdeps/x86_64/multiarch/wmemset_chk.c @@ -28,4 +28,8 @@ libc_ifunc_redirected (__redirect_wmemset_chk, __wmemset_chk, IFUNC_SELECTOR ()); +# ifdef SHARED +__hidden_ver1 (__wmemset_chk, __GI___wmemset_chk, __redirect_wmemset_chk) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__wmemset_chk); +# endif #endif diff --git a/wcsmbs/bits/wchar2-decl.h b/wcsmbs/bits/wchar2-decl.h index f3a2fd3c99..08c8ebd0e8 100644 --- a/wcsmbs/bits/wchar2-decl.h +++ b/wcsmbs/bits/wchar2-decl.h @@ -71,7 +71,7 @@ extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn, extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n, size_t __ns) __THROW; -extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c, +extern wchar_t *__REDIRECT_FORTIFY_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c, size_t __n), wmemset); extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn, (wchar_t *__s, wchar_t __c, size_t __n, @@ -203,7 +203,7 @@ extern wchar_t *__REDIRECT (__fgetws_unlocked_chk_warn, extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar, mbstate_t *__restrict __p, size_t __buflen) __THROW __wur; -extern size_t __REDIRECT_NTH (__wcrtomb_alias, +extern size_t __REDIRECT_FORTIFY_NTH (__wcrtomb_alias, (char *__restrict __s, wchar_t __wchar, mbstate_t *__restrict __ps), wcrtomb) __wur; From patchwork Wed Jul 5 14:10:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=jj0oIpRe; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1r51kZXz20ZQ for ; Thu, 6 Jul 2023 00:14:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2854F3882028 for ; Wed, 5 Jul 2023 14:14:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2854F3882028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566467; bh=ClqnuMyhAucPK9gj602OVxrrcDgEs3I5tf26p/PgeuA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=jj0oIpReI/zBzW/aO9BltBcFjD4g9eiPkszGcnzlmMXFFBwIgDhXdAk/uSIIze6PR eXKGnp3O82M6u6vGZ+ixXZio7i9i9JORL7A7DwxiSl/mcTPsZElbGnN6dIR3zEFw0v Ew4rB9Pb8VNRxFy8esMjdiRNarkWU+DRWNE/K3CE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 38DBE3857359 for ; Wed, 5 Jul 2023 14:11:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38DBE3857359 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-RJ9kNDJhNxW_Lch3PLSVUg-1; Wed, 05 Jul 2023 10:11:15 -0400 X-MC-Unique: RJ9kNDJhNxW_Lch3PLSVUg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 614933C1EF2A; Wed, 5 Jul 2023 14:11:15 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5050F5CF0; Wed, 5 Jul 2023 14:11:14 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 08/14] posix/bits/unistd.h: Clearly separate declaration from definitions Date: Wed, 5 Jul 2023 16:10:43 +0200 Message-ID: <20230705141055.274575-9-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This change is similar to what was done for bits/wchar2.h. Routines declaration are moved into a dedicated bits/unistd-decl.h file which is then included into the bits/unistd.h file. This will allow to adapt the files so that PLT entries are not created when _FORTIFY_SOURCE is enabled. Reviewed-by: Siddhesh Poyarekar --- include/bits/unistd-decl.h | 1 + include/unistd.h | 1 + posix/Makefile | 1 + posix/bits/unistd-decl.h | 198 +++++++++++++++++++++++++++++++++++++ posix/bits/unistd.h | 154 +---------------------------- 5 files changed, 202 insertions(+), 153 deletions(-) create mode 100644 include/bits/unistd-decl.h create mode 100644 posix/bits/unistd-decl.h diff --git a/include/bits/unistd-decl.h b/include/bits/unistd-decl.h new file mode 100644 index 0000000000..7fcbd272ac --- /dev/null +++ b/include/bits/unistd-decl.h @@ -0,0 +1 @@ +#include diff --git a/include/unistd.h b/include/unistd.h index 4345d08d60..b042a485f9 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -5,6 +5,7 @@ # include # include +# include libc_hidden_proto (_exit, __noreturn__) # ifndef NO_RTLD_HIDDEN diff --git a/posix/Makefile b/posix/Makefile index 5113ee3b74..3d368b91f6 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -42,6 +42,7 @@ headers := \ bits/types/idtype_t.h \ bits/types/struct_sched_param.h \ bits/typesizes.h \ + bits/unistd-decl.h \ bits/unistd.h \ bits/unistd_ext.h \ bits/utsname.h \ diff --git a/posix/bits/unistd-decl.h b/posix/bits/unistd-decl.h new file mode 100644 index 0000000000..2d0f7a4456 --- /dev/null +++ b/posix/bits/unistd-decl.h @@ -0,0 +1,198 @@ +/* Checking routines for unistd functions. Declaration only. + Copyright (C) 2023 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 _BITS_UNISTD_DECL_H +#define _BITS_UNISTD_DECL_H 1 + +#ifndef _UNISTD_H +# error "Never include directly; use instead." +#endif + +extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes, + size_t __buflen) + __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, + size_t __nbytes), read) + __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __REDIRECT (__read_chk_warn, + (int __fd, void *__buf, size_t __nbytes, + size_t __buflen), __read_chk) + __wur __warnattr ("read called with bigger length than size of " + "the destination buffer"); + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K8 +extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes, + __off_t __offset, size_t __bufsize) + __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset, size_t __bufsize) + __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __REDIRECT (__pread_alias, + (int __fd, void *__buf, size_t __nbytes, + __off_t __offset), pread) + __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __REDIRECT (__pread64_alias, + (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset), pread64) + __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __REDIRECT (__pread_chk_warn, + (int __fd, void *__buf, size_t __nbytes, + __off_t __offset, size_t __bufsize), __pread_chk) + __wur __warnattr ("pread called with bigger length than size of " + "the destination buffer"); +extern ssize_t __REDIRECT (__pread64_chk_warn, + (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset, size_t __bufsize), + __pread64_chk) + __wur __warnattr ("pread64 called with bigger length than size of " + "the destination buffer"); +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K +extern ssize_t __readlink_chk (const char *__restrict __path, + char *__restrict __buf, size_t __len, + size_t __buflen) + __THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __REDIRECT_NTH (__readlink_alias, + (const char *__restrict __path, + char *__restrict __buf, size_t __len), readlink) + __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3)); +extern ssize_t __REDIRECT_NTH (__readlink_chk_warn, + (const char *__restrict __path, + char *__restrict __buf, size_t __len, + size_t __buflen), __readlink_chk) + __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length " + "than size of destination buffer"); +#endif + +#ifdef __USE_ATFILE +extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path, + char *__restrict __buf, size_t __len, + size_t __buflen) + __THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4)); +extern ssize_t __REDIRECT_NTH (__readlinkat_alias, + (int __fd, const char *__restrict __path, + char *__restrict __buf, size_t __len), + readlinkat) + __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4)); +extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn, + (int __fd, const char *__restrict __path, + char *__restrict __buf, size_t __len, + size_t __buflen), __readlinkat_chk) + __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger " + "length than size of destination " + "buffer"); +#endif + +extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen) + __THROW __wur; +extern char *__REDIRECT_NTH (__getcwd_alias, + (char *__buf, size_t __size), getcwd) __wur; +extern char *__REDIRECT_NTH (__getcwd_chk_warn, + (char *__buf, size_t __size, size_t __buflen), + __getcwd_chk) + __wur __warnattr ("getcwd caller with bigger length than size of " + "destination buffer"); + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +extern char *__getwd_chk (char *__buf, size_t buflen) + __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2)); +extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd) + __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd " + "doesn't specify buffer size"); +#endif + +extern size_t __confstr_chk (int __name, char *__buf, size_t __len, + size_t __buflen) __THROW + __attr_access ((__write_only__, 2, 3)); +extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf, + size_t __len), confstr) + __attr_access ((__write_only__, 2, 3)); +extern size_t __REDIRECT_NTH (__confstr_chk_warn, + (int __name, char *__buf, size_t __len, + size_t __buflen), __confstr_chk) + __warnattr ("confstr called with bigger length than size of destination " + "buffer"); + + +extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen) + __THROW __wur __attr_access ((__write_only__, 2, 1)); +extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]), + getgroups) __wur __attr_access ((__write_only__, 2, 1)); +extern int __REDIRECT_NTH (__getgroups_chk_warn, + (int __size, __gid_t __list[], size_t __listlen), + __getgroups_chk) + __wur __warnattr ("getgroups called with bigger group count than what " + "can fit into destination buffer"); + + +extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen, + size_t __nreal) __THROW __nonnull ((2)) + __attr_access ((__write_only__, 2, 3)); +extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf, + size_t __buflen), ttyname_r) + __nonnull ((2)); +extern int __REDIRECT_NTH (__ttyname_r_chk_warn, + (int __fd, char *__buf, size_t __buflen, + size_t __nreal), __ttyname_r_chk) + __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than " + "size of destination buffer"); + + +#ifdef __USE_POSIX199506 +extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal) + __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); +extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen), + getlogin_r) __nonnull ((1)); +extern int __REDIRECT (__getlogin_r_chk_warn, + (char *__buf, size_t __buflen, size_t __nreal), + __getlogin_r_chk) + __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than " + "size of destination buffer"); +#endif + + +#if defined __USE_MISC || defined __USE_UNIX98 +extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal) + __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); +extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen), + gethostname) + __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); +extern int __REDIRECT_NTH (__gethostname_chk_warn, + (char *__buf, size_t __buflen, size_t __nreal), + __gethostname_chk) + __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than " + "size of destination buffer"); +#endif + + +#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98) +extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal) + __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2)); +extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf, + size_t __buflen), + getdomainname) __nonnull ((1)) + __wur __attr_access ((__write_only__, 1, 2)); +extern int __REDIRECT_NTH (__getdomainname_chk_warn, + (char *__buf, size_t __buflen, size_t __nreal), + __getdomainname_chk) + __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger " + "buflen than size of destination " + "buffer"); +#endif +#endif /* bits/unistd-decl.h. */ diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h index 2a0782e6c8..6a381116a9 100644 --- a/posix/bits/unistd.h +++ b/posix/bits/unistd.h @@ -20,17 +20,7 @@ # error "Never include directly; use instead." #endif -extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes, - size_t __buflen) - __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, - size_t __nbytes), read) - __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT (__read_chk_warn, - (int __fd, void *__buf, size_t __nbytes, - size_t __buflen), __read_chk) - __wur __warnattr ("read called with bigger length than size of " - "the destination buffer"); +# include __fortify_function __wur ssize_t read (int __fd, void *__buf, size_t __nbytes) @@ -41,32 +31,6 @@ read (int __fd, void *__buf, size_t __nbytes) } #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 -extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes, - __off_t __offset, size_t __bufsize) - __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes, - __off64_t __offset, size_t __bufsize) - __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT (__pread_alias, - (int __fd, void *__buf, size_t __nbytes, - __off_t __offset), pread) - __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT (__pread64_alias, - (int __fd, void *__buf, size_t __nbytes, - __off64_t __offset), pread64) - __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT (__pread_chk_warn, - (int __fd, void *__buf, size_t __nbytes, - __off_t __offset, size_t __bufsize), __pread_chk) - __wur __warnattr ("pread called with bigger length than size of " - "the destination buffer"); -extern ssize_t __REDIRECT (__pread64_chk_warn, - (int __fd, void *__buf, size_t __nbytes, - __off64_t __offset, size_t __bufsize), - __pread64_chk) - __wur __warnattr ("pread64 called with bigger length than size of " - "the destination buffer"); - # ifndef __USE_FILE_OFFSET64 __fortify_function __wur ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset) @@ -97,21 +61,6 @@ pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) #endif #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K -extern ssize_t __readlink_chk (const char *__restrict __path, - char *__restrict __buf, size_t __len, - size_t __buflen) - __THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT_NTH (__readlink_alias, - (const char *__restrict __path, - char *__restrict __buf, size_t __len), readlink) - __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT_NTH (__readlink_chk_warn, - (const char *__restrict __path, - char *__restrict __buf, size_t __len, - size_t __buflen), __readlink_chk) - __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length " - "than size of destination buffer"); - __fortify_function __nonnull ((1, 2)) __wur ssize_t __NTH (readlink (const char *__restrict __path, char *__restrict __buf, size_t __len)) @@ -123,23 +72,6 @@ __NTH (readlink (const char *__restrict __path, char *__restrict __buf, #endif #ifdef __USE_ATFILE -extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path, - char *__restrict __buf, size_t __len, - size_t __buflen) - __THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4)); -extern ssize_t __REDIRECT_NTH (__readlinkat_alias, - (int __fd, const char *__restrict __path, - char *__restrict __buf, size_t __len), - readlinkat) - __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4)); -extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn, - (int __fd, const char *__restrict __path, - char *__restrict __buf, size_t __len, - size_t __buflen), __readlinkat_chk) - __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger " - "length than size of destination " - "buffer"); - __fortify_function __nonnull ((2, 3)) __wur ssize_t __NTH (readlinkat (int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len)) @@ -150,16 +82,6 @@ __NTH (readlinkat (int __fd, const char *__restrict __path, } #endif -extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen) - __THROW __wur; -extern char *__REDIRECT_NTH (__getcwd_alias, - (char *__buf, size_t __size), getcwd) __wur; -extern char *__REDIRECT_NTH (__getcwd_chk_warn, - (char *__buf, size_t __size, size_t __buflen), - __getcwd_chk) - __wur __warnattr ("getcwd caller with bigger length than size of " - "destination buffer"); - __fortify_function __wur char * __NTH (getcwd (char *__buf, size_t __size)) { @@ -169,12 +91,6 @@ __NTH (getcwd (char *__buf, size_t __size)) } #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED -extern char *__getwd_chk (char *__buf, size_t buflen) - __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2)); -extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd) - __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd " - "doesn't specify buffer size"); - __fortify_function __nonnull ((1)) __attribute_deprecated__ __wur char * __NTH (getwd (char *__buf)) { @@ -184,18 +100,6 @@ __NTH (getwd (char *__buf)) } #endif -extern size_t __confstr_chk (int __name, char *__buf, size_t __len, - size_t __buflen) __THROW - __attr_access ((__write_only__, 2, 3)); -extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf, - size_t __len), confstr) - __attr_access ((__write_only__, 2, 3)); -extern size_t __REDIRECT_NTH (__confstr_chk_warn, - (int __name, char *__buf, size_t __len, - size_t __buflen), __confstr_chk) - __warnattr ("confstr called with bigger length than size of destination " - "buffer"); - __fortify_function size_t __NTH (confstr (int __name, char *__buf, size_t __len)) { @@ -205,16 +109,6 @@ __NTH (confstr (int __name, char *__buf, size_t __len)) } -extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen) - __THROW __wur __attr_access ((__write_only__, 2, 1)); -extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]), - getgroups) __wur __attr_access ((__write_only__, 2, 1)); -extern int __REDIRECT_NTH (__getgroups_chk_warn, - (int __size, __gid_t __list[], size_t __listlen), - __getgroups_chk) - __wur __warnattr ("getgroups called with bigger group count than what " - "can fit into destination buffer"); - __fortify_function int __NTH (getgroups (int __size, __gid_t __list[])) { @@ -224,18 +118,6 @@ __NTH (getgroups (int __size, __gid_t __list[])) } -extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen, - size_t __nreal) __THROW __nonnull ((2)) - __attr_access ((__write_only__, 2, 3)); -extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf, - size_t __buflen), ttyname_r) - __nonnull ((2)); -extern int __REDIRECT_NTH (__ttyname_r_chk_warn, - (int __fd, char *__buf, size_t __buflen, - size_t __nreal), __ttyname_r_chk) - __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than " - "size of destination buffer"); - __fortify_function int __NTH (ttyname_r (int __fd, char *__buf, size_t __buflen)) { @@ -246,16 +128,6 @@ __NTH (ttyname_r (int __fd, char *__buf, size_t __buflen)) #ifdef __USE_POSIX199506 -extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal) - __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); -extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen), - getlogin_r) __nonnull ((1)); -extern int __REDIRECT (__getlogin_r_chk_warn, - (char *__buf, size_t __buflen, size_t __nreal), - __getlogin_r_chk) - __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than " - "size of destination buffer"); - __fortify_function int getlogin_r (char *__buf, size_t __buflen) { @@ -267,17 +139,6 @@ getlogin_r (char *__buf, size_t __buflen) #if defined __USE_MISC || defined __USE_UNIX98 -extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal) - __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); -extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen), - gethostname) - __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); -extern int __REDIRECT_NTH (__gethostname_chk_warn, - (char *__buf, size_t __buflen, size_t __nreal), - __gethostname_chk) - __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than " - "size of destination buffer"); - __fortify_function int __NTH (gethostname (char *__buf, size_t __buflen)) { @@ -289,19 +150,6 @@ __NTH (gethostname (char *__buf, size_t __buflen)) #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98) -extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal) - __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2)); -extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf, - size_t __buflen), - getdomainname) __nonnull ((1)) - __wur __attr_access ((__write_only__, 1, 2)); -extern int __REDIRECT_NTH (__getdomainname_chk_warn, - (char *__buf, size_t __buflen, size_t __nreal), - __getdomainname_chk) - __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger " - "buflen than size of destination " - "buffer"); - __fortify_function int __NTH (getdomainname (char *__buf, size_t __buflen)) { From patchwork Wed Jul 5 14:10:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803720 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=NbPY10oY; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1p61FFtz20ZQ for ; Thu, 6 Jul 2023 00:12:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C700838708C1 for ; Wed, 5 Jul 2023 14:12:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C700838708C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566363; bh=38lxs2D7FeLWGL3wt66jhSjPuPami1/E5A0R5IJd+Y0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=NbPY10oYSinY2anpg+XKMxrreZ6jDQXpnB1/0/LQ4L0sjhpLbvpozr7vEpirjaXl3 L5w/g2cSvGWY1/xvfIqtmd1t6Zh+0sQcc9kWz/G5aG/HzAIjki8btCdsBicNJ7CyG6 oaGMIbT6KpRXyHZJPtT9hssLQTKlBU3Hx2VIn2AY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4B6633856964 for ; Wed, 5 Jul 2023 14:11:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B6633856964 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-400-WYypMWfWNPCzvsKs9eqKmg-1; Wed, 05 Jul 2023 10:11:16 -0400 X-MC-Unique: WYypMWfWNPCzvsKs9eqKmg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 428873811F2E; Wed, 5 Jul 2023 14:11:16 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94852F5CF0; Wed, 5 Jul 2023 14:11:15 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 09/14] unistd: Avoid PLT entries with _FORTIFY_SOURCE Date: Wed, 5 Jul 2023 16:10:44 +0200 Message-ID: <20230705141055.274575-10-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The change is meant to avoid unwanted PLT entries for the read_chk, getdomainname_chk and getlogin_r_chk routines when _FORTIFY_SOURCE is set. Reviewed-by: Siddhesh Poyarekar --- debug/getdomainname_chk.c | 1 + debug/read_chk.c | 1 + include/unistd.h | 4 ++++ login/getlogin_r_chk.c | 1 + posix/bits/unistd-decl.h | 6 +++--- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/debug/getdomainname_chk.c b/debug/getdomainname_chk.c index ccea1b2d9e..a7492adf95 100644 --- a/debug/getdomainname_chk.c +++ b/debug/getdomainname_chk.c @@ -26,3 +26,4 @@ __getdomainname_chk (char *buf, size_t buflen, size_t nreal) return getdomainname (buf, buflen); } +libc_hidden_def (__getdomainname_chk) diff --git a/debug/read_chk.c b/debug/read_chk.c index 17588736a1..75d902a8ba 100644 --- a/debug/read_chk.c +++ b/debug/read_chk.c @@ -25,3 +25,4 @@ __read_chk (int fd, void *buf, size_t nbytes, size_t buflen) return __read (fd, buf, nbytes); } +libc_hidden_def (__read_chk) diff --git a/include/unistd.h b/include/unistd.h index b042a485f9..e241603b81 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -32,6 +32,10 @@ libc_hidden_proto (readlinkat) libc_hidden_proto (fsync) libc_hidden_proto (fdatasync) +libc_hidden_proto (__read_chk) +libc_hidden_proto (__getdomainname_chk) +libc_hidden_proto (__getlogin_r_chk) + /* Now define the internal interfaces. */ extern int __access (const char *__name, int __type); libc_hidden_proto (__access) diff --git a/login/getlogin_r_chk.c b/login/getlogin_r_chk.c index 12a0d12bd4..26ec3e6970 100644 --- a/login/getlogin_r_chk.c +++ b/login/getlogin_r_chk.c @@ -26,3 +26,4 @@ __getlogin_r_chk (char *buf, size_t buflen, size_t nreal) return getlogin_r (buf, buflen); } +libc_hidden_def (__getlogin_r_chk) diff --git a/posix/bits/unistd-decl.h b/posix/bits/unistd-decl.h index 2d0f7a4456..2603039767 100644 --- a/posix/bits/unistd-decl.h +++ b/posix/bits/unistd-decl.h @@ -26,7 +26,7 @@ extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes, size_t __buflen) __wur __attr_access ((__write_only__, 2, 3)); -extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, +extern ssize_t __REDIRECT_FORTIFY (__read_alias, (int __fd, void *__buf, size_t __nbytes), read) __wur __attr_access ((__write_only__, 2, 3)); extern ssize_t __REDIRECT (__read_chk_warn, @@ -157,7 +157,7 @@ extern int __REDIRECT_NTH (__ttyname_r_chk_warn, #ifdef __USE_POSIX199506 extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal) __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); -extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen), +extern int __REDIRECT_FORTIFY (__getlogin_r_alias, (char *__buf, size_t __buflen), getlogin_r) __nonnull ((1)); extern int __REDIRECT (__getlogin_r_chk_warn, (char *__buf, size_t __buflen, size_t __nreal), @@ -184,7 +184,7 @@ extern int __REDIRECT_NTH (__gethostname_chk_warn, #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98) extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal) __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2)); -extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf, +extern int __REDIRECT_FORTIFY_NTH (__getdomainname_alias, (char *__buf, size_t __buflen), getdomainname) __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2)); From patchwork Wed Jul 5 14:10:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ZYusZYii; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1qG4hZxz20ZQ for ; Thu, 6 Jul 2023 00:13:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 818193882053 for ; Wed, 5 Jul 2023 14:13:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 818193882053 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566424; bh=83XiZvMtlXjHPTgZlmyH/6jjfc1nHisNHKMrG+7ns9Y=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ZYusZYii7j6auVvSuAoo9d6Uf5rZb/7tIOXTNcSkKOd1j+FRDmSqt8lRNoH4x4AsT gnT46XPqheuWqv+hBzQG8MmUgtbl9oW30RM1mAprtsyYBU6gGlq3qumdHcg9r82QBo MQgXQSrRHP9XQqf1pDEec0m1vDeDeYppRKuL23NI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6192C3856944 for ; Wed, 5 Jul 2023 14:11:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6192C3856944 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-443-RHj8unF1Nf6M2szFpIqnbQ-1; Wed, 05 Jul 2023 10:11:17 -0400 X-MC-Unique: RHj8unF1Nf6M2szFpIqnbQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2AE6E88D0F7; Wed, 5 Jul 2023 14:11:17 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76CAEF5CF0; Wed, 5 Jul 2023 14:11:16 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 10/14] misc/bits/select2.h: Clearly separate declaration from definitions Date: Wed, 5 Jul 2023 16:10:45 +0200 Message-ID: <20230705141055.274575-11-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The __fdelt_chk declaration needs to be available so that libc_hidden_proto can be used while not redefining __FD_ELT. Thus, misc/bits/select-decl.h is created to hold the corresponding prototypes. Reviewed-by: Siddhesh Poyarekar --- debug/fdelt_chk.c | 1 + include/bits/select-decl.h | 1 + include/sys/select.h | 4 ++++ misc/Makefile | 1 + misc/bits/select-decl.h | 31 +++++++++++++++++++++++++++++++ misc/bits/select2.h | 6 ++---- 6 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 include/bits/select-decl.h create mode 100644 misc/bits/select-decl.h diff --git a/debug/fdelt_chk.c b/debug/fdelt_chk.c index d1d3a19460..bcf8f333f9 100644 --- a/debug/fdelt_chk.c +++ b/debug/fdelt_chk.c @@ -28,3 +28,4 @@ __fdelt_chk (long int d) return d / __NFDBITS; } strong_alias (__fdelt_chk, __fdelt_warn) +libc_hidden_def (__fdelt_chk) diff --git a/include/bits/select-decl.h b/include/bits/select-decl.h new file mode 100644 index 0000000000..43db738a61 --- /dev/null +++ b/include/bits/select-decl.h @@ -0,0 +1 @@ +#include diff --git a/include/sys/select.h b/include/sys/select.h index a8961afbed..45376461e9 100644 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -3,6 +3,10 @@ #ifndef _ISOMAC /* Now define the internal interfaces. */ + +#include +libc_hidden_proto (__fdelt_chk) + # if __TIMESIZE == 64 # define __pselect64 __pselect # define __select64 __select diff --git a/misc/Makefile b/misc/Makefile index 36ba7a0bad..3497d30f3b 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -68,6 +68,7 @@ headers := \ bits/syslog-ldbl.h \ bits/syslog-path.h \ bits/error.h \ + bits/select-decl.h \ bits/select2.h \ bits/hwcap.h \ sys/auxv.h \ diff --git a/misc/bits/select-decl.h b/misc/bits/select-decl.h new file mode 100644 index 0000000000..95962e1b98 --- /dev/null +++ b/misc/bits/select-decl.h @@ -0,0 +1,31 @@ +/* Checking routines for select functions. Declaration only. + Copyright (C) 2023 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 _BITS_SELECT_DECL_H +#define _BITS_SELECT_DECL_H 1 + +#ifndef _SYS_SELECT_H +# error "Never include directly; use instead." +#endif + +/* Helper functions to issue warnings and errors when needed. */ +extern long int __fdelt_chk (long int __d); +extern long int __fdelt_warn (long int __d) + __warnattr ("bit outside of fd_set selected"); + +#endif diff --git a/misc/bits/select2.h b/misc/bits/select2.h index abd84a19d5..91e85c87d1 100644 --- a/misc/bits/select2.h +++ b/misc/bits/select2.h @@ -20,10 +20,8 @@ # error "Never include directly; use instead." #endif -/* Helper functions to issue warnings and errors when needed. */ -extern long int __fdelt_chk (long int __d); -extern long int __fdelt_warn (long int __d) - __warnattr ("bit outside of fd_set selected"); +#include + #undef __FD_ELT #define __FD_ELT(d) \ __extension__ \ From patchwork Wed Jul 5 14:10:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=iJYAa/2q; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1nv475dz20ZQ for ; Thu, 6 Jul 2023 00:12:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB4BE3875467 for ; Wed, 5 Jul 2023 14:12:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB4BE3875467 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566352; bh=1/7H9E21P1Vy30/gtc+tydhdlifS9DyjSohHr7ugx1U=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=iJYAa/2qYDR9wdmAHh1+NdCKwOxsaZ1J69LFdKE6RYVlC6BICSMHks5p6JXYUpRyt Ddb7fKcq7BYpq9uy+PN2s+a01tjvJh8WMrNj8b/IxbFDGxKwnegg2vx12O9BGWdvQD RL5p9WLsQzig3hNmKzSUFBCNS8g0HEJ8QY+dM9i8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id F29FB3857007 for ; Wed, 5 Jul 2023 14:11:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F29FB3857007 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-HuuChaeyPrmt0qoivR4AuA-1; Wed, 05 Jul 2023 10:11:18 -0400 X-MC-Unique: HuuChaeyPrmt0qoivR4AuA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11D62185A7A5; Wed, 5 Jul 2023 14:11:18 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 639B0F5CF0; Wed, 5 Jul 2023 14:11:17 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 11/14] misc/bits/syslog.h: Clearly separate declaration from definition Date: Wed, 5 Jul 2023 16:10:46 +0200 Message-ID: <20230705141055.274575-12-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This allows to include bits/syslog-decl.h in include/sys/syslog.h and therefore be able to create the libc_hidden_builtin_proto (__syslog_chk) prototype. Reviewed-by: Siddhesh Poyarekar --- include/bits/syslog-decl.h | 1 + include/sys/syslog.h | 4 +++ misc/Makefile | 1 + misc/bits/syslog-decl.h | 35 +++++++++++++++++++ misc/bits/syslog.h | 10 +----- misc/syslog.c | 4 ++- .../ldbl-128ibm-compat/ieee128-syslog.c | 1 + 7 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 include/bits/syslog-decl.h create mode 100644 misc/bits/syslog-decl.h diff --git a/include/bits/syslog-decl.h b/include/bits/syslog-decl.h new file mode 100644 index 0000000000..491a263777 --- /dev/null +++ b/include/bits/syslog-decl.h @@ -0,0 +1 @@ +#include diff --git a/include/sys/syslog.h b/include/sys/syslog.h index 44422eab13..1566228860 100644 --- a/include/sys/syslog.h +++ b/include/sys/syslog.h @@ -3,6 +3,8 @@ #include #ifndef _ISOMAC +#include + libc_hidden_ldbl_proto (syslog) /* __vsyslog_internal uses the same mode_flags bits as @@ -12,5 +14,7 @@ extern void __vsyslog_internal (int pri, const char *fmt, __gnuc_va_list ap, attribute_hidden __attribute__ ((__format__ (__printf__, 2, 0))); +libc_hidden_ldbl_proto (__syslog_chk) + #endif /* _ISOMAC */ #endif /* syslog.h */ diff --git a/misc/Makefile b/misc/Makefile index 3497d30f3b..fe0d49c1de 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -64,6 +64,7 @@ headers := \ sys/xattr.h \ syslog.h \ sys/syslog.h \ + bits/syslog-decl.h \ bits/syslog.h \ bits/syslog-ldbl.h \ bits/syslog-path.h \ diff --git a/misc/bits/syslog-decl.h b/misc/bits/syslog-decl.h new file mode 100644 index 0000000000..a9349feee0 --- /dev/null +++ b/misc/bits/syslog-decl.h @@ -0,0 +1,35 @@ +/* Checking routines for syslog functions. Declaration only. + Copyright (C) 2023 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 _BITS_SYSLOG_DECL_H +#define _BITS_SYSLOG_DECL_H 1 + +#ifndef _SYS_SYSLOG_H +# error "Never include directly; use instead." +#endif + +extern void __syslog_chk (int __pri, int __flag, const char *__fmt, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +#ifdef __USE_MISC +extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt, + __gnuc_va_list __ap) + __attribute__ ((__format__ (__printf__, 3, 0))); +#endif + +#endif diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h index 305cac4ba0..d7de90ed14 100644 --- a/misc/bits/syslog.h +++ b/misc/bits/syslog.h @@ -20,15 +20,7 @@ # error "Never include directly; use instead." #endif - -extern void __syslog_chk (int __pri, int __flag, const char *__fmt, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); - -#ifdef __USE_MISC -extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt, - __gnuc_va_list __ap) - __attribute__ ((__format__ (__printf__, 3, 0))); -#endif +#include #include #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 diff --git a/misc/syslog.c b/misc/syslog.c index f67d4b58a4..1b8cb722c5 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -101,7 +101,7 @@ __vsyslog (int pri, const char *fmt, va_list ap) ldbl_weak_alias (__vsyslog, vsyslog) void -__syslog_chk (int pri, int flag, const char *fmt, ...) +___syslog_chk (int pri, int flag, const char *fmt, ...) { va_list ap; @@ -109,6 +109,8 @@ __syslog_chk (int pri, int flag, const char *fmt, ...) __vsyslog_internal (pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0); va_end (ap); } +ldbl_hidden_def (___syslog_chk, __syslog_chk) +ldbl_strong_alias (___syslog_chk, __syslog_chk) void __vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c index 18aa7f707f..97810a7bbd 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c @@ -52,6 +52,7 @@ ___ieee128___syslog_chk (int pri, int flag, const char *fmt, ...) __vsyslog_internal (pri, fmt, ap, mode); va_end (ap); } +hidden_def (___ieee128___syslog_chk) strong_alias (___ieee128___syslog_chk, __syslog_chkieee128) void From patchwork Wed Jul 5 14:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Y+LqmABx; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1rw4zRhz20Pf for ; Thu, 6 Jul 2023 00:15:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A84EB3865C27 for ; Wed, 5 Jul 2023 14:15:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A84EB3865C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566510; bh=cfZpW+5KQq5TkdvBMXXwSUWcpd+t+10deNj/BF5SbE4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Y+LqmABxgXe+MrViu3JA/4wKtwC+s05j3keXOuCeYaGbTfYoXJ1XSXpj4CRUwPep2 eJVJ3kpiwcLgyoURHAWfzh3vM2qHk8Ue9y64/PRqLDlYRam1xE+QgIyMhiojxAks5V nvsSjYTkjMrZtpMcdfGQfhQ1s51X0BcXd9ViHMgQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 026A13857737 for ; Wed, 5 Jul 2023 14:11:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 026A13857737 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-GiI3jJm5NoWHvqoaKzgRFQ-1; Wed, 05 Jul 2023 10:11:19 -0400 X-MC-Unique: GiI3jJm5NoWHvqoaKzgRFQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 484BB8688DF; Wed, 5 Jul 2023 14:11:19 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53DD7F6403; Wed, 5 Jul 2023 14:11:18 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 12/14] libio/bits/stdio2.h: Clearly separate declaration from definitions Date: Wed, 5 Jul 2023 16:10:47 +0200 Message-ID: <20230705141055.274575-13-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Move declarations from libio/bits/stdio.h to existing libio/bits/stdio2-decl.h. This will enable future use of __REDIRECT_FORTIFY in place of some __REDIRECT. Reviewed-by: Siddhesh Poyarekar --- libio/bits/stdio2-decl.h | 49 ++++++++++++++++++++++++++++++++++++++++ libio/bits/stdio2.h | 48 --------------------------------------- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/libio/bits/stdio2-decl.h b/libio/bits/stdio2-decl.h index 9d4668da21..114b06d24b 100644 --- a/libio/bits/stdio2-decl.h +++ b/libio/bits/stdio2-decl.h @@ -84,18 +84,55 @@ extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack, #endif #if __GLIBC_USE (DEPRECATED_GETS) +extern char *__REDIRECT (__gets_warn, (char *__str), gets) + __wur __warnattr ("please use fgets or getline instead, gets can't " + "specify buffer size"); + extern char *__gets_chk (char *__str, size_t) __wur; #endif +extern char *__REDIRECT (__fgets_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets) + __wur __attr_access ((__write_only__, 1, 2)); +extern char *__REDIRECT (__fgets_chk_warn, + (char *__restrict __s, size_t __size, int __n, + FILE *__restrict __stream), __fgets_chk) + __wur __warnattr ("fgets called with bigger size than length " + "of destination buffer"); + extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __wur __attr_access ((__write_only__, 1, 3)); +extern size_t __REDIRECT (__fread_alias, + (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream), + fread) __wur; +extern size_t __REDIRECT (__fread_chk_warn, + (void *__restrict __ptr, size_t __ptrlen, + size_t __size, size_t __n, + FILE *__restrict __stream), + __fread_chk) + __wur __warnattr ("fread called with bigger size * nmemb than length " + "of destination buffer"); + extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __wur; #ifdef __USE_GNU +extern char *__REDIRECT (__fgets_unlocked_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets_unlocked) + __wur __attr_access ((__write_only__, 1, 2)); +extern char *__REDIRECT (__fgets_unlocked_chk_warn, + (char *__restrict __s, size_t __size, int __n, + FILE *__restrict __stream), __fgets_unlocked_chk) + __wur __warnattr ("fgets_unlocked called with bigger size than length " + "of destination buffer"); + + extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __wur __attr_access ((__write_only__, 1, 3)); @@ -103,6 +140,18 @@ extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, #ifdef __USE_MISC # undef fread_unlocked +extern size_t __REDIRECT (__fread_unlocked_alias, + (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream), + fread_unlocked) __wur; +extern size_t __REDIRECT (__fread_unlocked_chk_warn, + (void *__restrict __ptr, size_t __ptrlen, + size_t __size, size_t __n, + FILE *__restrict __stream), + __fread_unlocked_chk) + __wur __warnattr ("fread_unlocked called with bigger size * nmemb than " + "length of destination buffer"); + extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __wur; diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h index ad85f7df8b..71226408ab 100644 --- a/libio/bits/stdio2.h +++ b/libio/bits/stdio2.h @@ -182,10 +182,6 @@ __NTH (obstack_vprintf (struct obstack *__restrict __obstack, #endif #if __GLIBC_USE (DEPRECATED_GETS) -extern char *__REDIRECT (__gets_warn, (char *__str), gets) - __wur __warnattr ("please use fgets or getline instead, gets can't " - "specify buffer size"); - __fortify_function __wur char * gets (char *__str) { @@ -195,16 +191,6 @@ gets (char *__str) } #endif -extern char *__REDIRECT (__fgets_alias, - (char *__restrict __s, int __n, - FILE *__restrict __stream), fgets) - __wur __attr_access ((__write_only__, 1, 2)); -extern char *__REDIRECT (__fgets_chk_warn, - (char *__restrict __s, size_t __size, int __n, - FILE *__restrict __stream), __fgets_chk) - __wur __warnattr ("fgets called with bigger size than length " - "of destination buffer"); - __fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) char * fgets (char *__restrict __s, int __n, FILE *__restrict __stream) { @@ -216,18 +202,6 @@ fgets (char *__restrict __s, int __n, FILE *__restrict __stream) return __fgets_chk (__s, sz, __n, __stream); } -extern size_t __REDIRECT (__fread_alias, - (void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __stream), - fread) __wur; -extern size_t __REDIRECT (__fread_chk_warn, - (void *__restrict __ptr, size_t __ptrlen, - size_t __size, size_t __n, - FILE *__restrict __stream), - __fread_chk) - __wur __warnattr ("fread called with bigger size * nmemb than length " - "of destination buffer"); - __fortify_function __wur size_t fread (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) @@ -241,16 +215,6 @@ fread (void *__restrict __ptr, size_t __size, size_t __n, } #ifdef __USE_GNU -extern char *__REDIRECT (__fgets_unlocked_alias, - (char *__restrict __s, int __n, - FILE *__restrict __stream), fgets_unlocked) - __wur __attr_access ((__write_only__, 1, 2)); -extern char *__REDIRECT (__fgets_unlocked_chk_warn, - (char *__restrict __s, size_t __size, int __n, - FILE *__restrict __stream), __fgets_unlocked_chk) - __wur __warnattr ("fgets_unlocked called with bigger size than length " - "of destination buffer"); - __fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) char * fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) { @@ -265,18 +229,6 @@ fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) #ifdef __USE_MISC # undef fread_unlocked -extern size_t __REDIRECT (__fread_unlocked_alias, - (void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __stream), - fread_unlocked) __wur; -extern size_t __REDIRECT (__fread_unlocked_chk_warn, - (void *__restrict __ptr, size_t __ptrlen, - size_t __size, size_t __n, - FILE *__restrict __stream), - __fread_unlocked_chk) - __wur __warnattr ("fread_unlocked called with bigger size * nmemb than " - "length of destination buffer"); - __fortify_function __wur size_t fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) From patchwork Wed Jul 5 14:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=lTaKqB1t; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1pw3q2Cz20ZQ for ; Thu, 6 Jul 2023 00:13:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E4A13853D2B for ; Wed, 5 Jul 2023 14:13:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E4A13853D2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566406; bh=OuWN745uQt23s3bNyeGh6sfVUEe3pBa+rzNP9pGgZJ0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=lTaKqB1tqBcRyJHNucRXhtPK/NS/WNlpsp4xaRUZg5A16zZHXmTcqeagiecyMG9nw qZsj3GxenCp62UZBEQ4KCtETvitNzkqivjEN0p4fd4YcPdzMmsJURjaj6G+/BaIMUh 74v+PQO4vEx97SDh4ly80U8xKVt0Jz+33v8gT6fc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E14703856973 for ; Wed, 5 Jul 2023 14:11:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E14703856973 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-kzeltWn4NIO2Edw1Q87rnw-1; Wed, 05 Jul 2023 10:11:20 -0400 X-MC-Unique: kzeltWn4NIO2Edw1Q87rnw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3632081DB6C; Wed, 5 Jul 2023 14:11:20 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C8A6F5CF0; Wed, 5 Jul 2023 14:11:19 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 13/14] libio/bits/stdio2-decl.h: Avoid PLT entries with _FORTIFY_SOURCE Date: Wed, 5 Jul 2023 16:10:48 +0200 Message-ID: <20230705141055.274575-14-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The change is meant to avoid unwanted PLT entry for the fgets_unlocked routine when _FORTIFY_SOURCE is set. Reviewed-by: Siddhesh Poyarekar --- libio/bits/stdio2-decl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libio/bits/stdio2-decl.h b/libio/bits/stdio2-decl.h index 114b06d24b..d7ef7283d6 100644 --- a/libio/bits/stdio2-decl.h +++ b/libio/bits/stdio2-decl.h @@ -122,7 +122,7 @@ extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, FILE *__restrict __stream) __wur; #ifdef __USE_GNU -extern char *__REDIRECT (__fgets_unlocked_alias, +extern char *__REDIRECT_FORTIFY (__fgets_unlocked_alias, (char *__restrict __s, int __n, FILE *__restrict __stream), fgets_unlocked) __wur __attr_access ((__write_only__, 1, 2)); From patchwork Wed Jul 5 14:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=mxEVgKkH; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1pk624lz20ZQ for ; Thu, 6 Jul 2023 00:13:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 393503884526 for ; Wed, 5 Jul 2023 14:13:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 393503884526 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566395; bh=bY7SUQCA3DSXnCTdHkNT+b7A5OL7dp63OoLm1pBxvkU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=mxEVgKkH6Q16cPSCStywCD8GsBW/9vQN/mUDU0dj4uJ3DFbb6+TMkFdmPXq/qXPAr Y03teXWQiluqDm5g+pRH/ah2tgKN3pDLVLl/iKyY78S/wVzoYiPz5i2ZbOtKLvuCwr kzwrgY8L7WBfpOpcW/xgYMzMz8cvkkMnFv4rIGEU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1A6133857034 for ; Wed, 5 Jul 2023 14:11:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A6133857034 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-hXHXJlzfOuyjuAIt9iUoTQ-1; Wed, 05 Jul 2023 10:11:21 -0400 X-MC-Unique: hXHXJlzfOuyjuAIt9iUoTQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A3903C1EF2B; Wed, 5 Jul 2023 14:11:21 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6AD93F6404; Wed, 5 Jul 2023 14:11:20 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 14/14] sysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result Date: Wed, 5 Jul 2023 16:10:49 +0200 Message-ID: <20230705141055.274575-15-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Return value from *scanf and *asprintf routines are now properly checked in test-scanf-ldbl-compat-template.c and test-printf-ldbl-compat.c. Reviewed-by: Siddhesh Poyarekar --- .../test-printf-ldbl-compat.c | 10 +++++---- .../test-scanf-ldbl-compat-template.c | 21 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c index 3c759e1427..be37af7c31 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c @@ -30,12 +30,13 @@ do_test_call_varg (FILE *stream, const char *format, ...) char *buffer = NULL; char string[128]; va_list args; + int ret; printf ("%15s", "vasprintf: "); va_start (args, format); - vasprintf (&buffer, format, args); + ret = vasprintf (&buffer, format, args); va_end (args); - if (buffer == NULL) + if (ret == -1 || buffer == NULL) printf ("Error using vasprintf\n"); else { @@ -82,10 +83,11 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld, double d) { char *buffer = NULL; char string[128]; + int ret; printf ("%15s", "asprintf: "); - asprintf (&buffer, format, ld, d); - if (buffer == NULL) + ret = asprintf (&buffer, format, ld, d); + if (ret == -1 || buffer == NULL) printf ("Error using asprintf\n"); else { diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c index e8da3a67f0..776c12dd16 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c @@ -37,10 +37,10 @@ ldptr = va_arg (args, long double *); \ fptr = va_arg (args, float *); \ va_end (args); \ - if (*ldptr == -1 && *fptr == -2) \ + if (*ldptr == -1 && *fptr == -2 && ret == 2) \ printf ("OK"); \ else \ - printf ("ERROR (%Lf %f)", *ldptr, *fptr); \ + printf ("ERROR (%Lf %f %d)", *ldptr, *fptr, ret); \ printf ("\n"); #define CLEAR_VALUE \ @@ -48,10 +48,10 @@ f = 0; #define CHECK_VALUE \ - if (ld == -1 && f == -2) \ + if (ld == -1 && f == -2 && ret == 2) \ printf ("OK"); \ else \ - printf ("ERROR (%Lf %f)", ld, f); \ + printf ("ERROR (%Lf %f %d)", ld, f, ret); \ printf ("\n"); static void @@ -62,40 +62,41 @@ do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...) float *fptr; long double *ldptr; va_list args; + int ret; CLEAR_VALUE printf ("fscanf: "); - FSCANF (stream, format, &ld, &f); + ret = FSCANF (stream, format, &ld, &f); CHECK_VALUE CLEAR_VALUE printf ("scanf: "); - SCANF (format, &ld, &f); + ret = SCANF (format, &ld, &f); CHECK_VALUE CLEAR_VALUE printf ("sscanf: "); - SSCANF (string, format, &ld, &f); + ret = SSCANF (string, format, &ld, &f); CHECK_VALUE CLEAR_VARGS printf ("vfscanf: "); va_start (args, format); - VFSCANF (stream, format, args); + ret = VFSCANF (stream, format, args); va_end (args); CHECK_VARGS CLEAR_VARGS printf ("vscanf: "); va_start (args, format); - VSCANF (format, args); + ret = VSCANF (format, args); va_end (args); CHECK_VARGS CLEAR_VARGS printf ("vsscanf: "); va_start (args, format); - VSSCANF (string, format, args); + ret = VSSCANF (string, format, args); va_end (args); CHECK_VARGS }