Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit effc1b25 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman
Browse files

powerpc/64s/hash: Fix fork() with 512TB process address space



Hash unconditionally resets the addr_limit to default (128TB) when the
mm context is initialised. If a process has > 128TB mappings when it
forks, the child will not get the 512TB addr_limit, so accesses to
valid > 128TB mappings will fail in the child.

Fix this by only resetting the addr_limit to default if it was 0. Non
zero indicates it was duplicated from the parent (0 means exec()).

Fixes: f4ea6dcb ("powerpc/mm: Enable mappings above 128TB")
Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 6a72dc03
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -93,10 +93,10 @@ static int hash__init_new_context(struct mm_struct *mm)
		return index;

	/*
	 * We do switch_slb() early in fork, even before we setup the
	 * mm->context.addr_limit. Default to max task size so that we copy the
	 * default values to paca which will help us to handle slb miss early.
	 * In the case of exec, use the default limit,
	 * otherwise inherit it from the mm we are duplicating.
	 */
	if (!mm->context.addr_limit)
		mm->context.addr_limit = DEFAULT_MAP_WINDOW_USER64;

	/*