From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from chocolate.ash.relay.mailchannels.net (chocolate.ash.relay.mailchannels.net [23.83.222.35]) by sourceware.org (Postfix) with ESMTPS id 8FECA383580A for ; Mon, 16 May 2022 16:24:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8FECA383580A 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 090312A1E8B for ; Mon, 16 May 2022 16:24:11 +0000 (UTC) Received: from pdx1-sub0-mail-a306.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 9C0592A3085 for ; Mon, 16 May 2022 16:24:10 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1652718250; a=rsa-sha256; cv=none; b=Cyn01PeJ7jY4mJwVsNbvTyM0cQH5jcmf9zBsFDZvj7A3qO86oMjs5b9kUtWqfyhOxsa7YW K23DACCkxoM0OJfbpxtl1133Hyd9tGazcsiOb6nxyvE9m9zIwYbd+MzhnZ4HeW28lfjYRa ChMHckSAYKYkNBfL+lNtyJsYSdDfWpn8Qeqp9mIww8oQuq25GxQXdhg3EVItJrzgVp2PyV zJPUK0WDJS/6fu1PnxfZLPc1uNvUEFmvyz7R88epS/ZdmworD8K2nC7vh9hfmD8Hy6CcF4 V+A/pR4F/hdQut+AxXAh54g+dTlG+xW/dj4rAdX1NVcxa2CnPT2uDDcRSLNzMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1652718250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xXWQNAfSyWfgXRQ+9DM3poGOmPNRHSVibhbAG0GXDZE=; b=Rf9I3q7VlvZZzH5liugRRKEcZxuVQJJYyDrO1ixgGWJ4nwUoWp4xk81uoEKu5tgO24rpXB jYjy0lPHuQHKnIR2Yb2kTqNjkhrAvHqnlwTha2gvcJnLL4I3PdvN8C7wdjX0/+llD5jci0 B6aGQMRYpqajD4hQbjvI5BxIg9wGLhMu84me54nuzgUE3QH7gGq6MFzhP7knY9pXh4gFIf uCJjcDTTGTxKnLi1plzuagwlclwlyVGSwFKQ/ZFmIiBFv8P2Osj6fjjKzVYqsdIY19t8uw eEx+/qO4kvprKLwS+eutWxi7njhHDWPpdRKXMipOgm5h0fMMO6rDLI9sXmWVEw== ARC-Authentication-Results: i=1; rspamd-6fcfc4d76-kwqkt; 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-Shelf-Obese: 75960ae347dc08b0_1652718250869_4133897229 X-MC-Loop-Signature: 1652718250869:2844399390 X-MC-Ingress-Time: 1652718250868 Received: from pdx1-sub0-mail-a306.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.96.96.15 (trex/6.7.1); Mon, 16 May 2022 16:24:10 +0000 Received: from rhbox.redhat.com (unknown [1.186.223.88]) (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-a306.dreamhost.com (Postfix) with ESMTPSA id 4L24MF1NwXz1P7 for ; Mon, 16 May 2022 09:24:08 -0700 (PDT) From: Siddhesh Poyarekar To: libc-stable@sourceware.org Subject: [committed 2.35] fortify: Ensure that __glibc_fortify condition is a constant [BZ #29141] Date: Mon, 16 May 2022 21:40:35 +0530 Message-Id: <20220516161035.1011515-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3493.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NEUTRAL, 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-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 16:24:17 -0000 The fix c8ee1c85 introduced a -1 check for object size without also checking that object size is a constant. Because of this, the tree optimizer passes in gcc fail to fold away one of the branches in __glibc_fortify and trips on a spurious Wstringop-overflow. The warning itself is incorrect and the branch does go away eventually in DCE in the rtl passes in gcc, but the constant check is a helpful hint to simplify code early, so add it in. Resolves: BZ #29141 Signed-off-by: Siddhesh Poyarekar --- misc/sys/cdefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index f1faf8292c..1c2b044a0d 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -164,7 +164,7 @@ /* Length is known to be safe at compile time if the __L * __S <= __OBJSZ condition can be folded to a constant and if it is true, or unknown (-1) */ #define __glibc_safe_or_unknown_len(__l, __s, __osz) \ - ((__osz) == (__SIZE_TYPE__) -1 \ + ((__builtin_constant_p (__osz) && (__osz) == (__SIZE_TYPE__) -1) \ || (__glibc_unsigned_or_positive (__l) \ && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ (__s), (__osz))) \ -- 2.35.1