VDSO is randomized even when ASLR is disabled
Subsystems (3)
Hello,
I've stumbled upon an issue of VDSO address being randomized on x86_64 when ASLR is disabled. This happens only on systems with 5-level paging enabled. Details below.
Relevant code: "vdso_addr" in arch/x86/entry/vdso/vma.c
VDSO base address is picked at random starting from the stack bottom address so that it stays in the same PMD as the stack. This randomization is made regardless of PF_RANDOMIZE flag.
With ASLR off, stack is mapped at the highest possible address in 4-level paging, which is 0x7ffffffff000 - this leaves no space for VDSO after the stack, which effectively disables the above randomization. With 5-level paging the stack address stays the same, but "TASK_SIZE_MAX" is much greater, allowing for the above randomization.
This behavior is present in all versions (since VDSO was introduced on x64). I think the fix could be as simple as:
arch/x86/entry/vdso/vma.c +1 -1
@@ -326,7 +326,7 @@ static unsigned long vdso_addr(unsigned long start, unsigned len) end =TASK_SIZE_MAX ; end -= len; -if (end > start) { +if (end > start && (current->flags &PF_RANDOMIZE )) { offset =get_random_int () % (((end - start) >>PAGE_SHIFT ) +1 ); addr = start + (offset <<PAGE_SHIFT ); }else {
but I've not tested it yet, figured I'll post here first.
Best regards,
Borys
Hello,
I would like to get some feedback on this issue. Would such fix be accepted? Should I send a patch?
Best regards,
Borys
Quoted 2 lines · Borys Popławski
I would like to get some feedback on this issue. Would such fix be accepted? Should I send a patch?
The best way to get feedback is to submit a real patch following all the rules in our documentation. Cc'ing all the maintainers of the code and testing your fix would be two great places to start.