Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp216385pxb; Fri, 16 Apr 2021 03:59:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdJMSybMzDsEfW98ZTeuG7iIzNCB5zhdFfulQJ4ed9hfbxoMeVVesoofw0fbrC1PSBgMrd X-Received: by 2002:a17:902:6946:b029:e9:4dcc:9966 with SMTP id k6-20020a1709026946b02900e94dcc9966mr9038842plt.6.1618570796000; Fri, 16 Apr 2021 03:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618570795; cv=none; d=google.com; s=arc-20160816; b=A0cbdG+icbkSC6Dw+xBgGSsDlyw7zpsPlNaQBZbUF6PyhU9UDB0ZhsnGqBuwMdd+cF j32WdzvGRW5KC2yy0Grmf9+EU4snatCHKypeaaNh5Sr4W7ixvyyId3EAoWMBFaJcKjGJ /HyBRdBZn15/dZdlYz5d1JMSfnZ+ug9WiH9MRm22ggsww8re1Q9CO+rH7etXVKhwYggM lwj3z3I8YsxqjzPjJlXPjzZhdHsWB2yhaubL3O0izcbI5nywU91yJa74wuCaJrSCOjyj p1PgBWsvhK4onnXhzF6USlfDExAKTLNdA9mR1j83LGvMntHDhUertQ6aLsKQR0qR4KpK zCAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zex7i7Gm7ilDvh/qRtb14tTVDUsTiPnIyJ8lJBlTVDY=; b=e/cfpfqSVwIFSMn25Ca3IWEhEiwUYm74Wkhh9BgVtZgCOjDxzr0YegDNHSF57aM39C pM4pIayr/IgFt/n3/JlLICU7OAjMCnzIgTUX6UcX0fGlcLVrz5D/ClLY6ORFxXJIPOpB zL+jxj5i3WeJdgGYYY3ADBK72fj7Ri9UEsF+KADt7r2eiYfXa/WHaOumwoBd8wexU8Fj SVAiVSeNV1hFBwM+wwc24wFhP8mItx56KjL7MaHmW/9bckSLAQKFWgCybCzBCFrCDG98 x8Egtt2Q6LEUkYW7bVCh1MMVhVhPM6fq3Bw8rH7KmBGa43kMpfiMTGY/2wOdGYItjL15 p+Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=o+NE8pGA; 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 j13si6190934pgq.300.2021.04.16.03.59.43; Fri, 16 Apr 2021 03:59:55 -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; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=o+NE8pGA; 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 S241747AbhDPKm2 (ORCPT + 99 others); Fri, 16 Apr 2021 06:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241749AbhDPKm1 (ORCPT ); Fri, 16 Apr 2021 06:42:27 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10AA3C061574 for ; Fri, 16 Apr 2021 03:42:03 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id w186so9515552wmg.3 for ; Fri, 16 Apr 2021 03:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zex7i7Gm7ilDvh/qRtb14tTVDUsTiPnIyJ8lJBlTVDY=; b=o+NE8pGADgY4FrSGIXWUfJDlnJ1juLdQCdEiocUx/f4kBswMU6EacEfCbch4zfDr8H +8aCGjJXpl6SK20MOt1VpdXaX4BbkHmki5A2hh1gmZ20w2EMJP1VjnEsC8VADb9byTqY lE+sl5rG/g22g2pLcBDdBqPUtuuihLLbi7A6mVCOjdUC+LZqLYwD2VrW6Q33ZmABcitG osCWWS16aeTjD/SapJryOxU2/k5hi64Zs2KKTkPikhugxITJ9wbjvvaZwkFN1zhfoIGY lMbuOFwM6i8S1cr0T1JDeA7IJyAS5SdymT8sxxaVslfrawq50NfS7neQz6FJIXPKg4kh wuBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zex7i7Gm7ilDvh/qRtb14tTVDUsTiPnIyJ8lJBlTVDY=; b=jwsc84bR8ypJJ9OItgfq02Vwyd94tr8DPZxzpVuMF82GtpnFdxzhluI0WIwK3ZOtgT rpT/KSbtwuKs2B3yJs/HoSmaRQNoLZcBIH2DFgEYB3Qlr+CuTxPy2oQ8/dFjxgWO4RXq e5mWc+umXC6xEjfY6N0r8CLH4dYbq8dNohdrvfG+5fjbEos9H4DC/33pOfo+az1QGlCM CVatzFxM53bc59abbH7WBKA0Mq5y1yEifyrNLCRMAk68osIoka4UFecguKPsEayxrlql zmIJapMku60Tdt7vYIVC5JK4zTRw/VfYqk/RDCPLCdUETAsPQXOT3CThpKa4Y0d82gnJ 4b8w== X-Gm-Message-State: AOAM532d6XinD/P3fGYrzB1eRu1FSgPs5fPJ+sHs4XGJdQLuMe3EhfxQ pN77dxQGU6LQrAktEEAEbhJs5q+ywjEkbvaq/fpr7A== X-Received: by 2002:a7b:c348:: with SMTP id l8mr7746989wmj.152.1618569721686; Fri, 16 Apr 2021 03:42:01 -0700 (PDT) MIME-Version: 1.0 References: <20210415110426.2238-1-alex@ghiti.fr> In-Reply-To: <20210415110426.2238-1-alex@ghiti.fr> From: Anup Patel Date: Fri, 16 Apr 2021 16:11:50 +0530 Message-ID: Subject: Re: [PATCH] riscv: Protect kernel linear mapping only if CONFIG_STRICT_KERNEL_RWX is set To: Alexandre Ghiti Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , linux-doc@vger.kernel.org, linux-riscv , "linux-kernel@vger.kernel.org List" , kasan-dev@googlegroups.com, linux-arch , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 15, 2021 at 4:34 PM Alexandre Ghiti wrote: > > 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 Maybe you should add "Fixes:" tag in commit tag ? Otherwise it looks good. Reviewed-by: Anup Patel Regards, Anup > --- > 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 >