Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1903777pxb; Mon, 12 Apr 2021 09:17:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBzUHaVBnJ0POSCxCGqe3TeMIq4dtlWsmotNXaevF/mKbI36a3tSDWg0YKDz1X7Tqip4oG X-Received: by 2002:a17:906:4b59:: with SMTP id j25mr1698415ejv.313.1618244279247; Mon, 12 Apr 2021 09:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618244279; cv=none; d=google.com; s=arc-20160816; b=VWpaL0VNBg7zPHz+MnNGKfNs1tIGfjU8dUJYtsvFKwktC5nYZi+Y/8yQVTjD3f2QFy ebrqqOgf6zVCt/jqy0MW5QnvYVd6SsdnyHRn4N7Vus6Xz91S0AVP9CQzDwsm+iSxZ5il O4j1ykmyFutcdZiw+w1wFp4ULoYbTBKISFQhD2CVhCwEA75gL2sUH4Z8tr3jZGWnkPsE JbetJR5VI6Cx/PV4XARTWSEXdMCf1yiwxQVul/mfSW+KBHCUmGRSigILgDpX4cQ8191G v33Re1Fo17WXzpbXVmYhio37vr812PGM7NfPH98D7jxRnNAzPiGZW81qTvp8v9prEISh Y7AA== 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=YpOlDgDwAR8y20H8Gm8o0X6WO1zAuOxCsykTgd3UXC8=; b=aARMRAtmFZCqCx+62GNqKeKtLVD5mgX5ce6AdyP827swo9oe5RhftugTM0ducER4dW uMpYEBA98cxdiou31uP2caMm/eNiks/J7uwxdnz67Oeh5uZUdIZH/cLvk/+p5aHjxxpM puWEjmbvUXlo6dTsL4dv+yOWRxcymE+E7EYWMEdrWBGvqiBVx5lWFvmmGwUuOv8zCANC KkshsP5FOfC1aQpq7Ks59EKk9bahOQRgWpgUxGa6LZMIbuz0YDs5h4BQezr3strtD+Zf v87D7HXo+NnNZI2GTJwBK2XQX8uZRucAuEDRi/wY+peAVtCRcDOAU/xKdMCr0GTgw6WC 3snQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=EJwWzfZt; 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 n4si7799475edw.607.2021.04.12.09.17.34; Mon, 12 Apr 2021 09:17:59 -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=EJwWzfZt; 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 S239030AbhDLQRA (ORCPT + 99 others); Mon, 12 Apr 2021 12:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237798AbhDLQQ6 (ORCPT ); Mon, 12 Apr 2021 12:16:58 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A5D5C061574 for ; Mon, 12 Apr 2021 09:16:38 -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=YpOlDgDwAR8y20H8Gm8o0X6WO1zAuOxCsykTgd3UXC8=; b=EJwWzfZtxxM/S nndp28soJ2TQPlXIHP0kXpjfguAbc+Y6oy4Aw1YilXI9rTJq9ItWkN7kOGF235yq xozQ98EhkHDQH0FkJW5SHg2WkXqmA4YtRdjngO4UrueLsxxZWTnc+8v3zweMRjhG J0apWXo/zhvDofz2e5hZ2O8QLcpnVE= Received: from xhacker (unknown [101.86.20.15]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygC3WplUcnRgiTfLAA--.61003S2; Tue, 13 Apr 2021 00:16:20 +0800 (CST) Date: Tue, 13 Apr 2021 00:11:10 +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 , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang , Anup Patel Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 00/10] riscv: improve self-protection Message-ID: <20210413001110.7209bae6@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygC3WplUcnRgiTfLAA--.61003S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KFyxKrykur15Xw4rZrW5Jrb_yoW8urWkpr 45Cr15urW5Ar93C3Wayrn7ur1rJws5K3yagw43Aw18Aw4avFyjywnYgw4vqryDXFW0g3ZY kF13u34Fkr18Z37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkCb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4j6r4UJwA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40E FcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr 0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY 04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxV W8JVWxJwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUg0D7DU UUU X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang patch1 removes the non-necessary setup_zero_page() patch2 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 Hi Anup, I kept the __init modification to trap_init(), I will cook a trivial series to provide a __weak but NULL trap_init() implementation in init/main.c then remove all NULL implementation from all arch. Thanks Since v2: - collect Reviewed-by tag - add one patch to remove unnecessary setup_zero_page() 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 (10): riscv: mm: Remove setup_zero_page() 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/cpufeature.c | 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 | 16 +++++----------- 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 + 17 files changed, 45 insertions(+), 35 deletions(-) -- 2.31.0