During fork we may place the virtual memory address space into an
inconsistent state before the fork operation is complete.
In addition, we may encounter an error during the fork operation that
indicates that the virtual memory address space is invalidated.
As a result, we should not be exposing it in any way to external machinery
that might interact with the mm or VMAs, machinery that is not designed to
deal with incomplete state.
We specifically update the fork logic to defer khugepaged and ksm to the
end of the operation and only to be invoked if no error arose, and disallow
uffd from observing fork events should an error have occurred.
Lorenzo Stoakes (2):
fork: do not invoke uffd on fork if error occurs
fork: only invoke khugepaged, ksm hooks if no error
fs/userfaultfd.c | 28 ++++++++++++++++++++++++++++
include/linux/ksm.h | 10 ++++------
include/linux/userfaultfd_k.h | 5 +++++
kernel/fork.c | 12 ++++++------
4 files changed, 43 insertions(+), 12 deletions(-)
--
2.46.2