Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4522902ybv; Mon, 17 Feb 2020 00:33:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzsqJrc6t8LOPJ5k9/DZ95xJmenL6NI+ZEJf1T8n+oQ4AadCxBM1cag7Xxw7uJ0za9FePrz X-Received: by 2002:aca:c401:: with SMTP id u1mr9283263oif.62.1581928401436; Mon, 17 Feb 2020 00:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581928401; cv=none; d=google.com; s=arc-20160816; b=peXHtvSI3mzYz+PMSdxqOTgvuEKSI6it/9cWpOVNFInX5Upx8bWo4cMb0ioVfsAkXJ XLckTvwFIhK7AGeMchf57YTCtHmZOzv9bgfK1OopYXbERGQkTn9f0u0QZIYzQ3hIIKX6 Ir0gvg4rlJ/NxhsU1wHMy7HuMct8U048AgcJrFZ0zGax+KZovT0R78Td4pIXiRbrIOl8 OpHGgE9npfaJgoU+9fj6Fuobf9y8TdQ88s668J0TRBFaQ5zGmZdUvaj+p0pbf5V5Z5xj 6UOqw2Apfs4oHJsj/8HvtVmxpuBpI0opCUgaw6XesdziksfkHmsoeCdATmt7rmJ+9JBJ i5qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Hcs3IYu1loQeGMz6D7BaruDwBKpT/QAWJLc9WJ9RvcU=; b=wXNzxyBFLm+oIS9z2q6VANYFBf576L8jrlb36yVD2lSeHrIVv4gVZ4lRJqTh+2v7wa kHDGIpIOeMMWUxqp/TPdiYpeP1+/mUYkCJnIECkHNTAE4GwxtBtewEfr8jA8xXkYczU/ Tqo1r2wspAfntEea4YTnJj8JTTUUUNOI25NF3tZCuVl3yf0QPFQJEEkbMZeKsJ0bXoM/ lMiVk7TX6d0epb+Qkh6N34kIfq1ey2apyDt2OhFb7OuORFmTklneT7RB/W4P+g+k7lO5 1NC4Q1nIXWuDRPWhklPU0M6QMjYaKMln7zJoWrjgWw/7WoQFQwZ76qPzMV/XQuepffcP 7rqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=hJQ43EsI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si6953290otr.167.2020.02.17.00.33.09; Mon, 17 Feb 2020 00:33:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=hJQ43EsI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728282AbgBQIca (ORCPT + 99 others); Mon, 17 Feb 2020 03:32:30 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33813 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbgBQIc3 (ORCPT ); Mon, 17 Feb 2020 03:32:29 -0500 Received: by mail-pl1-f195.google.com with SMTP id j7so6423949plt.1 for ; Mon, 17 Feb 2020 00:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hcs3IYu1loQeGMz6D7BaruDwBKpT/QAWJLc9WJ9RvcU=; b=hJQ43EsIlapSjLKR42NfRJjH1Lsaw4P+FKomgrWFxgqnsCwR2ujO2E5Mqw+bPn0Yxu wipai+3ldCMpM3eS07bSj3k5yqo6YZQVMW0tuIltyYqE4aqN0JIUZjlt0uSkIgN4ob1o LoJjzNq62ebA+QLaIeie7/kd4Kvrq7jvVAz8DfqYhXkAx8DOUF69YcY38Kav0xSrk6zY QbgebI39Tva9CMqOkV6GCu3glUouzusjITCZT/XCA0/MYiiAgxxOcjHtbyOlDEQ7cVm9 NDjvXCMOA3VE52APYJEffDbdHhbZLuJ7Q+a2OhrKWfTIzEkj45SeJmOQpZtt1HDZGWyR dJCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hcs3IYu1loQeGMz6D7BaruDwBKpT/QAWJLc9WJ9RvcU=; b=fnhavxxysWHJwDfhzKeYI0McMjXZ3ER5eiicPmeNsc8UyrAaKObpbS28ZUmjkhwR9g 9BLi2vW88Xl/+ZFp73nj46wof+hdat7dKLf7Acge/bIfrOnQbtmeYklAZ+g86fUqerNa IUcc5ciQfiK6j05H2x7LRRp4pZnoKxyN3LVb66X+iUy+BOgRMGdP0cRB6cHMeZtvVwBm uTINTocyzps+H4mmcAuv2ZUH9F6JK1zE3a6wKwNOeWHzL6Gv6SBVR9kvGgKw0HPyoGyZ EQADmyQ+NLTe7yU+zQPRWD7xvC1ZYKYMnZiXZMHL8CSIGO0jbdTYpfaJeBTDu0pYa7xP 7RGw== X-Gm-Message-State: APjAAAUvxBDruMioyp9uuCIAXl+uRXCAOdLzxkdos72nZNGbbDstY7s8 1gVeZxs3pNu6AUCGKVzFl00q8g== X-Received: by 2002:a17:90a:1785:: with SMTP id q5mr18885984pja.143.1581928349196; Mon, 17 Feb 2020 00:32:29 -0800 (PST) Received: from hsinchu02.internal.sifive.com (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id z10sm16989319pgz.88.2020.02.17.00.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 00:32:28 -0800 (PST) From: Zong Li To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li Subject: [PATCH 0/8] Support strict kernel memory permissions for security Date: Mon, 17 Feb 2020 16:32:15 +0800 Message-Id: <20200217083223.2011-1-zong.li@sifive.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Zong Li (8): 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 DEBUG_WX support riscv: add two hook functions of ftrace arch/riscv/Kconfig | 6 + arch/riscv/Kconfig.debug | 30 +++++ arch/riscv/include/asm/ptdump.h | 6 + arch/riscv/include/asm/set_memory.h | 41 ++++++ arch/riscv/kernel/ftrace.c | 18 +++ arch/riscv/kernel/vmlinux.lds.S | 12 +- arch/riscv/mm/Makefile | 1 + arch/riscv/mm/init.c | 47 +++++++ arch/riscv/mm/pageattr.c | 187 ++++++++++++++++++++++++++++ 9 files changed, 344 insertions(+), 4 deletions(-) create mode 100644 arch/riscv/include/asm/set_memory.h create mode 100644 arch/riscv/mm/pageattr.c -- 2.25.0