From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by sourceware.org (Postfix) with ESMTPS id 4235D398E461 for ; Thu, 3 Jun 2021 18:04:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4235D398E461 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD84D613E3; Thu, 3 Jun 2021 18:04:33 +0000 (UTC) Date: Thu, 3 Jun 2021 19:04:31 +0100 From: Catalin Marinas To: Mark Brown Cc: Dave Martin , Will Deacon , Szabolcs Nagy , Jeremy Linton , "H . J . Lu" , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org Subject: Re: [PATCH v1 2/2] arm64: Enable BTI for main executable as well as the interpreter Message-ID: <20210603180429.GI20338@arm.com> References: <20210521144621.9306-1-broonie@kernel.org> <20210521144621.9306-3-broonie@kernel.org> <20210603154034.GH4187@arm.com> <20210603165134.GF4257@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210603165134.GF4257@sirena.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Thu, 03 Jun 2021 18:04:39 -0000 On Thu, Jun 03, 2021 at 05:51:34PM +0100, Mark Brown wrote: > On Thu, Jun 03, 2021 at 04:40:35PM +0100, Dave Martin wrote: > > Do we know how libcs will detect that they don't need to do the > > mprotect() calls? Do we need a detection mechanism at all? > > > > Ignoring certain errors from mprotect() when ld.so is trying to set > > PROT_BTI on the main executable's code pages is probably a reasonable, > > backwards-compatible compromise here, but it seems a bit wasteful. > > I think the theory was that they would just do the mprotect() calls and > ignore any errors as they currently do, or declare that they depend on a > new enough kernel version I guess (not an option for glibc but might be > for others which didn't do BTI yet). I think we discussed the possibility of an AT_FLAGS bit. Until recently, this field was 0 but it gained a new bit now. If we are to expose this to arch-specific things, it may need some reservations. Anyway, that's an optimisation that can be added subsequently. -- Catalin