From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 34CBC385840B for ; Wed, 28 Jun 2023 08:43:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34CBC385840B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687941779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KNz7Lm47fzJ3Q/CiHtGsNG6QGDXka1Tcsxp3X1TpVDY=; b=ZXWv/wMoFbD3wfzfYl9pYfs7sGCyMfCCE6Yv1u2tDWzZlOpaF6UevI040IOp0uzrzAAMat KYi5TsaMqBxVcPvZVL4ewtCx2GqhwT3jalphnPNJ3SQC6ADLTm3jp7Z8lh7pWMa+c8P89v FSq1NyWGy0/xp1xrWwmOFxAC/DZo1lo= 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-322-zAL0GEPnPYGZhft6HCeFKA-1; Wed, 28 Jun 2023 04:42:58 -0400 X-MC-Unique: zAL0GEPnPYGZhft6HCeFKA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 531FC1C09A45; Wed, 28 Jun 2023 08:42:58 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABD11492B02; Wed, 28 Jun 2023 08:42:57 +0000 (UTC) From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com Subject: [PATCH v3 07/16] misc/sys/cdefs.h: Create FORTIFY redirects for internal calls Date: Wed, 28 Jun 2023 10:42:37 +0200 Message-ID: <20230628084246.778302-8-fberat@redhat.com> In-Reply-To: <20230628084246.778302-1-fberat@redhat.com> References: <20230628084246.778302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.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_H5,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 List-Id: 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. --- 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__ -- 2.41.0