lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 27 Jan 2007 15:01:51 -0500
From:	"Parag Warudkar" <parag.warudkar@...il.com>
To:	akpm@...l.org, dsd@...too.org, joerg@...rops.han.de, ak@...e.de,
	linux-kernel@...r.kernel.org
Subject: Re: [Bugme-new] [Bug 7891] New: vdso page is no longer mapped for

Here is a patch that does what Andrew Morton suggested (plus some more
as explained below) .
Patch inline below and also attached in case there is whitespace
damage. Compile tested on i386 with make defconfig; make. If anyone
can test on other arches and provide feedback that'd be great.

Signed-off-by: Parag Warudkar <parag.warudkar@...il.com>

- Give i386, x86_64, powerpc and sh a new
  CONFIG_ARCH_HAS_SETUP_ADDITIONAL_PAGES

- Create a new include/linux/interp.h which has:

	struct linux_binprm;
	#ifdef CONFIG_ARCH_HAS_SETUP_ADDITIONAL_PAGES
	extern int arch_setup_additional_pages(struct linux_binprm *bprm,
                                       int executable_stack);
	#else
	static inline int arch_setup_additional_pages(struct linux_binprm *bprm,
                                       int executable_stack)
	{
		return 0;
	}
	#endif

- include <linux/interp.h> from binfmt_elf.c and binfmt_aout.c and from
  all the files which implement arch_setup_additional_pages().

- Remove the #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES from binfmt_elf.c

- Add the call to arch_setup_additional_pages() in binfmt_aout.h.

- EXPORT_SYMBOL(arch_setup_additional_pages) for all arches referred
above - binfmt_aout.c can be built as module on all architectures and
it needs to call arch_setup_additional_pages

- For x86_64 - remove
   #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
   #define arch_setup_additional_pages syscall32_setup_pages
  from ia32_binfmt.c and instead use arch_setup_additional_pages as an
exported wrapper over  syscall32_setup_pages

diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/i386/Kconfig
linux-2.6-wk/arch/i386/Kconfig
--- linux-2.6-us/arch/i386/Kconfig	2007-01-26 18:49:36.000000000 -0500
+++ linux-2.6-wk/arch/i386/Kconfig	2007-01-26 18:56:29.000000000 -0500
@@ -625,6 +625,11 @@
 config ARCH_POPULATES_NODE_MAP
 	def_bool y

+config ARCH_HAS_SETUP_ADDITIONAL_PAGES
+       bool
+       default y
+       depends on X86_32
+
 source "mm/Kconfig"

 config HIGHPTE
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/i386/kernel/sysenter.c
linux-2.6-wk/arch/i386/kernel/sysenter.c
--- linux-2.6-us/arch/i386/kernel/sysenter.c	2007-01-26 18:49:36.000000000 -0500
+++ linux-2.6-wk/arch/i386/kernel/sysenter.c	2007-01-27 12:40:14.000000000 -0500
@@ -17,6 +17,7 @@
 #include <linux/elf.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/interp.h>

 #include <asm/cpufeature.h>
 #include <asm/msr.h>
@@ -165,6 +166,7 @@
 	up_write(&mm->mmap_sem);
 	return ret;
 }
+EXPORT_SYMBOL(arch_setup_additional_pages);

 const char *arch_vma_name(struct vm_area_struct *vma)
 {
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/powerpc/Kconfig
linux-2.6-wk/arch/powerpc/Kconfig
--- linux-2.6-us/arch/powerpc/Kconfig	2007-01-26 18:49:36.000000000 -0500
+++ linux-2.6-wk/arch/powerpc/Kconfig	2007-01-26 19:01:39.000000000 -0500
@@ -45,6 +45,11 @@
 	bool
 	default y

+config ARCH_HAS_SETUP_ADDITIONAL_PAGES
+       bool
+       default y
+       depends on PPC32 || PPC64
+
 config ARCH_HAS_ILOG2_U64
 	bool
 	default y if 64BIT
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/powerpc/kernel/vdso.c
linux-2.6-wk/arch/powerpc/kernel/vdso.c
--- linux-2.6-us/arch/powerpc/kernel/vdso.c	2007-01-26 18:49:36.000000000 -0500
+++ linux-2.6-wk/arch/powerpc/kernel/vdso.c	2007-01-27 12:39:39.000000000 -0500
@@ -22,6 +22,7 @@
 #include <linux/elf.h>
 #include <linux/security.h>
 #include <linux/bootmem.h>
+#include <linux/interp.h>

 #include <asm/pgtable.h>
 #include <asm/system.h>
@@ -305,6 +306,7 @@
 	up_write(&mm->mmap_sem);
 	return rc;
 }
+EXPORT_SYMBOL(arch_setup_additional_pages);

 const char *arch_vma_name(struct vm_area_struct *vma)
 {
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/sh/Kconfig
linux-2.6-wk/arch/sh/Kconfig
--- linux-2.6-us/arch/sh/Kconfig	2007-01-26 18:49:36.000000000 -0500
+++ linux-2.6-wk/arch/sh/Kconfig	2007-01-26 19:04:00.000000000 -0500
@@ -67,6 +67,11 @@
 	bool
 	default n

+config ARCH_HAS_SETUP_ADDITIONAL_PAGES
+       bool
+       default y
+       depends on SUPERH
+
 source "init/Kconfig"

 menu "System type"
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/sh/kernel/vsyscall/vsyscall.c
linux-2.6-wk/arch/sh/kernel/vsyscall/vsyscall.c
--- linux-2.6-us/arch/sh/kernel/vsyscall/vsyscall.c	2007-01-26
18:49:36.000000000 -0500
+++ linux-2.6-wk/arch/sh/kernel/vsyscall/vsyscall.c	2007-01-27
12:39:15.000000000 -0500
@@ -17,6 +17,7 @@
 #include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/elf.h>
+#include <linux/interp.h>

 /*
  * Should the kernel map a VDSO page into processes and pass its
@@ -125,6 +126,7 @@
 	up_write(&mm->mmap_sem);
 	return ret;
 }
+EXPORT_SYMBOL(arch_setup_additional_pages);

 const char *arch_vma_name(struct vm_area_struct *vma)
 {
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/x86_64/ia32/ia32_aout.c
linux-2.6-wk/arch/x86_64/ia32/ia32_aout.c
--- linux-2.6-us/arch/x86_64/ia32/ia32_aout.c	2007-01-26
18:49:37.000000000 -0500
+++ linux-2.6-wk/arch/x86_64/ia32/ia32_aout.c	2007-01-27
13:30:08.000000000 -0500
@@ -25,6 +25,7 @@
 #include <linux/binfmts.h>
 #include <linux/personality.h>
 #include <linux/init.h>
+#include <linux/interp.h>

 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -410,7 +411,15 @@
 		send_sig(SIGKILL, current, 0);
 		return retval;
 	}
-
+	
+	retval = arch_setup_additional_pages(bprm, EXSTACK_DEFAULT);
+
+	if (retval < 0) {
+                /* Someone check-me: is this error path enough? */
+                send_sig(SIGKILL, current, 0);
+                return retval;
+        }
+	
 	current->mm->start_stack =
 		(unsigned long)create_aout_tables((char __user *)bprm->p, bprm);
 	/* start thread */
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/x86_64/ia32/ia32_binfmt.c
linux-2.6-wk/arch/x86_64/ia32/ia32_binfmt.c
--- linux-2.6-us/arch/x86_64/ia32/ia32_binfmt.c	2007-01-26
18:49:37.000000000 -0500
+++ linux-2.6-wk/arch/x86_64/ia32/ia32_binfmt.c	2007-01-27
13:23:56.000000000 -0500
@@ -14,6 +14,7 @@
 #include <linux/binfmts.h>
 #include <linux/mm.h>
 #include <linux/security.h>
+#include <linux/interp.h>

 #include <asm/segment.h>
 #include <asm/ptrace.h>
@@ -307,10 +308,6 @@

 static void elf32_init(struct pt_regs *);

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-#define arch_setup_additional_pages syscall32_setup_pages
-extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
-
 #include "../../../fs/binfmt_elf.c"

 static void elf32_init(struct pt_regs *regs)
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/x86_64/ia32/syscall32.c
linux-2.6-wk/arch/x86_64/ia32/syscall32.c
--- linux-2.6-us/arch/x86_64/ia32/syscall32.c	2007-01-26
18:49:37.000000000 -0500
+++ linux-2.6-wk/arch/x86_64/ia32/syscall32.c	2007-01-27
13:14:53.000000000 -0500
@@ -10,6 +10,7 @@
 #include <linux/init.h>
 #include <linux/stringify.h>
 #include <linux/security.h>
+#include <linux/interp.h>
 #include <asm/proto.h>
 #include <asm/tlbflush.h>
 #include <asm/ia32_unistd.h>
@@ -75,6 +76,12 @@
 	return 0;
 }

+int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
+{
+	return syscall32_setup_pages(struct linux_binprm *bprm, int exstack);
+}
+EXPORT_SYMBOL(arch_setup_additional_pages);
+
 static int __init init_syscall32(void)
 {
 	syscall32_page = (void *)get_zeroed_page(GFP_KERNEL);
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/arch/x86_64/Kconfig
linux-2.6-wk/arch/x86_64/Kconfig
--- linux-2.6-us/arch/x86_64/Kconfig	2007-01-26 18:49:37.000000000 -0500
+++ linux-2.6-wk/arch/x86_64/Kconfig	2007-01-26 18:59:26.000000000 -0500
@@ -398,6 +398,11 @@
 	def_bool y
 	depends on NUMA

+config ARCH_HAS_SETUP_ADDITIONAL_PAGES
+       bool
+       default y
+       depends on X86_64
+
 config OUT_OF_LINE_PFN_TO_PAGE
 	def_bool y
 	depends on DISCONTIGMEM
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/fs/binfmt_aout.c
linux-2.6-wk/fs/binfmt_aout.c
--- linux-2.6-us/fs/binfmt_aout.c	2007-01-26 18:49:39.000000000 -0500
+++ linux-2.6-wk/fs/binfmt_aout.c	2007-01-27 12:22:48.000000000 -0500
@@ -22,6 +22,7 @@
 #include <linux/user.h>
 #include <linux/slab.h>
 #include <linux/binfmts.h>
+#include <linux/interp.h>
 #include <linux/personality.h>
 #include <linux/init.h>

@@ -269,7 +270,7 @@
 	unsigned long fd_offset;
 	unsigned long rlim;
 	int retval;
-
+	int executable_stack = EXSTACK_DEFAULT;
 	ex = *((struct exec *) bprm->buf);		/* exec-header */
 	if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
 	     N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
@@ -432,6 +433,12 @@
 	}
 beyond_if:
 	set_binfmt(&aout_format);
+	
+	retval = arch_setup_additional_pages(bprm, executable_stack);
+        if (retval < 0) {
+                send_sig(SIGKILL, current, 0);
+                return retval;
+        }

 	retval = set_brk(current->mm->start_brk, current->mm->brk);
 	if (retval < 0) {
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/fs/binfmt_elf.c
linux-2.6-wk/fs/binfmt_elf.c
--- linux-2.6-us/fs/binfmt_elf.c	2007-01-26 18:49:39.000000000 -0500
+++ linux-2.6-wk/fs/binfmt_elf.c	2007-01-27 11:09:48.000000000 -0500
@@ -38,6 +38,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/random.h>
+#include <linux/interp.h>
 #include <linux/elf.h>
 #include <asm/uaccess.h>
 #include <asm/param.h>
@@ -965,13 +966,11 @@

 	set_binfmt(&elf_format);

-#ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES
 	retval = arch_setup_additional_pages(bprm, executable_stack);
 	if (retval < 0) {
 		send_sig(SIGKILL, current, 0);
 		goto out;
 	}
-#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */

 	compute_creds(bprm);
 	current->flags &= ~PF_FORKNOEXEC;
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/include/asm-i386/elf.h
linux-2.6-wk/include/asm-i386/elf.h
--- linux-2.6-us/include/asm-i386/elf.h	2007-01-26 18:49:40.000000000 -0500
+++ linux-2.6-wk/include/asm-i386/elf.h	2007-01-27 12:24:35.000000000 -0500
@@ -156,11 +156,6 @@

 #define VDSO_ENTRY		VDSO_SYM(&__kernel_vsyscall)

-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
-                                       int executable_stack);
-
 extern unsigned int vdso_enabled;

 #define ARCH_DLINFO						\
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/include/asm-powerpc/elf.h
linux-2.6-wk/include/asm-powerpc/elf.h
--- linux-2.6-us/include/asm-powerpc/elf.h	2007-01-26 18:49:40.000000000 -0500
+++ linux-2.6-wk/include/asm-powerpc/elf.h	2007-01-27 12:24:51.000000000 -0500
@@ -266,11 +266,6 @@
 extern int icache_bsize;
 extern int ucache_bsize;

-/* vDSO has arch_setup_additional_pages */
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
-				       int executable_stack);
 #define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b);

 /*
diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/include/asm-sh/elf.h
linux-2.6-wk/include/asm-sh/elf.h
--- linux-2.6-us/include/asm-sh/elf.h	2007-01-26 18:49:40.000000000 -0500
+++ linux-2.6-wk/include/asm-sh/elf.h	2007-01-27 12:25:07.000000000 -0500
@@ -121,12 +121,6 @@
 #endif

 #ifdef CONFIG_VSYSCALL
-/* vDSO has arch_setup_additional_pages */
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
-				       int executable_stack);
-
 extern unsigned int vdso_enabled;
 extern void __kernel_vsyscall;

diff -urN --exclude='cscope*' --exclude='*git*' --exclude='*.[sSoO]'
--exclude='*.gz' linux-2.6-us/include/linux/interp.h
linux-2.6-wk/include/linux/interp.h
--- linux-2.6-us/include/linux/interp.h	1969-12-31 19:00:00.000000000 -0500
+++ linux-2.6-wk/include/linux/interp.h	2007-01-27 12:13:44.000000000 -0500
@@ -0,0 +1,17 @@
+/* interp.h */
+#ifndef _LINUX_INTERP_H
+#define _LINUX_INTERP_H
+
+struct linux_binprm;
+#ifdef CONFIG_ARCH_HAS_SETUP_ADDITIONAL_PAGES
+extern int arch_setup_additional_pages(struct linux_binprm *bprm,
+					int executable_stack);
+#else
+static inline int arch_setup_additional_pages(struct linux_binprm *bprm,
+				int executable_stack)
+{
+	return 0;
+}
+#endif
+
+#endif /* interp.h */

View attachment "fix-arch-setup-add-pages.patch" of type "text/x-patch" (11332 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ