From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B275C43461 for ; Fri, 23 Apr 2021 01:34:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFC17613DB for ; Fri, 23 Apr 2021 01:34:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFC17613DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E0AFE6B0075; Thu, 22 Apr 2021 21:34:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6DC06B00A8; Thu, 22 Apr 2021 21:34:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B98BF6B00AA; Thu, 22 Apr 2021 21:34:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0125.hostedemail.com [216.40.44.125]) by kanga.kvack.org (Postfix) with ESMTP id 9557F6B0075 for ; Thu, 22 Apr 2021 21:34:52 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 56BE43621 for ; Fri, 23 Apr 2021 01:34:52 +0000 (UTC) X-FDA: 78061912824.38.E7C10C3 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf23.hostedemail.com (Postfix) with ESMTP id DEE40A000390 for ; Fri, 23 Apr 2021 01:34:49 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id lt13so13429575pjb.1 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=BL3LAjFr8FrA8lrBi85jRyVKrW+EqcBi9S6e4pJTxkqtW/ewT3UZBNV0Bf3S6vyeXj ZNeN9d9VRbyUU89X6oXfk+/n21AXHCkL3ACAYoZJnHT8/Zer/w+KFErm3+0ZmITWa49C 84ZaDjk5iHT1BvQDguRe7dCDUUnAPaRQniS4031OkID+c9A3V3Z3LOtGSaggv/jvOY5b ipmmRMrc6FNcRs2jALrnO1cM3/SYonzjKwCgkA6LXhPCstNdloQ9GHzdIRf0Q6adnbtw 0moGE2vk3ib29t/0YD0TiSyE9d0ZVkMWotT8jfcZMtrola0wnfHeYxHw8H4px2TPDZ2R 03Rg== X-Gm-Message-State: AOAM532PflaSNL4V/ZovQic1sULOvcB6wvUFaV7bqQsbS0VsRrqtjlb7 b04HRjSB98/ZtCjYVaippTP+OQ== X-Google-Smtp-Source: ABdhPJyPGTWn9ZwTGF0D0ZB3bx8F9D7skQtSMEe+BuiaPPW01VWIa1OOFmwPEC3wIJMBb5FDn5+xdg== 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 X-Rspamd-Queue-Id: DEE40A000390 X-Stat-Signature: 337369xypbaq7pnb31rwpaactajyq7pn X-Rspamd-Server: rspam02 Received-SPF: none (dabbelt.com>: No applicable sender policy available) receiver=imf23; identity=mailfrom; envelope-from=""; helo=mail-pj1-f43.google.com; client-ip=209.85.216.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619141689-796058 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, 17 Apr 2021 10:26:36 PDT (-0700), alex@ghiti.fr wrote: > Le 4/16/21 =C3=A0 12:33 PM, Palmer Dabbelt a =C3=A9crit=C2=A0: >> On Fri, 16 Apr 2021 03:47:19 PDT (-0700), alex@ghiti.fr wrote: >>> Hi Anup, >>> >>> Le 4/16/21 =C3=A0 6:41 AM, Anup Patel a =C3=A9crit=C2=A0: >>>> On Thu, Apr 15, 2021 at 4:34 PM Alexandre Ghiti wrot= e: >>>>> >>>>> 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 be= fore >>>>> 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.=C2=A0 My testing box was just tied up last night for t= he 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.=C2=A0 There's another kpro= bes 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).=C2=A0 Othe= rwise >> 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 mapp= ing") 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 >>>> >>>>> --- >>>>> =C2=A0 arch/riscv/kernel/setup.c | 8 ++++---- >>>>> =C2=A0 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) >>>>> >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sbi_init(); >>>>> >>>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ENABLED(CONFIG_STRICT_= KERNEL_RWX)) >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ENABLED(CONFIG_STRICT_= KERNEL_RWX)) { >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 protect_kernel_text_data(); >>>>> - >>>>> -#if defined(CONFIG_64BIT) && defined(CONFIG_MMU) >>>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 protect_kernel_linear_mapping= _text_rodata(); >>>>> +#ifdef CONFIG_64BIT >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 protect_kernel_linear_mapping_text_rodata(); >>>>> =C2=A0 #endif >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>>>> >>>>> =C2=A0 #ifdef CONFIG_SWIOTLB >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 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