Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp958118pxy; Thu, 22 Apr 2021 18:35:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvLqr1PErwLBeyOOj4Qp1ps76hTapgrjtkpC6f6IHL5fK0bKpHFvajveJdWnngnWDTCvnN X-Received: by 2002:a17:90b:4a4e:: with SMTP id lb14mr2971645pjb.155.1619141744792; Thu, 22 Apr 2021 18:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619141744; cv=none; d=google.com; s=arc-20160816; b=0j/u8FJnpyC8ZuXcmIGEadas2wpUcteZw72Swyno3hKiETgR5tu1p5RJO2alT5Iop3 PpUG7y1+p2VbrHm9tBYR9GfX4i70o5Ol32FDXGcNOEOBscHH8Iz5b2QZo3jqp+1Hppfg /IJSoGyspeyeKirvJ7d2wW0Ju3pvu0MqwctWEljYhVCetpsGjM1qpXRz6XmsbmvV/Spj LG9lMENmE9juqej4GZGhdSe4AsHQPsZS92KZOHSUMansQJ3xC46Q8teaVnU7GKG/z038 XohA2BtEU8cHoqZe8Cehhxckipc5T1Md4gkHgZZQrir54BuYKQaHOEU87KZR9egeQv2K SzOA== 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:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=2u9IVBbrQtK5nxCkY5Ql7e2S1s+pJgrMEaI8rlOVi1A=; b=JNUZ77HUJXLDu+dlT/SthDBIPbfy4bizBN8+Faoq8omIIP5f6oNwiA5huc4Gd+9K8X ahccgAZalnd73XuB/MwtUUx1BZCpYx5FsIaM8nR3DQgMmSQz+E4IGdI0fWGsAOI3Pl0L 4tt6iRVDYo2IUCDtrxOmiFIz55vd1KPwC58jzOvv9+sucrPFCHQaRXv3Nyf5hJIbNKPU udACX09ErXTub+LiZtO2/wGmZfwiONtYIwO5mnjp230heEZQoci/WH9q1jnY5l5yiJxd bRLxTpsFPQbr3/v3RSH5lLMhq51ij42cSn0bWhyMyRi3ixXA5iXp3GcoyvVEuqJcFO03 YZrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=kTIabuH9; 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 bf2si5300385plb.329.2021.04.22.18.35.32; Thu, 22 Apr 2021 18:35:44 -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=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=kTIabuH9; 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 S230367AbhDWBf2 (ORCPT + 99 others); Thu, 22 Apr 2021 21:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbhDWBf1 (ORCPT ); Thu, 22 Apr 2021 21:35:27 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82DFEC06174A for ; Thu, 22 Apr 2021 18:34:51 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id u14-20020a17090a1f0eb029014e38011b09so380345pja.5 for ; Thu, 22 Apr 2021 18:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=2u9IVBbrQtK5nxCkY5Ql7e2S1s+pJgrMEaI8rlOVi1A=; b=kTIabuH9XG8EpGNkxN0ttB2TSmNE1UXivJVL/O3iBhAmQtRpUGW6mdNngm3gaVyfHk mZd9igv/ZBylu7j0rFkbzyVbfgP+ZKtnZIFUq1iqZQmxygpodGL8feHFwTGP6bxSDycC aS/dcIescNWiXHRyi86Y8JX+grwyam5ml+aVSu0fu1iKHlX2FNXST0o08A+dKXWyewrs Kh2wSpw3Z38NA32RLIlAhlUrXsT3V8u9XqihnCW3TDKfRab7JiRIMyde0fJAEMOA6t0x dHExxcIpGTZcYxxvXbTeDJKIXOlCaRLkaiKneXlRbAMT21PyRBSE/QeEK7EInSAU7Ulk lR/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=2u9IVBbrQtK5nxCkY5Ql7e2S1s+pJgrMEaI8rlOVi1A=; b=IqR+OlrBP1Mn1y/QEC3jI/KNasJqIAFXqrTJ5fx7lfWJFvTngjK9gG6oRXElHiVLxn odX66wwf3Pha65KCFsNY9uo6vu/uJ9d9HpV51Jd9fhN6YP3HW/rJjEUP1N/g9rSYV9JB kA0AkzuRhnNIRQLDtuXpf39s9swI7kfZZVRe/q+dPpT9upoH4ezHyvu32syyKgH6h39+ 0VZ8tARwShZjP2zdvCHvpe1Agd5F6pYYIZIboj4nG3r4EolCG7G+sq8N1H4C6b2ZDlzv faOvuEjplcUSu/d9pkxYDgA2OnPcCoFJfA4GJGISs41OguuRRkUwJG16zHRcEUdK6avX ZKFA== X-Gm-Message-State: AOAM530eGsFdSw5z3RGjU5Lr9QF7XwGy0fwyQPsbT5TrLg3QO/ODCYrE ZMLlg9dnWvY675w3L9O9pOPM/Q== X-Received: by 2002:a17:90b:950:: with SMTP id dw16mr3058402pjb.68.1619141690659; Thu, 22 Apr 2021 18:34:50 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id w140sm3106903pfc.176.2021.04.22.18.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 18:34:50 -0700 (PDT) Date: Thu, 22 Apr 2021 18:34:50 -0700 (PDT) X-Google-Original-Date: Thu, 22 Apr 2021 18:34:48 PDT (-0700) Subject: Re: [PATCH] riscv: Protect kernel linear mapping only if CONFIG_STRICT_KERNEL_RWX is set In-Reply-To: <72130961-0419-9b1f-e88e-aa1e933f2942@ghiti.fr> 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 From: Palmer Dabbelt To: alex@ghiti.fr Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 17 Apr 2021 10:26:36 PDT (-0700), alex@ghiti.fr wrote: > 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. I just squashed it, though, as I had to rewrite this anyway. > > 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