Patch "x86/mm: Make mmap(MAP_32BIT) work correctly" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
x86/mm: Make mmap(MAP_32BIT) work correctly
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
x86-mm-make-mmap-map_32bit-work-correctly.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Sun Mar 18 16:55:33 CET 2018
From: Dmitry Safonov <[email protected]>
Date: Mon, 6 Mar 2017 17:17:20 +0300
Subject: x86/mm: Make mmap(MAP_32BIT) work correctly
From: Dmitry Safonov <[email protected]>
[ Upstream commit 3e6ef9c80946f781fc25e8490c9875b1d2b61158 ]
mmap(MAP_32BIT) is broken due to the dependency on the TIF_ADDR32 thread flag.
For 64bit applications MAP_32BIT will force legacy bottom-up allocations and the 1GB address space restriction even if the application issued a compat syscall, which should not be subject of these restrictions.
For 32bit applications, which issue 64bit syscalls the newly introduced mmap base separation into 64-bit and compat bases changed the behaviour because now a 64-bit mapping is returned, but due to the TIF_ADDR32 dependency MAP_32BIT is ignored. Before the separation a 32-bit mapping was returned, so the MAP_32BIT handling was irrelevant.
Replace the check for TIF_ADDR32 with a check for the compat syscall. That solves both the 64-bit issuing a compat syscall and the 32-bit issuing a 64-bit syscall problems.
[ tglx: Massaged changelog ]
--- arch/x86/kernel/sys_x86_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/sys_x86_64.c +2 -2
@@ -100,7 +100,7 @@ out:static void find_start_end (unsigned long flags,unsigned long *begin,unsigned long *end) { -if (!test_thread_flag (TIF_ADDR32 ) && (flags &MAP_32BIT )) { +if (!in_compat_syscall () && (flags &MAP_32BIT )) {/* This is usually used needed to map code in small model, so it needs to be in the first 31bit. Limit it to that. This means we need to move the
@@ -175,7 +175,7 @@ arch_get_unmapped_area_topdown(struct fireturn addr;/* for MAP_32BIT mappings we force the legacy mmap base */ -if (!test_thread_flag (TIF_ADDR32 ) && (flags &MAP_32BIT )) +if (!in_compat_syscall () && (flags &MAP_32BIT )) goto bottomup;/* requesting a specific address */
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/x86-mm-make-mmap-map_32bit-work-correctly.patch