x86/vdso: Make the PER_CPU segment start out accessed
authorAndy Lutomirski <luto@amacapital.net>
Tue, 23 Sep 2014 17:50:54 +0000 (10:50 -0700)
committerIngo Molnar <mingo@kernel.org>
Tue, 28 Oct 2014 10:22:11 +0000 (11:22 +0100)
The first userspace attempt to read or write the PER_CPU segment
will write the accessed bit to the GDT.  This is visible to
userspace using the LAR instruction, and it also pointlessly
dirties a cache line.

Set the segment's accessed bit at boot to prevent userspace
access to segments from having side effects.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/ac63814ca4c637a08ec2fd0360d67ca67560a9ee.1411494540.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/vdso/vma.c

index 261b134..0c79974 100644 (file)
@@ -264,7 +264,7 @@ static void vsyscall_set_cpu(int cpu)
        d = (struct desc_struct) {
                .limit0 = cpu | ((node & 0xf) << 12),
                .limit = node >> 4,
-               .type = 4,              /* RO data, expand down */
+               .type = 5,              /* RO data, expand down, accessed */
                .dpl = 3,               /* Visible to user code */
                .s = 1,                 /* Not a system segment */
                .p = 1,                 /* Present */