Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49275fe

Browse files
amlutoIngo Molnar
authored and
Ingo Molnar
committed
x86/vsyscall/64: Explicitly set _PAGE_USER in the pagetable hierarchy
The kernel is very erratic as to which pagetables have _PAGE_USER set. Thevsyscall page gets lucky: it seems that all of the relevant pagetables areamong the apparently arbitrary ones that set _PAGE_USER. Rather thanrelying on chance, just explicitly set _PAGE_USER.This will let us clean up pagetable setup to stop setting _PAGE_USER. Theadded code can also be reused by pagetable isolation to manage the_PAGE_USER bit in the usermode tables.[ tglx: Folded paravirt fix from Juergen Gross ]Signed-off-by: Andy Lutomirski <luto@kernel.org>Signed-off-by: Thomas Gleixner <tglx@linutronix.de>Cc: Borislav Petkov <bp@alien8.de>Cc: Brian Gerst <brgerst@gmail.com>Cc: Dave Hansen <dave.hansen@linux.intel.com>Cc: David Laight <David.Laight@aculab.com>Cc: H. Peter Anvin <hpa@zytor.com>Cc: Josh Poimboeuf <jpoimboe@redhat.com>Cc: Juergen Gross <jgross@suse.com>Cc: Kees Cook <keescook@chromium.org>Cc: Linus Torvalds <torvalds@linux-foundation.org>Cc: Peter Zijlstra <peterz@infradead.org>Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent146122e commit49275fe

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

‎arch/x86/entry/vsyscall/vsyscall_64.c‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include<asm/unistd.h>
3838
#include<asm/fixmap.h>
3939
#include<asm/traps.h>
40+
#include<asm/paravirt.h>
4041

4142
#defineCREATE_TRACE_POINTS
4243
#include"vsyscall_trace.h"
@@ -329,16 +330,47 @@ int in_gate_area_no_mm(unsigned long addr)
329330
returnvsyscall_mode!=NONE&& (addr&PAGE_MASK)==VSYSCALL_ADDR;
330331
}
331332

333+
/*
334+
* The VSYSCALL page is the only user-accessible page in the kernel address
335+
* range. Normally, the kernel page tables can have _PAGE_USER clear, but
336+
* the tables covering VSYSCALL_ADDR need _PAGE_USER set if vsyscalls
337+
* are enabled.
338+
*
339+
* Some day we may create a "minimal" vsyscall mode in which we emulate
340+
* vsyscalls but leave the page not present. If so, we skip calling
341+
* this.
342+
*/
343+
staticvoid__initset_vsyscall_pgtable_user_bits(void)
344+
{
345+
pgd_t*pgd;
346+
p4d_t*p4d;
347+
pud_t*pud;
348+
pmd_t*pmd;
349+
350+
pgd=pgd_offset_k(VSYSCALL_ADDR);
351+
set_pgd(pgd,__pgd(pgd_val(*pgd) |_PAGE_USER));
352+
p4d=p4d_offset(pgd,VSYSCALL_ADDR);
353+
#ifCONFIG_PGTABLE_LEVELS >=5
354+
p4d->p4d |=_PAGE_USER;
355+
#endif
356+
pud=pud_offset(p4d,VSYSCALL_ADDR);
357+
set_pud(pud,__pud(pud_val(*pud) |_PAGE_USER));
358+
pmd=pmd_offset(pud,VSYSCALL_ADDR);
359+
set_pmd(pmd,__pmd(pmd_val(*pmd) |_PAGE_USER));
360+
}
361+
332362
void__initmap_vsyscall(void)
333363
{
334364
externchar__vsyscall_page;
335365
unsigned longphysaddr_vsyscall=__pa_symbol(&__vsyscall_page);
336366

337-
if (vsyscall_mode!=NONE)
367+
if (vsyscall_mode!=NONE) {
338368
__set_fixmap(VSYSCALL_PAGE,physaddr_vsyscall,
339369
vsyscall_mode==NATIVE
340370
?PAGE_KERNEL_VSYSCALL
341371
:PAGE_KERNEL_VVAR);
372+
set_vsyscall_pgtable_user_bits();
373+
}
342374

343375
BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE)!=
344376
(unsigned long)VSYSCALL_ADDR);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp