* [PATCHv2] x86/mm: Fix VDSO and VVAR placement on 5-level paging machines
@ 2023-08-03 15:16 Kirill A. Shutemov
2023-08-05 0:13 ` Edgecombe, Rick P
0 siblings, 1 reply; 2+ messages in thread
From: Kirill A. Shutemov @ 2023-08-03 15:16 UTC (permalink / raw)
To: dave.hansen, tglx, mingo, bp
Cc: x86, linux-mm, linux-kernel, Kirill A. Shutemov, Yingcong Wu
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.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Yingcong Wu <yingcong.wu@intel.com>
Fixes: b569bab78d8d ("x86/mm: Prepare to expose larger address space to userspace")
---
v2:
- Fix commit message: grammar and passive voice
arch/x86/entry/vdso/vma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 11a5c68d1218..7645730dc228 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -299,8 +299,8 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
/* Round the lowest possible end address up to a PMD boundary. */
end = (start + len + PMD_SIZE - 1) & PMD_MASK;
- if (end >= TASK_SIZE_MAX)
- end = TASK_SIZE_MAX;
+ if (end >= DEFAULT_MAP_WINDOW)
+ end = DEFAULT_MAP_WINDOW;
end -= len;
if (end > start) {
--
2.41.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCHv2] x86/mm: Fix VDSO and VVAR placement on 5-level paging machines
2023-08-03 15:16 [PATCHv2] x86/mm: Fix VDSO and VVAR placement on 5-level paging machines Kirill A. Shutemov
@ 2023-08-05 0:13 ` Edgecombe, Rick P
0 siblings, 0 replies; 2+ messages in thread
From: Edgecombe, Rick P @ 2023-08-05 0:13 UTC (permalink / raw)
To: kirill.shutemov, tglx, mingo, Hansen, Dave, bp
Cc: Wu, Yingcong, linux-mm, linux-kernel, x86
On Thu, 2023-08-03 at 18:16 +0300, Kirill A. Shutemov wrote:
> 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.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-by: Yingcong Wu <yingcong.wu@intel.com>
> Fixes: b569bab78d8d ("x86/mm: Prepare to expose larger address space
> to userspace")
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-05 0:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-03 15:16 [PATCHv2] x86/mm: Fix VDSO and VVAR placement on 5-level paging machines Kirill A. Shutemov
2023-08-05 0:13 ` Edgecombe, Rick P
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox