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 5EE31C433EF for ; Thu, 23 Jun 2022 17:28:39 +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=lEfKEnIaM+RRxYX+uh6u2zNr9l1f6SXwM08e1xOUdKw=; b=qAkXfWJ3DgR3xP N9i4KLRxblUqEdRnhzkTw5zA6XzU+VGH2KEOEPHkpm+mBATrWBMmIqp67ZLSnNM1UfZZAJhiFB+Pf CfKWTN3MjYvX54pLQSm+FEpBWTHpiKcZeuw0KoOYVUJhmUes6BxgFtzp7/j62W1qQXs1W6DTLFW1c BJ8K3b9w9l6faICL7k4GowWw5jMJZsgCtoxBsCOI6svwfq7xc8JEnZzHLbnZJwN6aVijfpd3OZvC7 ms6Uhepgpqu3B5C+gHqbzka1qhJQJ4za4HK5tvIuBgIgojQl0m6XIN3T9c7SGLjqNMH7QtBR7jRn4 p3RAx0hAHoCZvtWT477Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4QcI-00G6no-FB; Thu, 23 Jun 2022 17:27:42 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4QcF-00G6nM-1l for linux-arm-kernel@lists.infradead.org; Thu, 23 Jun 2022 17:27:40 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6AB65B824C1; Thu, 23 Jun 2022 17:27:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DE5AC3411B; Thu, 23 Jun 2022 17:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656005256; bh=cjA2+/VfwtnJLx2FsxboduQ0YIyLP7BYCHUqenv0DAM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cdzYhdL6gkVCqD2yTCLB5gNKvSf7GtCZ/uQjF5mj1ZrsfjX7fOMgLidoj2c9Nymer bbQZWVclh7RawXhdisVV2rAs+Jk45BRtIfDi7hacQnk8c9mvXHhJRKv4x/ZCgR6VV+ oXA1oyCBchGS5UBYeexD6pD00cY0XxPFhwbBusj0VggOhiH66WD2or0sYbKrgvQwSp CPKHdODSIGrY6vfLyOpQhyhKYjEQ8iw/K7Dmc7GnuEtmSGIenxAPy0PJCQ+CkAB2pI ayVd7Ew+8D/PN1FDeHGN2zrPoUk/5XVBwGnO3OPqd1uXGftuqZlfwSUpOQZ50EEJWz 6rMkUX0po+zig== Date: Thu, 23 Jun 2022 18:27:31 +0100 From: Will Deacon To: Liu Song Cc: catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: cpufeature: make sure cpu_mitigations_off then kpti off Message-ID: <20220623172730.GA16966@willie-the-truck> References: <1655382938-126283-1-git-send-email-liusong@linux.alibaba.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1655382938-126283-1-git-send-email-liusong@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220623_102739_267609_F375AD72 X-CRM114-Status: GOOD ( 20.26 ) 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 Thu, Jun 16, 2022 at 08:35:38PM +0800, Liu Song wrote: > From: Liu Song > > If kaslr is enabled, kpti cannot be turned off even if "mitigations=off", > adjust the code order to ensure that kpti is off when "mitigations=off". > > Signed-off-by: Liu Song > --- > arch/arm64/kernel/cpufeature.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 42ea2bd..27d4850 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -1616,6 +1616,11 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, > __kpti_forced = -1; > } > > + if (cpu_mitigations_off() && !__kpti_forced) { > + str = "mitigations=off"; > + __kpti_forced = -1; > + } > + > /* Useful for KASLR robustness */ > if (kaslr_requires_kpti()) { > if (!__kpti_forced) { > @@ -1624,11 +1629,6 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, > } > } > > - if (cpu_mitigations_off() && !__kpti_forced) { > - str = "mitigations=off"; > - __kpti_forced = -1; > - } The current behaviour is intentional: KASLR is trivial to bypass when kpti is disabled. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel