Received: by 10.223.185.116 with SMTP id b49csp61627wrg; Tue, 20 Feb 2018 15:57:43 -0800 (PST) X-Google-Smtp-Source: AH8x224WuIVAD7p7gSW1Zp948tJZcrNiAlsXXO9TpIKur3oH0w6E5kGZczpTotzyY12Q+qxHHMES X-Received: by 10.101.101.206 with SMTP id y14mr101764pgv.297.1519171062994; Tue, 20 Feb 2018 15:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519171062; cv=none; d=google.com; s=arc-20160816; b=i3YiRMNkOip/K9zWd7Vty0YzFJQZTQ5GKBlvlgsRBWqB/Ynfb1SCnoLilcAfMkHJm8 ZIJxrN+IeCW25W3SZPgaesxVLKGc9LoXpcBRBWQ7yd5bJcrEWUJfXuOaKmn40QfxFD23 tpL4/TmrXXJ6Thd/aZLwFa6qP2p8ePF/ueDb13yWS6daNfN8EBdHVWcxQtuMqdHZAn3v zi2MH1LzKaSagD/1KfZ+8uGfRlO01TV+nS4ui1k7rZ/I82Eg1p3Z5v69pUJj/qJ7rsxB 4OBKidzWRbhhFmq1tj3xT5CeXWzOh9FcxBt68HZMcMQfIiL1bPIzzZeicoLFUUi7AZxX xCxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=uhYTRlEqNS+ZxV3VM5OvEqJO4cq9EQ32LI1u+Lrh3S4=; b=wJn38bf/rp8a6iMIkBYijC7F3RfpTvXYH/ayxXQhpVxbqJBi5MXOkGnLNO0RlYIt48 0RErAWC6UI02SYSeG319ydc+lVBnUsDR7OJeT6cIw/Y+DdoNcfgLqKvHdNuoUNI8z5Fb Mo20Wcy0YSb+K9j5bXBAvqQA5N33LL2Az3voq8vLwGwayOqcmYZrJYDqsVHxBQ5dWyU7 W0bZvkimE9cqAco2EXoysVZcvTJP5lJJB96aUVnSDR9pwvXIMbr+vCCgM7eFlFYtaolo /BeRhlTVZjPOdPp+7gyRe9ZzyES7c440ewJ9DZ6tHOecjp92VNBIiHOz74PoWx4xTx0I 6EUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=N08RLcP2; 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 t25si5869938pfk.176.2018.02.20.15.57.17; Tue, 20 Feb 2018 15:57:42 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=N08RLcP2; 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 S1751604AbeBTX4P (ORCPT + 99 others); Tue, 20 Feb 2018 18:56:15 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:47944 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751518AbeBTX4O (ORCPT ); Tue, 20 Feb 2018 18:56:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uhYTRlEqNS+ZxV3VM5OvEqJO4cq9EQ32LI1u+Lrh3S4=; b=N08RLcP2TK3OVxUXdX4WSjkIt UYb+T3x83LPeP+Pq4pS7DrfCdXnJtKU8uIxCO6tkpBoJAcOZifAnLCmbxGrZUfkRu8eZtUjw/z/i+ iWdKklhDhEKLuyFWM3xmNSFn8zYA68uGA7F7+KnLCqiwz2RbO+Y/HKC3ZvKREUs4BwOgIvGdToO6B LZ9jfoWhB0ff087BGjwpNdHI8K14FP5rfa0R+obQcJnph1Swds1t+0ZOPqsbxuvu+FQBcs+Vy3r9k iwFpQbYVr+N00vKuVXABXNEOC0D7ki8O5vRUdfaiQcBQ5Xgn7oZdKExBLL2B6HomCUC8VeoiZBzRn qvJXL9hAw==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1eoHlR-0003vy-2W; Tue, 20 Feb 2018 23:56:01 +0000 Date: Tue, 20 Feb 2018 15:56:00 -0800 From: Matthew Wilcox To: Dave Chinner Cc: Igor Stoppa , Kees Cook , Randy Dunlap , Jonathan Corbet , Michal Hocko , Laura Abbott , Jerome Glisse , Christoph Hellwig , Christoph Lameter , linux-security-module , Linux-MM , LKML , Kernel Hardening Subject: Re: [RFC PATCH v16 0/6] mm: security: ro protection for dynamic data Message-ID: <20180220235600.GA3706@bombadil.infradead.org> References: <20180212165301.17933-1-igor.stoppa@huawei.com> <20180220012111.GC3728@rh> <24e65dec-f452-a444-4382-d1f88fbb334c@huawei.com> <20180220213604.GD3728@rh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180220213604.GD3728@rh> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 08:36:04AM +1100, Dave Chinner wrote: > FWIW, I'm not wanting to use it to replace static variables. All the > structures are dynamically allocated right now, and get assigned to > other dynamically allocated pointers. I'd likely split the current > structures into a "ro after init" structure and rw structure, so > how does the "__ro_after_init" attribute work in that case? Is it > something like this? > > struct xfs_mount { > struct xfs_mount_ro{ > ....... > } *ro __ro_after_init; > ...... No, you'd do: struct xfs_mount_ro { [...] }; struct xfs_mount { const struct xfs_mount_ro *ro; [...] }; We can't do protection on less than a page boundary, so you can't embed a ro struct inside a rw struct. > Also, what compile time checks are in place to catch writes to > ro structure members? Is sparse going to be able to check this sort > of thing, like is does with endian-specific variables? Just labelling the pointer const should be enough for the compiler to catch unintended writes. > > 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. > > I'll look at it in more depth when it comes past again. :P I think the key question is whether you want a slab-style interface or whether you want a kmalloc-style interface. I'd been assuming the former, but Igor has implemented the latter already.