Received: by 10.223.185.116 with SMTP id b49csp928299wrg; Tue, 20 Feb 2018 10:05:19 -0800 (PST) X-Google-Smtp-Source: AH8x2270xBBPfUmhm/UaaBntljASIHpeEFVcHFDfI40iJBLVo+neBmcPEbFE5WWGwEBXhWeS48GB X-Received: by 2002:a17:902:9898:: with SMTP id s24-v6mr410501plp.275.1519149919197; Tue, 20 Feb 2018 10:05:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519149919; cv=none; d=google.com; s=arc-20160816; b=CgpfnAA0DEDTjHo5bfnNG0p3qmgiuUtcxWwal7/jbmruq/XRnXtGtYMUHM8OnHbJcj 1+lyyp3LCHYNx3p7qaI4EXRaM9HAs4KDCl1a6bSUlEl9U5QeYqXGQPO+mpHRo/GIBLZi WNJzFH8JdvDstDq6RGywYo4kqXzGVaNhPIFxYIKmqrU+gcNzhSYPIqiDxkG5AWKKLM0h dZoxzqe3PfsAmviYjJedjGlBoHBWBQXYM9o7ThRRpKWzaRy7HL5aEjijwliEy03pdOOZ cmYYx9hriGpqiKciVSWaeoDhey/VvEglfcd4osdTW4t9pElBLmB288PrVGA68ARXzBwY Lmpg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=KYUx9NWqWAN19tl9VF9QHwqlQzQeQ4Trp/31LC/YAKM=; b=QngRasZh9uLdUM662dO8rHV6B0ARjzvADBJP63MaaPWIomL0WeQSo1vU6m+nYs/Y18 YufZg9GE/kLMEgndIfL6zPfbVjsH3pAjGT9tLacxjbU9XNg1Q5prlXxr936FU3fpY69i 3VbAEI1VZuINbeLIqXz7F+kJ0LrIKMMOsUb4kTEM/nk7+3so7b5Jm6iojjtqkBWJ1uny oFrnoIVbiD1vwjjdDZ8YThmUptTpcVV3E6XMRHmAKdob9ktONXqVWC6mJg0x2TqhEnhj B1iGeIyxHoOtujnHRrcUSo4c2V0TIOtol2ndOGZZgkPV7dV5kp66QUROekAw+AvbcPM1 czBg== 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 m4si503275pfh.229.2018.02.20.10.05.00; Tue, 20 Feb 2018 10:05:19 -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 S1752771AbeBTSEU (ORCPT + 99 others); Tue, 20 Feb 2018 13:04:20 -0500 Received: from lhrrgout.huawei.com ([194.213.3.17]:26898 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751376AbeBTSES (ORCPT ); Tue, 20 Feb 2018 13:04:18 -0500 Received: from LHREML712-CAH.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id 0D006F73B9247; Tue, 20 Feb 2018 18:04:15 +0000 (GMT) Received: from [10.122.225.51] (10.122.225.51) by smtpsuk.huawei.com (10.201.108.35) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 20 Feb 2018 18:04:12 +0000 Subject: Re: [RFC PATCH v16 0/6] mm: security: ro protection for dynamic data To: Dave Chinner , Kees Cook CC: Matthew Wilcox , Randy Dunlap , Jonathan Corbet , Michal Hocko , Laura Abbott , Jerome Glisse , Christoph Hellwig , "Christoph Lameter" , linux-security-module , Linux-MM , LKML , Kernel Hardening References: <20180212165301.17933-1-igor.stoppa@huawei.com> <20180220012111.GC3728@rh> From: Igor Stoppa Message-ID: <24e65dec-f452-a444-4382-d1f88fbb334c@huawei.com> Date: Tue, 20 Feb 2018 20:03:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180220012111.GC3728@rh> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit 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 On 20/02/18 03:21, Dave Chinner wrote: > On Mon, Feb 12, 2018 at 03:32:36PM -0800, Kees Cook wrote: >> On Mon, Feb 12, 2018 at 8:52 AM, Igor Stoppa wrote: >>> 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. >> >> This series came up in discussions with Dave Chinner (and Matthew >> Wilcox, already part of the discussion, and others) at LCA. I wonder >> if XFS would make a good initial user of this, as it could allocate >> all the function pointers and other const information about a >> superblock in pmalloc(), keeping it separate from the R/W portions? >> Could other filesystems do similar things? > > I wasn't cc'd on this patchset, (please use david@fromorbit.com for > future postings) Apologies, somehow I didn't realize that I should have put you too in CC. It will be fixed at the next iteration. > so I can't really say anything about it right > now. My interest for XFS was that we have a fair amount of static > data in XFS that we set up at mount time and it never gets modified > after that. This is the typical use case I had in mind, although it requires a conversion. Ex: before: static int a; void set_a(void) { a = 4; } after: static int *a __ro_after_init; struct gen_pool *pool; void init_a(void) { pool = pmalloc_create_pool("pool", 0); a = (int *)pmalloc(pool, sizeof(int), GFP_KERNEL); } void set_a(void) { *a = 4; pmalloc_protect_pool(pool); } > I'm not so worried about VFS level objects (that's a > much more complex issue) but there is a lot of low hanging fruit in > the XFS structures we could convert to write-once structures. I'd be interested to have your review of the pmalloc API, if you think something is missing, once I send out the next revision. -- igor