Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6267643rwb; Tue, 9 Aug 2022 12:05:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR7nnEYxPGSXjSjsdrxasMQu3ZypPkp+usGjMZDTJJA42HjvQgxPt/NXBvHkIatg3vMZNYlO X-Received: by 2002:a17:90b:4ccb:b0:1f5:87:a17f with SMTP id nd11-20020a17090b4ccb00b001f50087a17fmr27265453pjb.7.1660071912765; Tue, 09 Aug 2022 12:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071912; cv=none; d=google.com; s=arc-20160816; b=K0aLhLhWUeEFhEhW0X3wKggYqY+m+/1RHXVbr1Ke6y0S/dMKlJwm+QB3380D6X4B2W i47Pp3pl/AGkUVqjhUDR1eevfzQaTOt410d/EfkR3LQgrI47zupwbApnrUikxP2aC/s0 w+jzqTJwrPZeXXPu0Pf3qvffpSpvofyz7X6C0D8um9Eu4PLUpCKgrGWKPXLlxeGpe7Qm ptAn5rAFzK9PrCAJgGzjtrtXTcjFknF1Mxl6PaI+eYahphaRHcXauQ/GJPQ8dYo+kapy lYbhLaBTi3/hYIAxjT3Zf/8ucHmQqwjpOftMpcXAbaGbEQaNe6FE6Kg3SnthwefkjoTR qtHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fdERn/Gg8xfbnG3C12MjHGuccDOCoprDTgm4SV5klG4=; b=rmVLu+6aYn99HeepqE7xUrN0SPLB7PjZr8zyleanrw88jpsl+aIbMoy2OzIFBPr2xH eNWtFQq+d8HFnuqtg/CBUVtBcosmIm/VHq6V5GMSbOdirXf+jOnxXcO2zoJw8X49hFpr rGFku9LY0ZsVqLfMc4baLWaGvRDEQH48DJqBXcx8Zdor31g3nkTPpyBMK2bCRIXIXVxX y1AG73rStma8QqicRhSdWLxJ54iqbm65/ZbfPaZl/v3DMqDuEUjSeke5RQPLkKakItOv wlu93BGZZ9U+JIEYeFX3b+06xarQnapnzSnS2EDaV83/or1lPrGyVC2+AQ4Y+wDkRAyJ 0+7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ef88kDjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020a170902f28b00b0016dc8948967si11780003plc.184.2022.08.09.12.04.58; Tue, 09 Aug 2022 12:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ef88kDjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344225AbiHISd3 (ORCPT + 99 others); Tue, 9 Aug 2022 14:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245061AbiHIS3l (ORCPT ); Tue, 9 Aug 2022 14:29:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC33324BCB; Tue, 9 Aug 2022 11:10:20 -0700 (PDT) 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 09B51B818C4; Tue, 9 Aug 2022 18:08:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 538FCC433B5; Tue, 9 Aug 2022 18:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068495; bh=Du+LfgidnyUZQYmLnNKvCIdplUELRrxtwIDyhwydf1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ef88kDjgJrH2a+05EzCgCLs+xspHqOc+tLPWPShTpSw2RTRGUtVbm/ND1a9Cbmx+X EJRMeEi4zEmjj1nV+g+wl06rEkKIeFtF3dOT6oAmccZOSJa1/sZkGuXdErFXJ7DWnp uuNyJiqOrIwCYnBFoy9e8l3uvMAX/dwad+/wCdYU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Collingbourne , Will Deacon , Ard Biesheuvel , Catalin Marinas Subject: [PATCH 5.19 08/21] arm64: set UXN on swapper page tables Date: Tue, 9 Aug 2022 20:01:00 +0200 Message-Id: <20220809175513.603831926@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175513.345597655@linuxfoundation.org> References: <20220809175513.345597655@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Collingbourne [ This issue was fixed upstream by accident in c3cee924bd85 ("arm64: head: cover entire kernel image in initial ID map") as part of a large refactoring of the arm64 boot flow. This simple fix is therefore preferred for -stable backporting ] On a system that implements FEAT_EPAN, read/write access to the idmap is denied because UXN is not set on the swapper PTEs. As a result, idmap_kpti_install_ng_mappings panics the kernel when accessing __idmap_kpti_flag. Fix it by setting UXN on these PTEs. Fixes: 18107f8a2df6 ("arm64: Support execute-only permissions with Enhanced PAN") Cc: # 5.15 Link: https://linux-review.googlesource.com/id/Ic452fa4b4f74753e54f71e61027e7222a0fae1b1 Signed-off-by: Peter Collingbourne Acked-by: Will Deacon Cc: Ard Biesheuvel Cc: Catalin Marinas Link: https://lore.kernel.org/r/20220719234909.1398992-1-pcc@google.com Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/kernel-pgtable.h | 4 ++-- arch/arm64/kernel/head.S | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/arch/arm64/include/asm/kernel-pgtable.h +++ b/arch/arm64/include/asm/kernel-pgtable.h @@ -103,8 +103,8 @@ /* * Initial memory map attributes. */ -#define SWAPPER_PTE_FLAGS (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) -#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) +#define SWAPPER_PTE_FLAGS (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED | PTE_UXN) +#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S | PMD_SECT_UXN) #if ARM64_KERNEL_USES_PMD_MAPS #define SWAPPER_MM_MMUFLAGS (PMD_ATTRINDX(MT_NORMAL) | SWAPPER_PMD_FLAGS) --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -285,7 +285,7 @@ SYM_FUNC_START_LOCAL(__create_page_table subs x1, x1, #64 b.ne 1b - mov x7, SWAPPER_MM_MMUFLAGS + mov_q x7, SWAPPER_MM_MMUFLAGS /* * Create the identity mapping.