Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp539443pxf; Wed, 31 Mar 2021 09:32:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVvE/3CUmx9kZegYXhnvUG1ML3xU1f0ORdizyOdZyOJlx+1+iTp5mbpz8VsReMM6JsyAfZ X-Received: by 2002:aa7:d54c:: with SMTP id u12mr4961219edr.234.1617208325743; Wed, 31 Mar 2021 09:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617208325; cv=none; d=google.com; s=arc-20160816; b=zh3qbOGxKxItj7P/ZwKAiaO4MCGU8Vluu2SplOCu2f65wCvLc/eM7N7omBU4VT26aT RJByGOcLR7Yk6YBjDmtR6UDVMj320+GMT2JH8YVSG9xs/bKlllZMQJDHGMtEh3k/8ael NQssoAxiPAWIlvGwa6x7AqX9cjJoL42yhLQpNWVZ5HoXqbMvC5/5+IJJnh39GnYUL470 qNmNDoWrMUgeG0yBpmRo8XMeGX7AN2yVaMGgsVvF3r2i0e5GGzC4vmzhvPrZ+y+xOqR1 ELiPwtLgi3HK5rYLaLXrYuKXwXLeHhid7wOmIFZgzT5HsxGLKAH0eg+B7WkVC2WYHfNo CjZw== 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:subject:cc:to:from:date:dkim-signature; bh=Z3YZthlfu0euTQ+THZUZPW+nmkMWZoVGbwK6weVz8AM=; b=fVQ/frUTVTYFT9FxzE5dNQxXVN2w/TpIq/r06dS5VAzLbX3IjGO8mFtkXChcliUgeL nAr1aktota4OJl3I/EfG7L3ACJAxdIhIFBAfB+7pT1nbSYDNXqlKwuFf6WZxsfyPg9s2 Yy2cbGNDMkqs7N+OFfM5xRJgEYReWB1+gmVBzzMEdeIFQHouOPps7Y0YcioOubAPTRbq fDaDFobxV4RMpI6pRxFy+GmL2tfZFhoybpQUTFHVYMKM2KY/HWEDG5RPkS2G0fgKeUyC jHsDRviribn2kURD7TDrQm/ZfACbl0WT3fROfyZSWdvKvBrbWkHM1n40SFM+2dlAaWyB RG7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=R4LfprXF; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si2104188ejg.204.2021.03.31.09.31.42; Wed, 31 Mar 2021 09:32:05 -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=@mail.ustc.edu.cn header.s=dkim header.b=R4LfprXF; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233757AbhCaQap (ORCPT + 99 others); Wed, 31 Mar 2021 12:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbhCaQaN (ORCPT ); Wed, 31 Mar 2021 12:30:13 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 94B05C061574; Wed, 31 Mar 2021 09:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:Date:From:To:Cc:Subject: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Z3YZthlfu0euTQ+THZUZPW+nmkMWZoVGbwK6weVz8AM=; b=R4LfprXFW3i0K GptS5/OFjr6eLUHAE6s8vZbnUgb14w+ptj6+vYza2lLNR3WpJ4o94RcE0PAAQBoP 7Gh7wmQSXN7Dl1hOzM/dgihYO8DzXZ+QpToMVDDPnx046TTrnBj0EV7Q9C5KGS2v o12cva7cBbiVTKM41ifd+wi+FC0kKs= Received: from xhacker (unknown [101.86.19.180]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygDX30tzo2RgObt6AA--.16468S2; Thu, 01 Apr 2021 00:29:39 +0800 (CST) Date: Thu, 1 Apr 2021 00:24:42 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , " =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?=" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 0/9] riscv: improve self-protection Message-ID: <20210401002442.2fe56b88@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygDX30tzo2RgObt6AA--.16468S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KFyxKrykur15Xw4rZrW5Jrb_yoW8WFy7pr s0kry5ZrWF9r93C3Way34kur1rJwsYg34agr45C34rJw4aqFWUAwnYqwn0qr1DXFy0gFnY kF15u34Ykw18Z37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkCb7Iv0xC_KF4lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4j6r4UJwA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40E FcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr 0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY 04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxV W8JVWxJwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU2vPfDU UUU X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang patch1 is a trivial improvement patch to move some functions to .init section Then following patches improve self-protection by: Marking some variables __ro_after_init Constifing some variables Enabling ARCH_HAS_STRICT_MODULE_RWX Since v1: - no need to move bpf_jit_alloc_exec() and bpf_jit_free_exec() to core because RV32 uses the default module_alloc() for jit code which also meets W^X after patch8 - fix a build error caused by local debug code clean up Jisheng Zhang (9): riscv: add __init section marker to some functions riscv: Mark some global variables __ro_after_init riscv: Constify sys_call_table riscv: Constify sbi_ipi_ops riscv: kprobes: Implement alloc_insn_page() riscv: bpf: Write protect JIT code riscv: bpf: Avoid breaking W^X on RV64 riscv: module: Create module allocations without exec permissions riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU arch/riscv/Kconfig | 1 + arch/riscv/include/asm/smp.h | 4 ++-- arch/riscv/include/asm/syscall.h | 2 +- arch/riscv/kernel/module.c | 10 ++++++++-- arch/riscv/kernel/probes/kprobes.c | 8 ++++++++ arch/riscv/kernel/sbi.c | 10 +++++----- arch/riscv/kernel/smp.c | 6 +++--- arch/riscv/kernel/syscall_table.c | 2 +- arch/riscv/kernel/time.c | 2 +- arch/riscv/kernel/traps.c | 2 +- arch/riscv/kernel/vdso.c | 4 ++-- arch/riscv/mm/init.c | 12 ++++++------ arch/riscv/mm/kasan_init.c | 6 +++--- arch/riscv/mm/ptdump.c | 2 +- arch/riscv/net/bpf_jit_comp64.c | 2 +- arch/riscv/net/bpf_jit_core.c | 1 + 16 files changed, 45 insertions(+), 29 deletions(-) -- 2.31.0