|
Message-ID: <CAGXu5jKmhoSsOTqDJmr3ijwDAh57Bfq3KVE+AjrBdLXjPz83+g@mail.gmail.com> Date: Wed, 31 Oct 2018 20:28:33 -0700 From: Kees Cook <keescook@...omium.org> To: Peter Zijlstra <peterz@...radead.org> Cc: Will Deacon <will.deacon@....com>, Igor Stoppa <igor.stoppa@...il.com>, Mimi Zohar <zohar@...ux.vnet.ibm.com>, Matthew Wilcox <willy@...radead.org>, Dave Chinner <david@...morbit.com>, James Morris <jmorris@...ei.org>, Michal Hocko <mhocko@...nel.org>, Kernel Hardening <kernel-hardening@...ts.openwall.com>, linux-integrity <linux-integrity@...r.kernel.org>, linux-security-module <linux-security-module@...r.kernel.org>, Igor Stoppa <igor.stoppa@...wei.com>, Dave Hansen <dave.hansen@...ux.intel.com>, Jonathan Corbet <corbet@....net>, Laura Abbott <labbott@...hat.com>, Boqun Feng <boqun.feng@...il.com>, Arnd Bergmann <arnd@...db.de>, linux-arch <linux-arch@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org> Subject: Re: [PATCH 16/17] prmem: pratomic-long On Wed, Oct 31, 2018 at 2:10 AM, Peter Zijlstra <peterz@...radead.org> wrote: > On Tue, Oct 30, 2018 at 04:28:16PM +0000, Will Deacon wrote: >> On Tue, Oct 30, 2018 at 04:58:41PM +0100, Peter Zijlstra wrote: >> > Like mentioned elsewhere; if you do write_enable() + write_disable() >> > thingies, it all becomes: >> > >> > write_enable(); >> > atomic_foo(&bar); >> > write_disable(); >> > >> > No magic gunk infested duplication at all. Of course, ideally you'd then >> > teach objtool about this (or a GCC plugin I suppose) to ensure any >> > enable reached a disable. >> >> Isn't the issue here that we don't want to change the page tables for the >> mapping of &bar, but instead want to create a temporary writable alias >> at a random virtual address? >> >> So you'd want: >> >> wbar = write_enable(&bar); >> atomic_foo(wbar); >> write_disable(wbar); >> >> which is probably better expressed as a map/unmap API. I suspect this >> would also be the only way to do things for cmpxchg() loops, where you >> want to create the mapping outside of the loop to minimise your time in >> the critical section. > > Ah, so I was thikning that the altnerative mm would have stuff in the > same location, just RW instead of RO. I was hoping for the same location too. That allows use to use a gcc plugin to mark, say, function pointer tables, as read-only, and annotate their rare updates with write_rare() without any recalculation. -Kees -- Kees Cook
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.