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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 65FA3C43331 for ; Wed, 1 Apr 2020 07:19:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C058206F5 for ; Wed, 1 Apr 2020 07:19:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="a0agqxK2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731989AbgDAHTD (ORCPT ); Wed, 1 Apr 2020 03:19:03 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:43871 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731680AbgDAHTD (ORCPT ); Wed, 1 Apr 2020 03:19:03 -0400 Received: by mail-ot1-f67.google.com with SMTP id a6so24882855otb.10 for ; Wed, 01 Apr 2020 00:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xWNb23bvG43tvtDYflVRLL7xRdiOM0I/bVuwrcZ+sjE=; b=a0agqxK22RUr8z9MxKv9tv14LtU8MonFWWz7niFaVWHguVjdgtQfydx9atK7qk3dbs 2gDzIP9xM2xaF3U27R655p7/PV9fULM/chP8iVji/p32gvrB4KyjdvJEejjzSju4N78l nDamZuEOyC9aECrt2a85JdHMNiU6kw09IJ+N8XN6oG7VMvWLXto6jcd7VATWHEu6mO6S wu+hTVFqus+Vx7Av9A0q2OX+RdlTrChEB/uwL5ApRRuZ6Kx7oDh3t4GX5mzti1Jjj9ko uUDGz3o4AcGjIhnOQSiKHJ4ENCXkS9SefXTAMezuCmwGIJ83KxWL41Taim/Jw3Mprk15 kgWg== 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=xWNb23bvG43tvtDYflVRLL7xRdiOM0I/bVuwrcZ+sjE=; b=ukZATAgDyoWPoWbKQ0IQT7XOhUNck9mxIYPLbwFHpBGMJauckv1JGzsh6NCLunifst pegsUbyir2paxmJABRzO3aw5oTXfxr3vcgoKZJU4kjqQGb/PvZsdd5xghWi21h0g7B/o z+vV6odSQsIRSY2rRZdVlg6wJOv2s7Uiyjjh4ICMYjkrKHGt/T65bCFcLSjtE81B5jee Igm1e6Hr82rZbEV6e5qa9iNZ6wLDLrObumrsfO3YVmvA1X5Up/NbNMxHHvCr+wF9NY7P GkwDLi9a0szWBDq6tNnAflpBXD9QBeK8dQr6u83iv1y2FvE6vm8NHQo360oPqmn9PCkm /5Dg== X-Gm-Message-State: ANhLgQ0yAzKNgCyHrAl9/o4L5JZmn4b1cMJRJiyAMrv9TUcuZaLOr0sf UnmxI8NVj1cPU43wBmfNApdn4RXyVB12htQSuiDbag== X-Google-Smtp-Source: ADFU+vtzKsxY68182TQ7PSwuGG29gx2NjzcuiOIGWaybfm5PYHXJTIV0ibgQlUPctKZxdt1NZIfA9bk1Pdza1/Pl31s= X-Received: by 2002:a9d:2002:: with SMTP id n2mr4368298ota.127.1585725542448; Wed, 01 Apr 2020 00:19:02 -0700 (PDT) MIME-Version: 1.0 References: <20200331223254.919b92750962fefed5a6646f@kernel.org> In-Reply-To: <20200331223254.919b92750962fefed5a6646f@kernel.org> From: Zong Li Date: Wed, 1 Apr 2020 15:18:52 +0800 Message-ID: Subject: Re: [PATCH v3 0/9] Support strict kernel memory permissions for security To: Masami Hiramatsu Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 31, 2020 at 9:32 PM Masami Hiramatsu wrote: > > Hi Zong, > > On Tue, 10 Mar 2020 00:55:35 +0800 > Zong Li wrote: > > > The main purpose of this patch series is changing the kernel mapping permission > > , make sure that code is not writeable, data is not executable, and read-only > > data is neither writable nor executable. > > > > This patch series also supports the relevant implementations such as > > ARCH_HAS_SET_MEMORY, ARCH_HAS_SET_DIRECT_MAP, > > ARCH_SUPPORTS_DEBUG_PAGEALLOC and DEBUG_WX. > > The order of the patches seems a bit strange. Since the first 7 patches > makes kernel read-only, at that point ftrace is broken and it is fixed > by the last 2 patches. That is not bisect-friendly. Can you move the > last 2 patches to the top? > OK. Let me rearrange the order. Thanks. > Thank you, > > > > > Changes in v3: > > - Fix build error on nommu configuration. We already support nommu on > > RISC-V, so we should consider nommu case and test not only rv32/64, > > but also nommu. > > > > Changes in v2: > > - Use _data to specify the start of data section with write permission. > > - Change ftrace patch text implementaion. > > - Separate DEBUG_WX patch to another patchset. > > > > Zong Li (9): > > riscv: add ARCH_HAS_SET_MEMORY support > > riscv: add ARCH_HAS_SET_DIRECT_MAP support > > riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support > > riscv: move exception table immediately after RO_DATA > > riscv: add alignment for text, rodata and data sections > > riscv: add STRICT_KERNEL_RWX support > > riscv: add macro to get instruction length > > riscv: introduce interfaces to patch kernel code > > riscv: patch code by fixmap mapping > > > > arch/riscv/Kconfig | 6 + > > arch/riscv/include/asm/bug.h | 8 ++ > > arch/riscv/include/asm/fixmap.h | 2 + > > arch/riscv/include/asm/patch.h | 12 ++ > > arch/riscv/include/asm/set_memory.h | 48 +++++++ > > arch/riscv/kernel/Makefile | 4 +- > > arch/riscv/kernel/ftrace.c | 13 +- > > arch/riscv/kernel/patch.c | 120 ++++++++++++++++++ > > arch/riscv/kernel/traps.c | 3 +- > > arch/riscv/kernel/vmlinux.lds.S | 11 +- > > arch/riscv/mm/Makefile | 2 +- > > arch/riscv/mm/init.c | 44 +++++++ > > arch/riscv/mm/pageattr.c | 187 ++++++++++++++++++++++++++++ > > 13 files changed, 445 insertions(+), 15 deletions(-) > > create mode 100644 arch/riscv/include/asm/patch.h > > create mode 100644 arch/riscv/include/asm/set_memory.h > > create mode 100644 arch/riscv/kernel/patch.c > > create mode 100644 arch/riscv/mm/pageattr.c > > > > -- > > 2.25.1 > > > > > -- > Masami Hiramatsu 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=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 A6F1FC2D0E7 for ; Wed, 1 Apr 2020 07:19:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77471206F5 for ; Wed, 1 Apr 2020 07:19:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iVWw6k7c"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="a0agqxK2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77471206F5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To: Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xWNb23bvG43tvtDYflVRLL7xRdiOM0I/bVuwrcZ+sjE=; b=iVWw6k7cpXNYRHmJI1SvCoaNH /ljGHLvW/Zf1rn4dpjD0u6uJ1ydx0SzY2ylkVOL9rl3amvQNhIuXCUyXjw8pNgYq3joL2HZZjeL5F CjJXRCA7TMPTZc5ZbnkaXK6fbNthA7y9OdK8xzhSuXtRgsr9HTKHBhwPZjOEGuIjlzkRxVU7Th2nS FohN7gsgX95AEEuKrzTL7Jy3y8auABrhzTI4qX4SxyFIP4sTWIH8AEvQXDZgLFPECL65/ct2ihXcy JziWkLf6Ed/KDSzZKmEazK+dassRG53xqtzssrcQX2yY59l7bJM7PBio6lzXAXvrQKj9U4t6oAJ0L lief1TCUg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJXeX-0002Yc-B1; Wed, 01 Apr 2020 07:19:09 +0000 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJXeT-0002Xe-4e for linux-riscv@lists.infradead.org; Wed, 01 Apr 2020 07:19:07 +0000 Received: by mail-ot1-x342.google.com with SMTP id t28so24921758ott.5 for ; Wed, 01 Apr 2020 00:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xWNb23bvG43tvtDYflVRLL7xRdiOM0I/bVuwrcZ+sjE=; b=a0agqxK22RUr8z9MxKv9tv14LtU8MonFWWz7niFaVWHguVjdgtQfydx9atK7qk3dbs 2gDzIP9xM2xaF3U27R655p7/PV9fULM/chP8iVji/p32gvrB4KyjdvJEejjzSju4N78l nDamZuEOyC9aECrt2a85JdHMNiU6kw09IJ+N8XN6oG7VMvWLXto6jcd7VATWHEu6mO6S wu+hTVFqus+Vx7Av9A0q2OX+RdlTrChEB/uwL5ApRRuZ6Kx7oDh3t4GX5mzti1Jjj9ko uUDGz3o4AcGjIhnOQSiKHJ4ENCXkS9SefXTAMezuCmwGIJ83KxWL41Taim/Jw3Mprk15 kgWg== 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=xWNb23bvG43tvtDYflVRLL7xRdiOM0I/bVuwrcZ+sjE=; b=H/G8bIEnakcn7HdxV6FxFVtUDnnFHXHmwN3SkuUzhJIikVEb9gZYfPhTz3+uDrUJ32 X3v5asfxSnlbYbqp2NJDhRj2gc8QHKR9durQUf08FMo0y3CCsRjQonu/ckK9he4Xz7J5 SUDlQp49s/nVcGBpynw77bK6mu8UcMUl28GkX5Hnk533lvG7CJhFbZ971cMWGGpeMhyP yuX8+vU5uCMxfKAU46umm2H18ECRuc03l7yY4iUMx8Tq4cCJ9rJxlHT1mYoL3xqBd3fM /0gCvAtbkTPDNXuKywwCFcoJRCh7uJ2aU3egtJnPwae5qZDAKggTZvgATc2jJqLrM4yd uLkQ== X-Gm-Message-State: ANhLgQ0cFUbzKj/WSSkZ7XWStrtGvHJ49+C87evrzYvROJT2tR8w35fS Vq0DNtfUHBl9yBkHuUZfi6AfCiL4ODCKBu0WL0SVjw== X-Google-Smtp-Source: ADFU+vtzKsxY68182TQ7PSwuGG29gx2NjzcuiOIGWaybfm5PYHXJTIV0ibgQlUPctKZxdt1NZIfA9bk1Pdza1/Pl31s= X-Received: by 2002:a9d:2002:: with SMTP id n2mr4368298ota.127.1585725542448; Wed, 01 Apr 2020 00:19:02 -0700 (PDT) MIME-Version: 1.0 References: <20200331223254.919b92750962fefed5a6646f@kernel.org> In-Reply-To: <20200331223254.919b92750962fefed5a6646f@kernel.org> From: Zong Li Date: Wed, 1 Apr 2020 15:18:52 +0800 Message-ID: Subject: Re: [PATCH v3 0/9] Support strict kernel memory permissions for security To: Masami Hiramatsu Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200401_001905_345096_BD6CBAFA X-CRM114-Status: GOOD ( 20.57 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-riscv , Albert Ou , Palmer Dabbelt , "linux-kernel@vger.kernel.org List" , Paul Walmsley Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, Mar 31, 2020 at 9:32 PM Masami Hiramatsu wrote: > > Hi Zong, > > On Tue, 10 Mar 2020 00:55:35 +0800 > Zong Li wrote: > > > The main purpose of this patch series is changing the kernel mapping permission > > , make sure that code is not writeable, data is not executable, and read-only > > data is neither writable nor executable. > > > > This patch series also supports the relevant implementations such as > > ARCH_HAS_SET_MEMORY, ARCH_HAS_SET_DIRECT_MAP, > > ARCH_SUPPORTS_DEBUG_PAGEALLOC and DEBUG_WX. > > The order of the patches seems a bit strange. Since the first 7 patches > makes kernel read-only, at that point ftrace is broken and it is fixed > by the last 2 patches. That is not bisect-friendly. Can you move the > last 2 patches to the top? > OK. Let me rearrange the order. Thanks. > Thank you, > > > > > Changes in v3: > > - Fix build error on nommu configuration. We already support nommu on > > RISC-V, so we should consider nommu case and test not only rv32/64, > > but also nommu. > > > > Changes in v2: > > - Use _data to specify the start of data section with write permission. > > - Change ftrace patch text implementaion. > > - Separate DEBUG_WX patch to another patchset. > > > > Zong Li (9): > > riscv: add ARCH_HAS_SET_MEMORY support > > riscv: add ARCH_HAS_SET_DIRECT_MAP support > > riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support > > riscv: move exception table immediately after RO_DATA > > riscv: add alignment for text, rodata and data sections > > riscv: add STRICT_KERNEL_RWX support > > riscv: add macro to get instruction length > > riscv: introduce interfaces to patch kernel code > > riscv: patch code by fixmap mapping > > > > arch/riscv/Kconfig | 6 + > > arch/riscv/include/asm/bug.h | 8 ++ > > arch/riscv/include/asm/fixmap.h | 2 + > > arch/riscv/include/asm/patch.h | 12 ++ > > arch/riscv/include/asm/set_memory.h | 48 +++++++ > > arch/riscv/kernel/Makefile | 4 +- > > arch/riscv/kernel/ftrace.c | 13 +- > > arch/riscv/kernel/patch.c | 120 ++++++++++++++++++ > > arch/riscv/kernel/traps.c | 3 +- > > arch/riscv/kernel/vmlinux.lds.S | 11 +- > > arch/riscv/mm/Makefile | 2 +- > > arch/riscv/mm/init.c | 44 +++++++ > > arch/riscv/mm/pageattr.c | 187 ++++++++++++++++++++++++++++ > > 13 files changed, 445 insertions(+), 15 deletions(-) > > create mode 100644 arch/riscv/include/asm/patch.h > > create mode 100644 arch/riscv/include/asm/set_memory.h > > create mode 100644 arch/riscv/kernel/patch.c > > create mode 100644 arch/riscv/mm/pageattr.c > > > > -- > > 2.25.1 > > > > > -- > Masami Hiramatsu