Re: [PATCH v2 0/2] mm,fork,security: introduce MADV_WIPEONFORK

From: Mike Kravetz
Date: Mon Aug 07 2017 - 14:24:22 EST


On 08/06/2017 07:04 AM, riel@xxxxxxxxxx wrote:
> v2: fix MAP_SHARED case and kbuild warnings
>
> Introduce MADV_WIPEONFORK semantics, which result in a VMA being
> empty in the child process after fork. This differs from MADV_DONTFORK
> in one important way.

It seems that the target use case might be private anonymous mappings.
If a shared or file backed mapping exists, one would assume that it
was created with the intention of sharing, even across fork. So,
setting MADV_DONTFORK on such a mapping seems to change the meaning
and conflict with the original intention of the mapping.

If my thoughts above are correct, what about returning EINVAL if one
attempts to set MADV_DONTFORK on mappings set up for sharing?

If not, and you really want this to be applicable to all mappings, then
you should be more specific about what happens at fork time. Do they
all get turned into anonymous mappings? What happens to file references?
What about the really ugly case of hugetlb mappings? Do they get
'transformed' to non-hugetlb mappings? Or, do you create a separate
hugetlb mapping for the child?

--
Mike Kravetz