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

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
...@@ -93,10 +93,10 @@ static int hash__init_new_context(struct mm_struct *mm) ...@@ -93,10 +93,10 @@ static int hash__init_new_context(struct mm_struct *mm)
return index; return index;
/* /*
* We do switch_slb() early in fork, even before we setup the * In the case of exec, use the default limit,
* mm->context.addr_limit. Default to max task size so that we copy the * otherwise inherit it from the mm we are duplicating.
* default values to paca which will help us to handle slb miss early.
*/ */
if (!mm->context.addr_limit)
mm->context.addr_limit = DEFAULT_MAP_WINDOW_USER64; mm->context.addr_limit = DEFAULT_MAP_WINDOW_USER64;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment