android_kernel_xiaomi_sm8450/arch/x86/entry/vdso
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
..
vdso32 x86: Prepare asm files for straight-line-speculation 2022-07-25 11:26:28 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
checkundef.sh x86/asm/entry, x86/vdso: Move the vDSO code to arch/x86/entry/vdso/ 2015-06-03 18:51:37 +02:00
Makefile x86: link vdso and boot with -z noexecstack --no-warn-rwx-segments 2022-08-21 15:15:18 +02:00
vclock_gettime.c y2038: vdso: change time_t to __kernel_old_time_t 2019-11-15 14:38:28 +01:00
vdso2c.c x86/vdso/vdso2c: Correct error messages on file open 2020-04-21 20:33:16 +02:00
vdso2c.h x86/vdso/vdso2c: Convert iterators to unsigned 2020-04-21 20:33:16 +02:00
vdso32-setup.c x86/vdso: Provide missing include file 2019-12-29 13:41:31 +01:00
vdso-layout.lds.S x86/vdso: Discard .note.gnu.property sections in vDSO 2020-03-27 15:53:05 +01:00
vdso-note.S x86: Add build salt to the vDSO 2018-07-18 01:18:05 +09:00
vdso.lds.S x86/vdso: Add clock_getres() entry point 2019-06-22 21:21:10 +02:00
vdsox32.lds.S x86/vdso: Switch to generic vDSO implementation 2019-06-22 21:21:10 +02:00
vgetcpu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 223 2019-05-30 11:29:55 -07:00
vma.c x86/mm: Fix VDSO and VVAR placement on 5-level paging machines 2023-08-16 18:21:00 +02:00