Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1228395pxb; Sat, 17 Apr 2021 10:28:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+5e5lF6BQ+r2w+Cypq2iTr8EGacqK8W5cPkyIwEF9VNO2ZzowJ1KQvtpsUrxZ4xHhYpGj X-Received: by 2002:a17:906:2509:: with SMTP id i9mr13928807ejb.117.1618680533491; Sat, 17 Apr 2021 10:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618680533; cv=none; d=google.com; s=arc-20160816; b=ROS68Ys6kx72y8HzWZfT0w/KvURWKd4n6wfOhfGP6hIAC7OIfrJ5JuVzVQnSoTSN+b ZdzBOKiE02wR+PTJ37k9n0HZwMh7hP/SHDl/o62ffw+eGUM1l4+cFaLUQ0P2zxQr4egs +1If6krlG52SQLzPSBZDc7XoltelYDGDFtNIK11BC80elVcbjcnmx3Vtmlx5SuyzhZJN myXQX66ixw4/ufGW8JG/4cyBv6YySC90CcFj69JE2PJo4o3Ji4v37iPowggv9enGxELM FutikYwFybujdvDwyvGz8vjKO+Q71K9Hjqnh5roxxJJCvFH+AlSeE2Kntxj08t4izEXZ Y7vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=On5c/ZGGJhSlObpkSo0BSTAa8iWyj8i8MJVorIMxnKA=; b=brdXgP9Z+/TspLMWAKZDUpeEmqTpn2u+mufwDiKhCrjV6aBs1F30syRFuuhFiXJLCA C1itvvXW/rbR3Sl6K94WY3K9NLnJTB1VufgTZHCAz73ZkGZSAj2j162/4Lx5g795eFcC o7dv4Wj4Trw4EDjEiTG28YHgqsNtjGgkvBscJkyhRYdPqMQmjhhXzhxiFYmoz+5HZ6A/ bg7vvYR5ni0LhQFXWVS0AUVIc26XEO15EmzRmVIbHwqY4G4ezrbJshCmQYNND+NKQUJ5 lNd5qVNvV17gzxnOv1xfUa7DQjygDTTxuiZDJreYf2kQ3xDo8UjqGaFJqNBGkXefHj7t yd2A== 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 d14si8095957edj.529.2021.04.17.10.28.30; Sat, 17 Apr 2021 10:28:53 -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 S236827AbhDQR1I (ORCPT + 99 others); Sat, 17 Apr 2021 13:27:08 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:55863 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236820AbhDQR1H (ORCPT ); Sat, 17 Apr 2021 13:27:07 -0400 X-Originating-IP: 2.7.49.219 Received: from [192.168.1.12] (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 39881E0003; Sat, 17 Apr 2021 17:26:37 +0000 (UTC) Subject: Re: [PATCH] riscv: Protect kernel linear mapping only if CONFIG_STRICT_KERNEL_RWX is set To: Palmer Dabbelt Cc: anup@brainfault.org, corbet@lwn.net, Paul Walmsley , aou@eecs.berkeley.edu, Arnd Bergmann , aryabinin@virtuozzo.com, glider@google.com, dvyukov@google.com, 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 References: From: Alex Ghiti Message-ID: <72130961-0419-9b1f-e88e-aa1e933f2942@ghiti.fr> Date: Sat, 17 Apr 2021 13:26:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 4/16/21 à 12:33 PM, Palmer Dabbelt a écrit : > On Fri, 16 Apr 2021 03:47:19 PDT (-0700), alex@ghiti.fr wrote: >> Hi Anup, >> >> Le 4/16/21 à 6:41 AM, Anup Patel a écrit : >>> 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 ? >> >> Yes you're right I should have done that. Maybe Palmer will squash it as >> it just entered for-next? > > Ya, I'll do it.  My testing box was just tied up last night for the rc8 > PR, so I threw this on for-next to get the buildbots to take a look. > It's a bit too late to take something for this week, as I try to be > pretty conservative this late in the cycle.  There's another kprobes fix > on the list so if we end up with an rc8 I might send this along with > that, otherwise this'll just go onto for-next before the linear map > changes that exercise the bug. > > You're more than welcome to just dig up the fixes tag and reply, my > scripts pull all tags from replies (just like Revieweb-by).  Otherwise > I'll do it myself, most people don't really post Fixes tags that > accurately so I go through it for pretty much everything anyway. Here it is: Fixes: 4b67f48da707 ("riscv: Move kernel mapping outside of linear mapping") Thanks, > > Thanks for sorting this out so quickly! > >> >>> >>> Otherwise it looks good. >>> >>> Reviewed-by: Anup Patel >> >> Thank you! >> >> Alex >> >>> >>> 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 >>>> >>> >>> _______________________________________________ >>> linux-riscv mailing list >>> linux-riscv@lists.infradead.org >>> http://lists.infradead.org/mailman/listinfo/linux-riscv >>> > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv