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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D38BC433E0 for ; Mon, 8 Feb 2021 14:54:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE9FB64E0B for ; Mon, 8 Feb 2021 14:54:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE9FB64E0B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=/WFx0UO+oC2CQYCnPSst1FEQlg+TmtMt3eXLGsr5ARE=; b=sk8HX9sl+T3F/ONsUJU0K4lzx 64Qh4EWEujZDQ36sEeOYS9IF80+SxreQq1kJpubIvwAwG/6RuKmQAo3XL0XJZa+RbkPul8rdSDTi8 5k6iqO8wk7NpwLuN3C6bUW4Utyy2Im8upp4p6fTlf3e2cnTcx38Zccm5vaaDStZ04aMJjmzaSBqyi EWl/f6cFd1jwZ/K7iZ/8ZqEZ/1jgHx9/sDp0GEPUvlAmJgFaTynPZc2lVYz+mKHwgT1uaHxIAGmSX Lc0lOnyqv2vUkUtYT5+pMjBLHcE1BhDfFFKonT64EZ1iDpHLPaoAHG+SG/Hd5q0ipDmC/P4wzuOnZ awDy2b0Tw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l97v6-0001jX-46; Mon, 08 Feb 2021 14:53:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l97v3-0001jD-Ut for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 14:53:42 +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 A9BF71FB; Mon, 8 Feb 2021 06:53:38 -0800 (PST) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8DC043F719; Mon, 8 Feb 2021 06:53:37 -0800 (PST) Date: Mon, 8 Feb 2021 14:53:16 +0000 From: Dave Martin To: Mark Brown Subject: Re: [PATCH] arm64: bti: Set PROT_BTI on all BTI executables mapped by the kernel Message-ID: <20210208145315.GE21837@arm.com> References: <20210205173837.39315-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210205173837.39315-1-broonie@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210208_095342_129490_AB435CF5 X-CRM114-Status: GOOD ( 29.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , libc-alpha@sourceware.org, Kees Cook , Catalin Marinas , Jeremy Linton , Will Deacon , linux-arm-kernel@lists.infradead.org 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 Fri, Feb 05, 2021 at 05:38:37PM +0000, Mark Brown via Libc-alpha wrote: > Currently for dynamically linked executables the kernel only enables > PROT_BTI for the interpreter, the interpreter is responsible for > enabling it for everything else including the main executable. > Unfortunately this interacts poorly with systemd's > MemoryDenyWriteExecute feature which uses a seccomp filter to prevent > setting PROT_EXEC on already mapped memory via mprotect(), it lacks the > context to detect that PROT_EXEC is already set and so refuses to allow > the mprotect() on the main executable which the kernel has already > mapped. > > Since we don't want to force users to choose between having MDWX and BTI > as these are othogonal features have the kernel enable PROT_BTI for all > the ELF objects it loads, not just the dynamic linker. This means that > if there is a problem with BTI it will be harder to disable at the > executable level but we currently have no conditional support for this > in any libc anyway so that would be new development. Ideally we would > have interfaces that allowed us to more clearly specify what is enabled > and disabled by a given syscall but this would be a far more difficult > change to deploy. > > Reported-by: Jeremy Linton > Suggested-by: Catalin Marinas > Signed-off-by: Mark Brown > Cc: Mark Rutland > Cc: Szabolcs Nagy > Cc: Dave Martin > Cc: Kees Cook > Cc: libc-alpha@sourceware.org > --- > > This solution was proposed by Catalin, I'm just writing it up into a > patch since it looks to be what we've converged on as the most practical > solution and but things seemed to have stalled out. > > arch/arm64/kernel/process.c | 8 -------- > 1 file changed, 8 deletions(-) > > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 71c8265b9139..0967f9e1f9fd 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -717,14 +717,6 @@ asmlinkage void __sched arm64_preempt_schedule_irq(void) > 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; > - Reviewed-by: Dave Martin > if (!(state->flags & ARM64_ELF_BTI)) > return prot; The original idea was to interfere with userspace as little as possible, and leave this until/unless there was a clear need for it and a clear understanding that it wouldn't break anything. Looks like we have both of those now -- I'll leave it to Szabolcs to confirm the userspace view of this. Question: will this change prevent BTI executables from working under a non-BTI-aware ld.so? And do we care? (I think "probably not" for both, but I'd be interested in others' views.) Cheers ---Dave _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel