From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 2580D1F44D for ; Tue, 23 Apr 2024 15:27:38 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=XnCoIo2p; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=Cyotdyb9; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id D472B84468; Tue, 23 Apr 2024 15:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713886049; bh=IdlCCRP0Bc/bZUQjAs06IwBwMHv3Jw8K2tKV2ROHB2w=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=XnCoIo2plVoizGMThA9Rkyc/9YaqVlBJBxwTHBooyM2uJC6a95j4kwcKgbQ+QokRg np9ZQnJI4zy0+uICSAb4v+1hhpl8K3YINqsay+9ZY2g0z64WKMbW4kE42FL/E8Yadl j2gqoaGnnX91I7UySLNn1Nf/h5W9P1l0V04WCa/I= Received: from s.wrqvwxzv.outbound-mail.sendgrid.net (s.wrqvwxzv.outbound-mail.sendgrid.net [149.72.154.232]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 9BFD584319 for ; Tue, 23 Apr 2024 15:27:26 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=Cyotdyb9; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=fC4iV7xjKCgo1ojPrqMk/++LW4He7uuDwOEjdB4a1A8=; b=Cyotdyb9xty9ooJo49eAGCVICC6FrVN0Jg9keiQEO9P7BscOeLkTHHelj8syBmhPT74m KQ/SRKnC45JFmcG89kK5eZ+e5LogbnvV1lnfdmcKwSBDSjxrMRSqcQfxyApSR5B3CfIdHP lEfYVB9XWLwIiaKBADyRU6oFqdhL3M/JwT6tcrKxYk7fc442c0BSnSZXrwQo40y5YWBKjW rwYzaSfet82QqKBqGV8iVE20RLqWk0ZEALxxmdYo1hZ+4je/ALmjKF+ORlcxYCUi1CrlLM Xozp28xkBfIZ/zGxHIK7IVLyLgHRG7EMxcSnTcUUx75YRq+0ugCITN4gFZNvbsSA== Received: by filterdrecv-6db7b8944d-r72h9 with SMTP id filterdrecv-6db7b8944d-r72h9-1-6627D35C-21 2024-04-23 15:27:24.57549905 +0000 UTC m=+59127.010740920 Received: from herokuapp.com (unknown) by geopod-ismtpd-21 (SG) with ESMTP id 5c-5ZNuYTiaptlY_Wg-lqw for ; Tue, 23 Apr 2024 15:27:24.562 +0000 (UTC) Date: Tue, 23 Apr 2024 15:27:24 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20154 X-Redmine-Issue-Author: jprokop X-Redmine-Issue-Priority: Normal X-Redmine-Sender: vo.x X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 94250 X-SG-EID: =?us-ascii?Q?u001=2EyMiCBSACWrWmffOKyGXWHegF7vzERB8YDC=2Fl8bL1VoJCfzjoEQKqqhWMB?= =?us-ascii?Q?cCIxOU5CxEWLdUTISPq9d+vx=2FmMemcfTMyqzv40?= =?us-ascii?Q?0KWaIh3uqWtGa77mcWQguAjjKFZuhCBChzPKfFy?= =?us-ascii?Q?y2aoPNExGzWFQ8DY1YjudkANSaYRX3cPDvP+Dxq?= =?us-ascii?Q?QprCCCazhBS8e=2FA2oLkLJAzHGDxB9Yi+aaJlTqr?= =?us-ascii?Q?vkLCyeyMiU4bF+oUGXAtnDySEs2J=2FeddXuw7b+P?= =?us-ascii?Q?08IyURkrb1T5YBRCTcix4gig+w=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: HME6PEQXVKVHENX4MMGDIWLSH4QVURXW X-Message-ID-Hash: HME6PEQXVKVHENX4MMGDIWLSH4QVURXW X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117654] [Ruby master Bug#20154] aarch64: configure overrides `-mbranch-protection` if it was set in CFLAGS via environment List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "vo.x (Vit Ondruch) via ruby-core" Cc: "vo.x (Vit Ondruch)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20154 has been updated by vo.x (Vit Ondruch). Any update please? We are still carrying downstream patch in Fedora, so it would be nice to get this upstreamed ---------------------------------------- Bug #20154: aarch64: configure overrides `-mbranch-protection` if it was set in CFLAGS via environment https://bugs.ruby-lang.org/issues/20154#change-108064 * Author: jprokop (Jarek Prokop) * Status: Open * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [aarch64-linux] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Recently a GH PR was merged For PAC/BTI support on ARM CPUs for Coroutine.S. Without proper compilation support in configure.ac it segfaults Ruby with fibers on CPUs where PAC is supported: https://bugs.ruby-lang.org/issues/20085 At the time of writing, configure.ac appends the first option from a list for flag `-mbranch-protection` that successfully compiles a program , to XCFLAGS and now also ASFLAGS to fix issue 20085 for Ruby master. This is suboptimal for Fedora as we set -mbranch-protection=standard by default in C{,XX}FLAGS: ``` CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' export CFLAGS CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer' export CXXFLAGS ``` And the appended flag overrides distribution's compilation configuration, which in this case ends up omitting BTI instructions and only using PAC. Would it make sense to check if such flags exist and not overwrite them if they do? Serious proposals: 1. Simplest fix that does not overwrite what is set in the distribution and results in higher security is simply prepending the list of options with `-mbranch-protection=standard`, it should cause no problems on ARMv8 CPUs and forward, BTI similarly to PAC instructions result into NOP, it is only extending the capability. See attached 0001-aarch64-Check-mbranch-protection-standard-first-to-u.patch 2. Other fix that sounds more sane IMO and dodges this kind of guessing where are all the correct places for the flag is what another Fedora contributor Florian Weimer suggested: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/CVTNF2OQCL3XZHUUFNYMDK6ZEF2SWUEN/ "The reliable way to do this would be to compile a C file and check whether that enables __ARM_FEATURE_PAC_DEFAULT, and if that's the case, define a *different* macro for use in the assembler implementation. This way, you don't need to care about the exact name of the option." IOW instead of using __ARM_FEATURE_* directly in that code, define a macro in the style of "USE_PAC" with value of the feature if it is defined, I think that way we shouldn't need to append ASFLAGS anymore. However it's also important to catch the value of those macros as their values have meaning, I have an idea how to do that but I'd get on that monday earliest. ---Files-------------------------------- 0001-aarch64-Check-mbranch-protection-standard-first-to-u.patch (1004 Bytes) -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/