[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAF6GDdFjS612mx1TXzaVk1J-Afz9wsAywTEijO2TG4idxabiw@mail.gmail.com>
Date: Fri, 11 Aug 2017 00:09:57 +0200
From: Colm MacCárthaigh <colm@...costs.net>
To: Michal Hocko <mhocko@...nel.org>
Cc: Florian Weimer <fweimer@...hat.com>,
Kees Cook <keescook@...omium.org>,
Mike Kravetz <mike.kravetz@...cle.com>,
Rik van Riel <riel@...hat.com>,
Will Drewry <wad@...omium.org>, akpm@...ux-foundation.org,
dave.hansen@...el.com, kirill@...temov.name,
linux-api@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, luto@...capital.net, mingo@...nel.org
Subject: Re: [PATCH v2 0/2] mm,fork,security: introduce MADV_WIPEONFORK
On Thu, Aug 10, 2017 at 7:01 PM, Michal Hocko <mhocko@...nel.org> wrote:
> Does anybody actually do that using the minherit BSD interface?
I can't find any OSS examples. I just thought of it in response to
your question, but now that I have, I do want to use it that way in
privsep code.
As a mere user, fwiw it would make /my/ code less complex (in
Kolmogorov terms) to be an madvise option. Here's what that would look
like in user space:
mmap()
#if MAP_INHERIT_ZERO
minherit() || pthread_atfork(workaround_fptr);
#elif MADVISE_WIPEONFORK
madvise() || pthread_atfork(workaround_fptr);
#else
pthread_atfork(workaround_fptr);
#endif
Vs:
#if MAP_WIPEONFORK
mmap( ... WIPEONFORK) || pthread_atfork(workaround_fptr);
#else
mmap()
#endif
#if MAP_INHERIT_ZERO
madvise() || pthread_atfork(workaround_fptr);
#endif
#if !defined(MAP_WIPEONFORK) && !defined(MAP_INHERIT_ZERO)
pthread_atfork(workaround_fptr);
#endif
The former is neater, and also a lot easier to stay structured if the
code is separated across different functional units. Allocation is
often handled in special functions.
For me, madvise() is the principle of least surprise, following
existing DONTDUMP semantics.
--
Colm
Powered by blists - more mailing lists