From patchwork Mon Jan 30 13:32:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 63914 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E04F3858C83 for ; Mon, 30 Jan 2023 13:32:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E04F3858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675085567; bh=BDLnQ12Xl+CF6D9dV/vmLwucwt4J4IFUBgU9Cdlyf5s=; 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=R+8KDZfqB81/BFTY4/ZKM7pkhRt6tJNUrFo9gMLYz3nUE6LC44F+sdJJk5eGuHyCZ W1PDuIpUysf1a1BOORsDJDmbX4M67mKA9Qe72mDB1j5+WzEWUZUW1BNvQYuiWL9fhT TV5nds+FYpREz41Qz4j4v10hjT6o2eUBhHLxAmj0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from quail.birch.relay.mailchannels.net (quail.birch.relay.mailchannels.net [23.83.209.151]) by sourceware.org (Postfix) with ESMTPS id 7DB113858CDA for ; Mon, 30 Jan 2023 13:32:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7DB113858CDA X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id EFC70100851; Mon, 30 Jan 2023 13:32:21 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 8F6F1100A4E; Mon, 30 Jan 2023 13:32:21 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1675085541; a=rsa-sha256; cv=none; b=QrpH9kRO+kHYFu6HWQk1janr9Cc1FYWPLRu5BYJAAUw6nuAjFY8rWkhe5Fl+jbGIpu7AdJ wWryAqqiv4YqPZ2doYq63FA1ucHIkzOhgHedjySwb3K9D5/aE6WI8OmACkFbYEyibPYW7W vBgYS77Ly8cCB+q/06B/FU5/AA8xX6FXtKg1lreQVQCuRpyq8qQvoDlq97rwEWBakn1ppM MClHGpA1p2RFU2sk2jEW6zeLa8xnX8kSA20CMIIxzq3jE8vyMC9Ab74ogppx4HSORHjOjz FZroO1tuy8OiWtsil24aNPwmUB55WX9qwjOAXLoFbXubeh+e/1PtJF24u6QKkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1675085541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BDLnQ12Xl+CF6D9dV/vmLwucwt4J4IFUBgU9Cdlyf5s=; b=OxIC9Z24OrbegFE1UhgGPT915+HEbd016pL9SOF2WyT8K+KS0zYN/cSV9AX6c7ZNvopDCc Aq6gpXwNGdActw9d5xQ12yGJwKK9UbcywIp0+byU01FB2rgzXqrZHmZi/01mg1M90J6q1m BJ9jYIlVRk6MXHrtiJZuHz/emXPrnkmbmHFMINMjQrpGUWklAGgQNaxWEIt8qsdssuu7Jt Dwn+qhVOGegjwReUMXM3P1f6IteVDDtdE1zMYjs03ljlKFcXfiUDTk0W/dDniPp59HtKWW cIbF1fGyRohHPW0CP1bNpE7nu9rGjP+Lnli5SHcdfH55ptrz0Q0h/Pp5JhGHSQ== ARC-Authentication-Results: i=1; rspamd-544f66f495-5k5f2; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Irritate-Bubble: 3856817e0e405338_1675085541819_1924576935 X-MC-Loop-Signature: 1675085541819:2366377244 X-MC-Ingress-Time: 1675085541818 Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.24.83 (trex/6.7.1); Mon, 30 Jan 2023 13:32:21 +0000 Received: from fedora.redhat.com (bras-vprn-toroon4834w-lp130-07-174-93-43-36.dsl.bell.ca [174.93.43.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4P58HS6sDmzRQ; Mon, 30 Jan 2023 05:32:20 -0800 (PST) To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH] cdefs: Limit definition of fortification macros Date: Mon, 30 Jan 2023 08:32:17 -0500 Message-Id: <20230130133217.497398-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <87v8koxkel.fsf@oldenburg.str.redhat.com> References: <87v8koxkel.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1173.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP 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: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Define the __glibc_fortify and other macros only when __FORTIFY_LEVEL > 0. This has the effect of not defining these macros on older C90 compilers that do not have support for variable length argument lists. Also trim off the trailing backslashes from the definition of __glibc_fortify and __glibc_fortify_n macros. Signed-off-by: Siddhesh Poyarekar Reviewed-by: Florian Weimer --- Only tested for sanity. Florian, can you please verify that this resolves the original problem? misc/sys/cdefs.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 66d6702123..c37a3ff637 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -152,6 +152,7 @@ # define __glibc_objsize(__o) __bos (__o) #endif +#if __USE_FORTIFY_LEVEL > 0 /* Compile time conditions to choose between the regular, _chk and _chk_warn variants. These conditions should get evaluated to constant and optimized away. */ @@ -187,7 +188,7 @@ ? __ ## f ## _alias (__VA_ARGS__) \ : (__glibc_unsafe_len (__l, __s, __osz) \ ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \ - : __ ## f ## _chk (__VA_ARGS__, __osz))) \ + : __ ## f ## _chk (__VA_ARGS__, __osz))) /* Fortify function f, where object size argument passed to f is the number of elements and not total size. */ @@ -197,7 +198,8 @@ ? __ ## f ## _alias (__VA_ARGS__) \ : (__glibc_unsafe_len (__l, __s, __osz) \ ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \ - : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \ + : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) +#endif #if __GNUC_PREREQ (4,3) # define __warnattr(msg) __attribute__((__warning__ (msg)))