All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: + fully-honor-vdso_enabled.patch added to -mm tree
@ 2007-03-01 17:52 Oleg Nesterov
  2007-03-02  3:48 ` Paul Mundt
  2007-03-02 21:06 ` John Reiser
  0 siblings, 2 replies; 14+ messages in thread
From: Oleg Nesterov @ 2007-03-01 17:52 UTC (permalink / raw)
  To: John Reiser
  Cc: Andi Kleen, Ingo Molnar, Arjan van de Ven, Paul Mundt,
	Andrew Morton, linux-kernel

John Reiser wrote:
>
> --- a/arch/i386/kernel/sysenter.c~fully-honor-vdso_enabled
> +++ a/arch/i386/kernel/sysenter.c
> @@ -22,6 +22,8 @@
>  #include <asm/msr.h>
>  #include <asm/pgtable.h>
>  #include <asm/unistd.h>
> +#include <asm/a.out.h>
> +#include <asm/mman.h>
>
>  /*
>   * Should the kernel map a VDSO page into processes and pass its
> @@ -105,10 +107,25 @@ int arch_setup_additional_pages(struct l
>  {
>  	struct mm_struct *mm = current->mm;
>  	unsigned long addr;
> +	unsigned long flags;
>  	int ret;
>
> +	switch (vdso_enabled) {
> +	case 0:  /* none */
> +		return 0;

This means we don't initialize mm->context.vdso and ->sysenter_return.

Is it ok? For example, setup_rt_frame() uses VDSO_SYM(&__kernel_rt_sigreturn),
sysenter_past_esp pushes ->sysenter_return on stack.

Note also that load_elf_binary does

	arch_setup_additional_pages()
	create_elf_tables()

, looks like application can crash after exec if vdso_enabled changes from 0
to 1 in between.

Could you please explain if I missed something?

Oleg.


^ permalink raw reply	[flat|nested] 14+ messages in thread
* + fully-honor-vdso_enabled.patch added to -mm tree
@ 2007-03-01  5:33 akpm
  0 siblings, 0 replies; 14+ messages in thread
From: akpm @ 2007-03-01  5:33 UTC (permalink / raw)
  To: mm-commits; +Cc: jreiser, ak, arjan, lethal, mingo


The patch titled
     fully honor vdso_enabled [i386, sh; x86_64?]
has been added to the -mm tree.  Its filename is
     fully-honor-vdso_enabled.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: fully honor vdso_enabled [i386, sh; x86_64?]
From: John Reiser <jreiser@BitWagon.com>

Architectures such as i386, sh, x86_64 have a flag
/proc/sys/vm/vdso_enabled to choose whether the kernel should setup a
process to use vdso after execve().  Informing the user code via
AT_SYSINFO* is controlled by macro ARCH_DLINFO in fs/binfmt_elf.c and
include/asm-$ARCH/elf.h, but the vdso page is established always via
arch_setup_additonal_pages() called from load_elf_binary().  If
vdso_enabled is off, then current code wastes kernel time during execve()
and fragments the address space unnecessarily.

This patch changes arch_setup_additonal_pages() to honor vdso_enabled.  For
i386 it also allows the option of a fixed addresss to avoid fragmenting the
address space.  Compiles and runs on i386.  x86_64 [IA32 support] and sh
maintainers also please comment.

For some related history, including interaction with exec-shield, see:
http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=229304
and also 207020 and 162797.

Signed-off-by: John Reiser <jreiser@BitWagon.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arjan van de Ven <arjan@infradead.org>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 arch/i386/kernel/sysenter.c        |   19 ++++++++++++++++++-
 arch/sh/kernel/vsyscall/vsyscall.c |    3 +++
 include/asm-i386/a.out.h           |    2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff -puN arch/i386/kernel/sysenter.c~fully-honor-vdso_enabled arch/i386/kernel/sysenter.c
--- a/arch/i386/kernel/sysenter.c~fully-honor-vdso_enabled
+++ a/arch/i386/kernel/sysenter.c
@@ -22,6 +22,8 @@
 #include <asm/msr.h>
 #include <asm/pgtable.h>
 #include <asm/unistd.h>
+#include <asm/a.out.h>
+#include <asm/mman.h>
 
 /*
  * Should the kernel map a VDSO page into processes and pass its
@@ -105,10 +107,25 @@ int arch_setup_additional_pages(struct l
 {
 	struct mm_struct *mm = current->mm;
 	unsigned long addr;
+	unsigned long flags;
 	int ret;
 
+	switch (vdso_enabled) {
+	case 0:  /* none */
+		return 0;
+	default:
+	case 1:  /* vdso in random available page */
+		addr = 0ul;
+		flags = 0ul;
+		break;
+	case 2:  /* out of user's way */
+		addr = STACK_TOP;
+		flags = MAP_FIXED;
+		break;
+	}
+
 	down_write(&mm->mmap_sem);
-	addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
+	addr = get_unmapped_area(NULL, addr, PAGE_SIZE, 0, flags);
 	if (IS_ERR_VALUE(addr)) {
 		ret = addr;
 		goto up_fail;
diff -puN arch/sh/kernel/vsyscall/vsyscall.c~fully-honor-vdso_enabled arch/sh/kernel/vsyscall/vsyscall.c
--- a/arch/sh/kernel/vsyscall/vsyscall.c~fully-honor-vdso_enabled
+++ a/arch/sh/kernel/vsyscall/vsyscall.c
@@ -64,6 +64,9 @@ int arch_setup_additional_pages(struct l
 	unsigned long addr;
 	int ret;
 
+	if (!vdso_enabled)
+		return 0;
+
 	down_write(&mm->mmap_sem);
 	addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
 	if (IS_ERR_VALUE(addr)) {
diff -puN include/asm-i386/a.out.h~fully-honor-vdso_enabled include/asm-i386/a.out.h
--- a/include/asm-i386/a.out.h~fully-honor-vdso_enabled
+++ a/include/asm-i386/a.out.h
@@ -19,7 +19,7 @@ struct exec
 
 #ifdef __KERNEL__
 
-#define STACK_TOP	TASK_SIZE
+#define STACK_TOP	(TASK_SIZE - PAGE_SIZE)  /* 1 page optional for vdso */
 
 #endif
 
_

Patches currently in -mm which might be from jreiser@BitWagon.com are

fully-honor-vdso_enabled.patch

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

end of thread, other threads:[~2007-03-05 10:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-01 17:52 + fully-honor-vdso_enabled.patch added to -mm tree Oleg Nesterov
2007-03-02  3:48 ` Paul Mundt
2007-03-02 19:32   ` Oleg Nesterov
2007-03-02 21:19     ` John Reiser
2007-03-03 17:38       ` Oleg Nesterov
2007-03-02 21:06 ` John Reiser
2007-03-02 22:18   ` Oleg Nesterov
2007-03-05 10:12     ` Paul Mundt
2007-03-05 10:54       ` Oleg Nesterov
2007-03-05 10:56         ` Paul Mundt
2007-03-02 22:19   ` Chuck Ebbert
2007-03-02 23:11     ` Oleg Nesterov
2007-03-02 23:33     ` John Reiser
  -- strict thread matches above, loose matches on Subject: below --
2007-03-01  5:33 akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.