From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB260C433EF for ; Mon, 28 Feb 2022 18:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4yzJJFCdxOP8gLCl8PtHYO+rKkU6G/7ech/+xWq+UXI=; b=HtWo+WbGc+8hH3 gFNTUiExYVZfjjErnPLl8L1uutqbABjAybPwzicXBDM1kcACahTjVjjakqjoXCzO1ZKKXRdBa5A3T E/vDBj/kzhleIhS8epl5C0I9q/u9rdIbFtDlgOP93dBePoztGpV2nrMZqAfaJIwYSVKEtKJEteJKV y654W5+T4iTugWbmXOYzmknXx2PBFhjYAnqq/vRKIaK5WbNvPj+oVCnA2U6Rb3CZNJFfxPNC8nVAn s8kX+S0i9hqmbg8QqSEAWFjqjnQ18dke33MvjdR5HCBOLMGIMGQkc/pp2bOre5HYLJgY/KqAYG5Kz NcLVxMtvhIVOyzCGW7Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOkh3-00DhKm-Qs; Mon, 28 Feb 2022 18:24:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOkh0-00DhJl-Gz for linux-arm-kernel@lists.infradead.org; Mon, 28 Feb 2022 18:24:19 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A2E171042; Mon, 28 Feb 2022 10:24:11 -0800 (PST) Received: from arm.com (arrakis.cambridge.arm.com [10.1.196.175]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E23C3F70D; Mon, 28 Feb 2022 10:24:09 -0800 (PST) Date: Mon, 28 Feb 2022 18:24:07 +0000 From: Catalin Marinas To: Mark Brown Cc: Will Deacon , Szabolcs Nagy , Jeremy Linton , "H . J . Lu" , Yu-cheng Yu , Kees Cook , Eric Biederman , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org Subject: Re: [PATCH v10 2/2] arm64: Enable BTI for main executable as well as the interpreter Message-ID: References: <20220228130606.1070960-1-broonie@kernel.org> <20220228130606.1070960-3-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220228130606.1070960-3-broonie@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_102418_650494_B34DE66B X-CRM114-Status: GOOD ( 17.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Feb 28, 2022 at 01:06:06PM +0000, Mark Brown wrote: > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 5369e649fa79..82aaf361fa17 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -701,23 +701,49 @@ core_initcall(tagged_addr_init); > #endif /* CONFIG_ARM64_TAGGED_ADDR_ABI */ > > #ifdef CONFIG_BINFMT_ELF > +static unsigned int bti_main; > + > int arch_elf_adjust_prot(int prot, const struct arch_elf_state *state, > bool has_interp, bool is_interp) > { > - /* > - * For dynamically linked executables the interpreter is > - * responsible for setting PROT_BTI on everything except > - * itself. > - */ > - if (is_interp != has_interp) > - return prot; > - > - if (!(state->flags & ARM64_ELF_BTI)) > - return prot; > - > - if (prot & PROT_EXEC) > + if ((prot & PROT_EXEC) && > + (is_interp || !has_interp || bti_main) && > + (state->flags & arm64_elf_bti_flag(is_interp))) > prot |= PROT_BTI; > > return prot; > } TBH, I liked the other series more as we were getting rid of 'has_interp' in patches 3 and 4. Now we keep it around only for the bti_main case on dynamic executables (i.e. we need to distinguish them from static). We could still get rid of has_interp if bti_main was default on and it affected static binaries as well (for consistency, it wouldn't be a bad idea). I think the risk of ABI breaking is negligible in a glibc distro since currently the dynamic loader sets PROT_BTI on the main exe anyway, just as the kernel does after this series. Anyway, from a correctness perspective, this patch looks fine to me, just a preference for the other series: Reviewed-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel