From c0c4f6c29c494c466f3a2a6273c5b55b76a72927 Mon Sep 17 00:00:00 2001 From: Rik van Riel Date: Tue, 19 Sep 2017 20:32:00 +0200 Subject: [PATCH] madvise.2: Document MADV_WIPEONFORK and MADV_KEEPONFORK MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add MADV_WIPEONFORK and MADV_KEEPONFORK documentation, which has been merged for the 4.14 kernel. While documenting what EINVAL means for MADV_WIPEONFORK, I realized that MADV_FREE has the same thing going on, so I documented EINVAL for both in the ERRORS section. This patch documents the following kernel commit: commit d2cd9ede6e193dd7d88b6d27399e96229a551b19 Author: Rik van Riel Date: Wed Sep 6 16:25:15 2017 -0700 mm,fork: introduce MADV_WIPEONFORK Signed-off-by: Rik van Riel Signed-off-by: Colm MacCárthaigh Signed-off-by: Michael Kerrisk --- man2/madvise.2 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/man2/madvise.2 b/man2/madvise.2 index a7468e4578..19d838cfb8 100644 --- a/man2/madvise.2 +++ b/man2/madvise.2 @@ -405,6 +405,24 @@ can be applied only to private anonymous pages (see .BR mmap (2)). On a swapless system, freeing pages in a given range happens instantly, regardless of memory pressure. +.TP +.BR MADV_WIPEONFORK " (since Linux 4.14)" +.\" commit d2cd9ede6e193dd7d88b6d27399e96229a551b19 +Present the child process with zero-filled memory in this range after a +.BR fork (2). +This is useful for per-process data in forking servers that should be +re-initialized in the child process after a fork, for example PRNG seeds, +cryptographic secrets, etc. +.IP +The +.B MADV_WIPEONFORK +operation can only be applied to private anonymous pages (see +.BR mmap (2)). +.TP +.BR MADV_KEEPONFORK " (since Linux 4.14)" +.\" commit d2cd9ede6e193dd7d88b6d27399e96229a551b19 +Undo the effect of an earlier +.BR MADV_WIPEONFORK . .SH RETURN VALUE On success, .BR madvise () @@ -457,6 +475,18 @@ or but the kernel was not configured with .BR CONFIG_KSM . .TP +.B EINVAL +.I advice +is +.BR MADV_FREE +or +.BR MADV_WIPEONFORK +but the specified address range includes file, Huge TLB, +.BR MAP_SHARED , +or +.BR VM_PFNMAP +ranges. +.TP .B EIO (for .BR MADV_WILLNEED ) -- 2.39.2