Received: by 10.223.176.5 with SMTP id f5csp6405wra; Tue, 30 Jan 2018 07:15:44 -0800 (PST) X-Google-Smtp-Source: AH8x224kkbd1oI2JCINefW4447ACaNCRFPs9U9TsDkq7AnYhry+K1tR3DW5Lo7U+SVjP/Ga54R6j X-Received: by 2002:a17:902:5914:: with SMTP id o20-v6mr17052492pli.196.1517325344574; Tue, 30 Jan 2018 07:15:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517325344; cv=none; d=google.com; s=arc-20160816; b=yfLZwdDfnv+E+VFGudoLk03+4e3dfxDm6Qvffm9KjQxN3szRFi101yE4VyBB6ZL+ZT 2jpP8YcuANa0357U9homxj7sE1iPHQgcOHTPp5TXa6x7mdpfzOPyoJLSpNxFxTTXJFTP BGn+HONbDXiytapObxIjVc1GAWlBXoB0T4AK8qPeypRhjEHTIQ1GaNPZmtfAvqzbxkJZ 2CkPTv1n3CTvIitxnY6fTPw1z2uZKzsBFNFBLIZvAyYWQfNoyAFqhJQaf6jk73yJCIu1 tS88xQSDhCO5dpeke/I7VUaHiSgaYLx+Y7waj3nD3MRREkDhVlsqwloOFKpJBuVeu3b4 aXGg== 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=B9+Y7ClLy2bsBvNbJjeAQWQVQRF59ENhFE4zCVu6byw=; b=ojSMvqFtaHFopbpBUN2nZ5OMtlQA8zScFOXe/QENqTwGeUZg/gcTppkEUx0TTfMc14 NaGtcpsQwj5Vda1ntAL/gcnjuvk5ln1MpYOCYNsCDgjhFVVcbromFEy5j6kMF7UO8+nk YfhkvSMNPpbac6bwm9X38FI997rTjeUpr+Eyk0nVKDcLPwVSMQi9XzabEwobCDr04bZN uolKCx1wbkrgdi26ljsNn1R4ZrRIdUUPmjtDB9cy2ScHu3c67rMvPaeRoUW/I/U9oQKr NMJ2BdKW7vFL2h+zu04jTQxgAsN/DdwM3Av4gR/kNFI0CrFo5djzJn8rbGACejzhudaw TSvg== 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 b91-v6si2190013plb.819.2018.01.30.07.15.30; Tue, 30 Jan 2018 07:15:44 -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 S1752890AbeA3PPF (ORCPT + 99 others); Tue, 30 Jan 2018 10:15:05 -0500 Received: from lhrrgout.huawei.com ([194.213.3.17]:23925 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751699AbeA3PPE (ORCPT ); Tue, 30 Jan 2018 10:15:04 -0500 Received: from LHREML714-CAH.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 36A89DD494082; Tue, 30 Jan 2018 15:15:00 +0000 (GMT) Received: from localhost.localdomain (10.122.225.51) by smtpsuk.huawei.com (10.201.108.37) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 30 Jan 2018 15:14:51 +0000 From: Igor Stoppa To: , , , , , CC: , , , , , Igor Stoppa Subject: [RFC PATCH v12 0/6] mm: security: ro protection for dynamic data Date: Tue, 30 Jan 2018 17:14:40 +0200 Message-ID: <20180130151446.24698-1-igor.stoppa@huawei.com> X-Mailer: git-send-email 2.9.3 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 the v11 version: [http://www.openwall.com/lists/kernel-hardening/2018/01/24/4] - restricted access to sysfs entries created (444 -> 400) - more explicit reference to documentation - couple of typos Igor Stoppa (6): genalloc: track beginning of allocations genalloc: selftest struct page: add field for vm_struct Protectable Memory Documentation for Pmalloc Pmalloc: self-test Documentation/core-api/pmalloc.txt | 104 ++++++++ include/linux/genalloc-selftest.h | 30 +++ include/linux/genalloc.h | 5 +- include/linux/mm_types.h | 1 + include/linux/pmalloc.h | 216 ++++++++++++++++ include/linux/vmalloc.h | 1 + init/main.c | 2 + lib/Kconfig | 15 ++ lib/Makefile | 1 + lib/genalloc-selftest.c | 402 +++++++++++++++++++++++++++++ lib/genalloc.c | 444 +++++++++++++++++++++---------- mm/Kconfig | 7 + mm/Makefile | 2 + mm/pmalloc-selftest.c | 65 +++++ mm/pmalloc-selftest.h | 30 +++ mm/pmalloc.c | 516 +++++++++++++++++++++++++++++++++++++ mm/usercopy.c | 25 +- mm/vmalloc.c | 18 +- 18 files changed, 1744 insertions(+), 140 deletions(-) create mode 100644 Documentation/core-api/pmalloc.txt 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.9.3