public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86_64: fix perms/range of vsyscall vma in /proc/*/maps
@ 2006-11-10  1:20 Ernie Petrides
  2006-11-10  5:07 ` Andi Kleen
  0 siblings, 1 reply; 4+ messages in thread
From: Ernie Petrides @ 2006-11-10  1:20 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

Hi, Andy.  The final line of /proc/<pid>/maps on x86_64 for native 64-bit
tasks shows an incorrect ending address and incorrect permissions.  There
is only a single page mapped in this vsyscall region, and it is accessible
for both read and execute.

The patch below fixes this.  (Since 32-bit-compat tasks have a real vma
with correct perms/range, no change is necessary for that scenario.)

Before the patch, a "cat /proc/self/maps | tail -1" shows this:

	ffffffffff600000-ffffffffffe00000 ---p 00000000 [...]

After the patch, this is the output:

	ffffffffff600000-ffffffffff601000 r-xp 00000000 [...]

Cheers.  -ernie



Signed-off-by: Ernie Petrides <petrides@redhat.com>

--- linux-2.6.18/arch/x86_64/mm/init.c.orig
+++ linux-2.6.18/arch/x86_64/mm/init.c
@@ -774,14 +774,15 @@ static __init int x8664_sysctl_init(void
 __initcall(x8664_sysctl_init);
 #endif
 
-/* A pseudo VMAs to allow ptrace access for the vsyscall page.   This only
+/* A pseudo VMA to allow ptrace access for the vsyscall page.   This only
    covers the 64bit vsyscall page now. 32bit has a real VMA now and does
    not need special handling anymore. */
 
 static struct vm_area_struct gate_vma = {
 	.vm_start = VSYSCALL_START,
-	.vm_end = VSYSCALL_END,
-	.vm_page_prot = PAGE_READONLY
+	.vm_end = VSYSCALL_START + PAGE_SIZE,
+	.vm_page_prot = PAGE_READONLY_EXEC,
+	.vm_flags = VM_READ | VM_EXEC
 };
 
 struct vm_area_struct *get_gate_vma(struct task_struct *tsk)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86_64: fix perms/range of vsyscall vma in /proc/*/maps
  2006-11-10  1:20 [PATCH] x86_64: fix perms/range of vsyscall vma in /proc/*/maps Ernie Petrides
@ 2006-11-10  5:07 ` Andi Kleen
  2006-11-14  2:51   ` Ernie Petrides
  0 siblings, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2006-11-10  5:07 UTC (permalink / raw)
  To: Ernie Petrides; +Cc: linux-kernel

On Friday 10 November 2006 02:20, Ernie Petrides wrote:
> Hi, Andy.  The final line of /proc/<pid>/maps on x86_64 for native 64-bit
> tasks shows an incorrect ending address and incorrect permissions.  There
> is only a single page mapped in this vsyscall region, and it is accessible
> for both read and execute.

The range reported is how much address space is reserved, but you're
right it is less.

But I don't like hardcoding a page here -- this will likely be extended
soon. Can you please create a new define VSYSCALL_REAL_LENGTH or similar 
in vsyscall.h and use that?

Thanks,
-Andi


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86_64: fix perms/range of vsyscall vma in /proc/*/maps
  2006-11-10  5:07 ` Andi Kleen
@ 2006-11-14  2:51   ` Ernie Petrides
  2006-11-14  2:52     ` Andi Kleen
  0 siblings, 1 reply; 4+ messages in thread
From: Ernie Petrides @ 2006-11-14  2:51 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

On Friday, 10-Nov-2006 at 6:07 +0100, Andi Kleen wrote:

> On Friday 10 November 2006 02:20, Ernie Petrides wrote:
>
> > Hi, Andi.  The final line of /proc/<pid>/maps on x86_64 for native 64-bit
> > tasks shows an incorrect ending address and incorrect permissions.  There
> > is only a single page mapped in this vsyscall region, and it is accessible
> > for both read and execute.
> 
> The range reported is how much address space is reserved, but you're
> right it is less.
> 
> But I don't like hardcoding a page here -- this will likely be extended
> soon. Can you please create a new define VSYSCALL_REAL_LENGTH or similar 
> in vsyscall.h and use that?

Good idea -- how about the patch below?

Cheers.  -ernie



Signed-off-by: Ernie Petrides <petrides@redhat.com>

--- linux-2.6.18/arch/x86_64/kernel/vsyscall.c.orig
+++ linux-2.6.18/arch/x86_64/kernel/vsyscall.c
@@ -205,6 +205,7 @@ static void __init map_vsyscall(void)
 	extern char __vsyscall_0;
 	unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
 
+	/* Note that VSYSCALL_MAPPED_PAGES must agree with the code below. */
 	__set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
 }
 
--- linux-2.6.18/arch/x86_64/mm/init.c.orig
+++ linux-2.6.18/arch/x86_64/mm/init.c
@@ -774,14 +774,15 @@ static __init int x8664_sysctl_init(void
 __initcall(x8664_sysctl_init);
 #endif
 
-/* A pseudo VMAs to allow ptrace access for the vsyscall page.   This only
+/* A pseudo VMA to allow ptrace access for the vsyscall page.  This only
    covers the 64bit vsyscall page now. 32bit has a real VMA now and does
    not need special handling anymore. */
 
 static struct vm_area_struct gate_vma = {
 	.vm_start = VSYSCALL_START,
-	.vm_end = VSYSCALL_END,
-	.vm_page_prot = PAGE_READONLY
+	.vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES << PAGE_SHIFT),
+	.vm_page_prot = PAGE_READONLY_EXEC,
+	.vm_flags = VM_READ | VM_EXEC
 };
 
 struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
--- linux-2.6.18/include/asm-x86_64/vsyscall.h.orig
+++ linux-2.6.18/include/asm-x86_64/vsyscall.h
@@ -9,6 +9,7 @@ enum vsyscall_num {
 #define VSYSCALL_START (-10UL << 20)
 #define VSYSCALL_SIZE 1024
 #define VSYSCALL_END (-2UL << 20)
+#define VSYSCALL_MAPPED_PAGES 1
 #define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
 
 #ifdef __KERNEL__

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86_64: fix perms/range of vsyscall vma in /proc/*/maps
  2006-11-14  2:51   ` Ernie Petrides
@ 2006-11-14  2:52     ` Andi Kleen
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2006-11-14  2:52 UTC (permalink / raw)
  To: Ernie Petrides; +Cc: linux-kernel

On Tuesday 14 November 2006 03:51, Ernie Petrides wrote:
> On Friday, 10-Nov-2006 at 6:07 +0100, Andi Kleen wrote:
> 
> > On Friday 10 November 2006 02:20, Ernie Petrides wrote:
> >
> > > Hi, Andi.  The final line of /proc/<pid>/maps on x86_64 for native 64-bit
> > > tasks shows an incorrect ending address and incorrect permissions.  There
> > > is only a single page mapped in this vsyscall region, and it is accessible
> > > for both read and execute.
> > 
> > The range reported is how much address space is reserved, but you're
> > right it is less.
> > 
> > But I don't like hardcoding a page here -- this will likely be extended
> > soon. Can you please create a new define VSYSCALL_REAL_LENGTH or similar 
> > in vsyscall.h and use that?
> 
> Good idea -- how about the patch below?

Added thanks. Probably for .20, i don't think it's critical enough for .19
unless someone feels strongly about it.

-Andi

P.S.: When you retransmit patches please always include the original description
for the changelog too.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-14  2:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-10  1:20 [PATCH] x86_64: fix perms/range of vsyscall vma in /proc/*/maps Ernie Petrides
2006-11-10  5:07 ` Andi Kleen
2006-11-14  2:51   ` Ernie Petrides
2006-11-14  2:52     ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox