Received: by 10.223.185.116 with SMTP id b49csp2400187wrg; Mon, 12 Feb 2018 08:58:46 -0800 (PST) X-Google-Smtp-Source: AH8x2262eDa3cZ/ZjGcmWuQFE3VOldDmenhWZmaFJZpGwGv7HM+fV5ZbeRMQZ7MIdGaGmzw/sHDW X-Received: by 10.98.60.5 with SMTP id j5mr12308580pfa.217.1518454726692; Mon, 12 Feb 2018 08:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518454726; cv=none; d=google.com; s=arc-20160816; b=jLqrVW7f7B/q440bnoIE7lKP9FOF24Bsm4z13fyEIId07NT+K2o5SuzHOrn8QzjiMB 3LzYblBTVvjlxKDxlm2YfoYijF3bC+BToXzjtDSTZiC4u2Grk9n4yi0xixMtLolKwtH8 UV7B4VY5vOb6M7MxfofaJsx7R+Lc+cHYbLFzVjxS5OEQJfLwq652MBSqWQ7bHGENMkJk 2Gq/k5ANAetJv5bNgbbCuO4wNNrMqgxFXFC50YkHHTpgijJ9cwbYZ2wgXv/qtBh1Ly24 WKZ+GPVECVTlQSr2Ar26nkBeAbd/YS0A+8aZP7q7sc+gDAWsOcUSU0aQMYy/1jmTIv2Z ljjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=WMd+ZWs25BOmow0yV9qMvXM3VeKLLFbH8J74Kss7QZ8=; b=huJh7AEBG7r7fLiu8X3aiPAJmWur74wsWxWtMKslTP53jWKibgdBu6TYNBrp4Kzy+5 vnqZ1UMGWaqxuGLeJD8y1aMYIZ+0kqFtuEgK9JTtokmoXEepnbUzCoLRZbU4UQBJNvvd TMjtJUa7VcXjr4MxA4QbbgGVcJc1p89c1ZLT5ULpeIHvhczljmdTLRxbSK5i+QowWFHl O7Hcni1UtHZnI7A+e81y/gwqsYvvR5KxzLWDnQ048hRnltuDMAYZcQy7sx0QN7bnD6dt 8opW6qKcX64mm8gRzLQvB6kgjsWcF0Dv86GajsBi4PnDRlPZmlYsYbOq2YlSfpXKyaxP K+3w== ARC-Authentication-Results: i=1; mx.google.com; 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 n5si4354825pfi.199.2018.02.12.08.58.31; Mon, 12 Feb 2018 08:58:46 -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; 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 S1754491AbeBLQxd (ORCPT + 99 others); Mon, 12 Feb 2018 11:53:33 -0500 Received: from lhrrgout.huawei.com ([194.213.3.17]:26209 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753868AbeBLQxb (ORCPT ); Mon, 12 Feb 2018 11:53:31 -0500 Received: from LHREML712-CAH.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id 05896FAE9C1E5; Mon, 12 Feb 2018 16:53:28 +0000 (GMT) Received: from localhost.localdomain (10.122.225.51) by smtpsuk.huawei.com (10.201.108.35) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 12 Feb 2018 16:53:24 +0000 From: Igor Stoppa To: , , , , , , , CC: , , , , , Igor Stoppa Subject: [RFC PATCH v16 0/6] mm: security: ro protection for dynamic data Date: Mon, 12 Feb 2018 18:52:55 +0200 Message-ID: <20180212165301.17933-1-igor.stoppa@huawei.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.122.225.51] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch-set introduces the possibility of protecting memory that has been allocated dynamically. The memory is managed in pools: when a memory pool is turned into R/O, all the memory that is part of it, will become R/O. A R/O pool can be destroyed, to recover its memory, but it cannot be turned back into R/W mode. This is intentional. This feature is meant for data that doesn't need further modifications after initialization. However the data might need to be released, for example as part of module unloading. To do this, the memory must first be freed, then the pool can be destroyed. An example is provided, in the form of self-testing. Changes since v15: [http://www.openwall.com/lists/kernel-hardening/2018/02/11/4] - Fixed remaining broken comments - Fixed remaining broken "Returns" instead of "Return:" in kernel-doc - Converted "Return:" values to lists - Fixed SPDX license statements Igor Stoppa (6): genalloc: track beginning of allocations genalloc: selftest struct page: add field for vm_struct Protectable Memory Pmalloc: self-test Documentation for Pmalloc Documentation/core-api/index.rst | 1 + Documentation/core-api/pmalloc.rst | 114 +++++++ include/linux/genalloc-selftest.h | 26 ++ include/linux/genalloc.h | 7 +- include/linux/mm_types.h | 1 + include/linux/pmalloc.h | 242 ++++++++++++++ include/linux/vmalloc.h | 1 + init/main.c | 2 + lib/Kconfig | 15 + lib/Makefile | 1 + lib/genalloc-selftest.c | 400 ++++++++++++++++++++++ lib/genalloc.c | 658 +++++++++++++++++++++++++++---------- mm/Kconfig | 15 + mm/Makefile | 2 + mm/pmalloc-selftest.c | 64 ++++ mm/pmalloc-selftest.h | 24 ++ mm/pmalloc.c | 501 ++++++++++++++++++++++++++++ mm/usercopy.c | 33 ++ mm/vmalloc.c | 18 +- 19 files changed, 1950 insertions(+), 175 deletions(-) create mode 100644 Documentation/core-api/pmalloc.rst create mode 100644 include/linux/genalloc-selftest.h create mode 100644 include/linux/pmalloc.h create mode 100644 lib/genalloc-selftest.c create mode 100644 mm/pmalloc-selftest.c create mode 100644 mm/pmalloc-selftest.h create mode 100644 mm/pmalloc.c -- 2.14.1