android_kernel_xiaomi_sm8450/arch/x86/entry
Kirill A. Shutemov 5258281a93 x86/mm: Fix VDSO and VVAR placement on 5-level paging machines
commit 1b8b1aa90c9c0e825b181b98b8d9e249dc395470 upstream.

Yingcong has noticed that on the 5-level paging machine, VDSO and VVAR
VMAs are placed above the 47-bit border:

8000001a9000-8000001ad000 r--p 00000000 00:00 0                          [vvar]
8000001ad000-8000001af000 r-xp 00000000 00:00 0                          [vdso]

This might confuse users who are not aware of 5-level paging and expect
all userspace addresses to be under the 47-bit border.

So far problem has only been triggered with ASLR disabled, although it
may also occur with ASLR enabled if the layout is randomized in a just
right way.

The problem happens due to custom placement for the VMAs in the VDSO
code: vdso_addr() tries to place them above the stack and checks the
result against TASK_SIZE_MAX, which is wrong. TASK_SIZE_MAX is set to
the 56-bit border on 5-level paging machines. Use DEFAULT_MAP_WINDOW
instead.

Fixes: b569bab78d ("x86/mm: Prepare to expose larger address space to userspace")
Reported-by: Yingcong Wu <yingcong.wu@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20230803151609.22141-1-kirill.shutemov%40linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-16 18:21:00 +02:00
..
syscalls A couple of x86 fixes which missed rc1 due to my stupidity: 2020-10-27 14:39:29 -07:00
vdso x86/mm: Fix VDSO and VVAR placement on 5-level paging machines 2023-08-16 18:21:00 +02:00
vsyscall x86/vsyscall_emu/64: Don't use RET in vsyscall emulation 2022-07-25 11:26:38 +02:00
calling.h x86/retbleed: Add fine grained Kconfig knobs 2022-07-25 11:26:50 +02:00
common.c x86/entry: Fix noinstr fail in __do_fast_syscall_32() 2021-06-30 08:47:17 -04:00
entry_32.S exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
entry_64_compat.S objtool: Add entry UNRET validation 2022-07-25 11:26:45 +02:00
entry_64.S exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
entry.S x86/bugs: Add retbleed=ibpb 2022-07-25 11:26:44 +02:00
Makefile x86/entry: Build thunk_$(BITS) only if CONFIG_PREEMPTION=y 2022-08-21 15:16:13 +02:00
syscall_32.c x86/entry: Drop asmlinkage from syscalls 2020-03-21 16:03:25 +01:00
syscall_64.c x86/entry: Drop asmlinkage from syscalls 2020-03-21 16:03:25 +01:00
syscall_x32.c mm: remove compat_process_vm_{readv,writev} 2020-10-03 00:02:15 -04:00
thunk_32.S x86/entry: Build thunk_$(BITS) only if CONFIG_PREEMPTION=y 2022-08-21 15:16:13 +02:00
thunk_64.S x86/entry: Build thunk_$(BITS) only if CONFIG_PREEMPTION=y 2022-08-21 15:16:13 +02:00