Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp675851pxb; Thu, 15 Apr 2021 04:05:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvaGiZodedsL5Oms2zKgAuVJ8kpt5jncICBu6VKVaLJotzbD37/q8ir4pAz08YRhr/FHyF X-Received: by 2002:a17:90a:c7d5:: with SMTP id gf21mr3168824pjb.80.1618484726448; Thu, 15 Apr 2021 04:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618484726; cv=none; d=google.com; s=arc-20160816; b=00Ty5esQSPVWu40v78bJvy1RDJytAGOWTYBV4r70RHlZVB3z3W//91teCAGw+dgxnw 9Nn4oMy77dxXLV6etpQ37u2r3cBqSdKg4xQUMd1uW8Zl/Ik21a4zhTue/yhyYvHBFunB Shqbp66PwbWGyezYbwlFBy3ely3zqIOF5pvOqzErTmNuBhgM/ARlU/r89DjTEatI9IuF yMpmbMVFDHYvW08BZlOTTQ5X8s+gOc5nyj+uafoN4hkiehVYwYmZWWuo1Gu+dISls0YF S5Np2qzmci4iwRQxBcfTdgdgSR4I0WvIg6BFuK4eCPqf3WABYqpuQIFnP5l+IGFzHeP0 9DnA== 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 :message-id:date:subject:cc:to:from; bh=IbDa10lNiAVDnQpyZxMsU0GsYU3d2rd0C7iMTYwbPRA=; b=RM6c8zmVFFFAiaTj1bzauLV93bsE3pRqidDeRfL+UK2srjocjz25nT3K6i+/DqBaDr pkJP/7MBAhCguirRe/wgYf8U5AlGYxcFdC1MAZKvCC7E61VEu3BI49VVgIPLK+rIeyAN v72DIWAz9H6lfWfLwJj4Kux7wuDCe89nXF44DDfTTzGxw3jyA5e59N3BNFGRxlzvij84 giaUIYEjo5BNgsGwaeWi4Ob9GD2j9c5hyh8dBMJZht5e1b5CoffHqBLqiBUTGJqyUw/Y hj20nyrs1h7LMleC21a5RdAF6VryvZ5Wkk4xVh0PAGWlX2qZeYu9/NR9ryIfT+0MDunA Aa0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si3277782pfk.28.2021.04.15.04.05.13; Thu, 15 Apr 2021 04:05:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232299AbhDOLE4 (ORCPT + 99 others); Thu, 15 Apr 2021 07:04:56 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:64835 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbhDOLEz (ORCPT ); Thu, 15 Apr 2021 07:04:55 -0400 X-Originating-IP: 2.7.49.219 Received: from debian.home (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id E665324000C; Thu, 15 Apr 2021 11:04:27 +0000 (UTC) From: Alexandre Ghiti To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH] riscv: Protect kernel linear mapping only if CONFIG_STRICT_KERNEL_RWX is set Date: Thu, 15 Apr 2021 07:04:26 -0400 Message-Id: <20210415110426.2238-1-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_STRICT_KERNEL_RWX is not set, we cannot set different permissions to the kernel data and text sections, so make sure it is defined before trying to protect the kernel linear mapping. Signed-off-by: Alexandre Ghiti --- arch/riscv/kernel/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 626003bb5fca..ab394d173cd4 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -264,12 +264,12 @@ void __init setup_arch(char **cmdline_p) sbi_init(); - if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) + if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) { protect_kernel_text_data(); - -#if defined(CONFIG_64BIT) && defined(CONFIG_MMU) - protect_kernel_linear_mapping_text_rodata(); +#ifdef CONFIG_64BIT + protect_kernel_linear_mapping_text_rodata(); #endif + } #ifdef CONFIG_SWIOTLB swiotlb_init(1); -- 2.20.1