Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5826663imd; Wed, 31 Oct 2018 02:39:30 -0700 (PDT) X-Google-Smtp-Source: AJdET5ed465+AkfoSF+GZRytPM2j7goJjDa2Oozm1JpvDra/oi1X/mVU2bBKOkYhijZQrZi3dMy3 X-Received: by 2002:a17:902:7108:: with SMTP id a8-v6mr2569382pll.290.1540978770425; Wed, 31 Oct 2018 02:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540978770; cv=none; d=google.com; s=arc-20160816; b=X+ayaloMiuNkhW99m3wF+0wwdLWTLlsEmhQciRI5EgG/yhHWcJYcrKX+t/bAbL7cEm jwF/nmp8cbTtx6QJfnneSXbZZllJQY029FY8jG7hA2Y49Sc+36s8twt7fl7t1Czwa3/X GGUPI+Xzzi698IgDK3V6NlGO9FKw3Bd/AixCjYqOktw0LuaC880FbyXq9lzDEneVfPwA f6xlsb8rc3w7bEsaGFOMjbibZVCAwSsSgsD1zBVKa8uMEy2S3vfEAyzM+mDBBT3v53C8 QtJIimrvBNDnoo5A/TiiKP29dsxK2UJeMRtXB8MjxFeyl5TjKqzHYnWVPwgzHxIuYcFt sRqQ== 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; bh=G0893bgA/y7iXzmJuJJEVe9WVnnsrWSG6x1JuEa+NgM=; b=JXncG5rSLolcyyPdLWI4DVVB4s5s7np0N1tfgXU1bx559VUZbWPKM3fvSMSaUhPXlA z0g0rvWsUmGD5vvVx72QVpM90BozB1rPKnc7TSFcrxRD1uWI3nZOuuqMhu0dsiB3DJ7R JkaYdnDnGZ37ej+ox7Zm0rEtqEuc0VOTSie5HkQP8sbIyz/qUTxtqnukNcQoM/IOKnMM HVtx6VUd1dkamGGcu0TzhBenMpBpulvC+lU8+4mNie5Tey/PEA+WeaEXzyhpp8m3U8vo +sy8Gf2YvtWXhpAaGyPkUCuNpCrdHzP2ohy7BlmZgxt80FjByumKx3fhyyz3lv7gmyO5 whoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=ScM0FWYk; 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 s186-v6si18796901pfb.129.2018.10.31.02.39.15; Wed, 31 Oct 2018 02:39:30 -0700 (PDT) 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=merlin.20170209 header.b=ScM0FWYk; 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 S1728086AbeJaSeg (ORCPT + 99 others); Wed, 31 Oct 2018 14:34:36 -0400 Received: from merlin.infradead.org ([205.233.59.134]:35302 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbeJaSef (ORCPT ); Wed, 31 Oct 2018 14:34:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=G0893bgA/y7iXzmJuJJEVe9WVnnsrWSG6x1JuEa+NgM=; b=ScM0FWYkYbf/CLCPPDd73lfwM 897SU9uP4fuMmkc9waT5p56RwxfAgMpMFZEo1aJjb6mf8eFn3vODDpK5CocZEdpWjxbhxWNQ9uEHN IUEcJYfBJhm/V3GC8ZHWXyEPB2YWe8G/YlmpuZ1JCLoxVZdNxCflEYq3vVVNDJZpRFAB4ahh5Wf5v /uGE9HR0w6FrbHPodGKHfAkkj6QmcD/5TFPce9EUlvPoPXwkSlHlGRyS36E3qfhb6MbbFpyrqqQdb FP/++d19zyCqKfej6Tvz7/rIlbCjb43R0TmwD18UWLrVEueyKU7cYWRB0Ln2Xl0bleGY+FZfP9sGp eZghIjyCQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHmvt-0002ZX-9f; Wed, 31 Oct 2018 09:37:01 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BF0032029FA14; Wed, 31 Oct 2018 10:36:59 +0100 (CET) Date: Wed, 31 Oct 2018 10:36:59 +0100 From: Peter Zijlstra To: Matthew Wilcox Cc: Andy Lutomirski , Kees Cook , Igor Stoppa , Mimi Zohar , Dave Chinner , James Morris , Michal Hocko , Kernel Hardening , linux-integrity , linux-security-module , Igor Stoppa , Dave Hansen , Jonathan Corbet , Laura Abbott , Randy Dunlap , Mike Rapoport , "open list:DOCUMENTATION" , LKML , Thomas Gleixner Subject: Re: [PATCH 10/17] prmem: documentation Message-ID: <20181031093659.GL744@hirez.programming.kicks-ass.net> References: <20181023213504.28905-1-igor.stoppa@huawei.com> <20181023213504.28905-11-igor.stoppa@huawei.com> <20181026092609.GB3159@worktop.c.hoisthospitality.com> <20181028183126.GB744@hirez.programming.kicks-ass.net> <40cd77ce-f234-3213-f3cb-0c3137c5e201@gmail.com> <20181030152641.GE8177@hirez.programming.kicks-ass.net> <0A7AFB50-9ADE-4E12-B541-EC7839223B65@amacapital.net> <20181030175814.GB10491@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181030175814.GB10491@bombadil.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 30, 2018 at 10:58:14AM -0700, Matthew Wilcox wrote: > On Tue, Oct 30, 2018 at 10:06:51AM -0700, Andy Lutomirski wrote: > > > On Oct 30, 2018, at 9:37 AM, Kees Cook wrote: > > I support the addition of a rare-write mechanism to the upstream kernel. > > And I think that there is only one sane way to implement it: using an > > mm_struct. That mm_struct, just like any sane mm_struct, should only > > differ from init_mm in that it has extra mappings in the *user* region. > > I'd like to understand this approach a little better. In a syscall path, > we run with the user task's mm. What you're proposing is that when we > want to modify rare data, we switch to rare_mm which contains a > writable mapping to all the kernel data which is rare-write. > > So the API might look something like this: > > void *p = rare_alloc(...); /* writable pointer */ > p->a = x; > q = rare_protect(p); /* read-only pointer */ > > To subsequently modify q, > > p = rare_modify(q); > q->a = y; > rare_protect(p); Why would you have rare_alloc() imply rare_modify() ? Would you have the allocator meta data inside the rare section?