From patchwork Mon Jun 20 17:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1645644 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=kHlAS69D; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LRcqk3jbkz9sFw for ; Tue, 21 Jun 2022 04:00:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53C9D38418AC for ; Mon, 20 Jun 2022 17:59:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53C9D38418AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1655747998; bh=gHVtmlMD8elUCpvmuulS/xUI4MMUdb3D1WKUAtdO58I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kHlAS69DIHIg70pfC0osvJlRoRAF5EYsI5JyV3UZAUQvbgqaTFSyvSDzAFAgxruAR TF+ToWpLvojaLJPELi7lndE8w21s1KEEvsEbNIttx1liiDIfKLUzO42xEjDbL+Gvpu BTle4ajUuTHmJvejChmZJhJMrKmeKjbpyMfGWyBo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from boar.tulip.relay.mailchannels.net (boar.tulip.relay.mailchannels.net [23.83.218.250]) by sourceware.org (Postfix) with ESMTPS id B1A623850857 for ; Mon, 20 Jun 2022 17:59:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B1A623850857 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 54675820DC9 for ; Mon, 20 Jun 2022 17:59:37 +0000 (UTC) Received: from pdx1-sub0-mail-a307.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 567BE821A56 for ; Mon, 20 Jun 2022 17:59:36 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1655747976; a=rsa-sha256; cv=none; b=s8t00ZpGLID0P5eOQXIRmb2iEiOflY2c+pUzq9V5gKfaO7l5v7vTyIXMy1dEa6Xew6diVx LmqS4gSDaLYxgsVrM3Hw4j7pSKKrRsD/jaamg0QMQc6ufmCOWfnwE2QEer77cJ7GXhQckg HN+X7KnH3F8a781BcIchEHOmhwqxjif0XTvGQifZ9+HbgdVROUg4yPs/IXwzgNdoWutDWQ VMERIjrdbwMC10/rOXagnZaoX29GnVfqygAELUgJaw7DiK0jyWUUnVGfQGg3bGzehAaBZw pNcQQvOitOAxJsv8eviQ7m8EFLbs2wNvsvnzYUbqQKwUoALPZ500OPmQhbKRLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1655747976; 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=gHVtmlMD8elUCpvmuulS/xUI4MMUdb3D1WKUAtdO58I=; b=YqJV8aXtKN81IaUEHIWa39P1lIY/xyB9Jjla9RHEj5ziMSJaDuiN6u4xI70lQMuNy0Bv73 gBQ++nNPahBE1Xz6RxYUR+htOQ49EhCIM4joth7VoMNyIwIb4jKDdhptdaQ9ePR+/1fE6z g7CDD51kVcJM4ZT2/9SSqbS2SBb54zZu1JdAXcuEsw+Yrie7sudX1Zs90ZFdhH08D8nmf1 GlobNPkcVJGscbC0UKyFCn1+ui6sP2qJ9YrcUyfpzxfTlJgKwXcRvnbAxV2teKQuo4Ac6c KPCeu/oFMN3E+K/17EyT0ut7ZIWrDpiLLYmLPWtjg/WWAH3YOiX77XsSNvg8sw== ARC-Authentication-Results: i=1; rspamd-848669fb87-tmqp7; 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-Glossy-Unite: 0e403b1e5ccebc39_1655747976774_911190151 X-MC-Loop-Signature: 1655747976774:1788813234 X-MC-Ingress-Time: 1655747976774 Received: from pdx1-sub0-mail-a307.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.115.45.51 (trex/6.7.1); Mon, 20 Jun 2022 17:59:36 +0000 Received: from rhbox.redhat.com (unknown [223.182.179.254]) (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-a307.dreamhost.com (Postfix) with ESMTPSA id 4LRcqB6VCbzmd for ; Mon, 20 Jun 2022 10:59:34 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [committed 2.34] fortify: Ensure that __glibc_fortify condition is a constant [BZ #29141] Date: Mon, 20 Jun 2022 23:29:29 +0530 Message-Id: <20220620175929.736651-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-1169.5 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-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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" 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 (cherry picked from commit 61a87530108ec9181e1b18a9b727ec3cc3ba7532) --- 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 b36013b9a6..e0ecd9147e 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -163,7 +163,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))) \