Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2-0]: src/sys/compat/linux/arch/powerpc Pull up revision 1.13 (re...



details:   https://anonhg.NetBSD.org/src/rev/400b529a15c6
branches:  netbsd-2-0
changeset: 561471:400b529a15c6
user:      grant <grant%NetBSD.org@localhost>
date:      Sat Jun 19 04:37:04 2004 +0000

description:
Pull up revision 1.13 (requested by manu in ticket #511):

COMPAT_LINUX/powerpc fixes for non-executable stack.

diffstat:

 sys/compat/linux/arch/powerpc/linux_exec_powerpc.c |  59 +++++++++++++++++++++-
 1 files changed, 57 insertions(+), 2 deletions(-)

diffs (77 lines):

diff -r 0650e4213da4 -r 400b529a15c6 sys/compat/linux/arch/powerpc/linux_exec_powerpc.c
--- a/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c        Sat Jun 19 04:36:22 2004 +0000
+++ b/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c        Sat Jun 19 04:37:04 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_exec_powerpc.c,v 1.12 2003/06/29 22:29:25 fvdl Exp $ */
+/* $NetBSD: linux_exec_powerpc.c,v 1.12.4.1 2004/06/19 04:37:04 grant Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_exec_powerpc.c,v 1.12 2003/06/29 22:29:25 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_powerpc.c,v 1.12.4.1 2004/06/19 04:37:04 grant Exp $");
 
 #if defined (__alpha__)
 #define ELFSIZE 64
@@ -230,3 +230,58 @@
 
        return 0;
 }
+
+/* 
+ * This is copied from sys/kern/exec_subr.c:exec_setup_stack()
+ * We need a Linux version only to avoid the non executable
+ * mappings. They will probably break signal delivery on Linux,
+ * and they surely break the stack fixup hack.
+ */
+int
+linux_exec_setup_stack(p, epp)
+       struct proc *p;
+       struct exec_package *epp;
+{
+       u_long max_stack_size;
+       u_long access_linear_min, access_size;
+       u_long noaccess_linear_min, noaccess_size;
+
+#ifndef        USRSTACK32
+#define USRSTACK32     (0x00000000ffffffffL&~PGOFSET)
+#endif
+
+       if (epp->ep_flags & EXEC_32) {
+               epp->ep_minsaddr = USRSTACK32;
+               max_stack_size = MAXSSIZ;
+       } else {
+               epp->ep_minsaddr = USRSTACK;
+               max_stack_size = MAXSSIZ;
+       }
+       epp->ep_maxsaddr = (u_long)STACK_GROW(epp->ep_minsaddr, 
+               max_stack_size);
+       epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
+
+       /*
+        * set up commands for stack.  note that this takes *two*, one to
+        * map the part of the stack which we can access, and one to map
+        * the part which we can't.
+        *
+        * arguably, it could be made into one, but that would require the
+        * addition of another mapping proc, which is unnecessary
+        */
+       access_size = epp->ep_ssize;
+       access_linear_min = (u_long)STACK_ALLOC(epp->ep_minsaddr, access_size);
+       noaccess_size = max_stack_size - access_size;
+       noaccess_linear_min = (u_long)STACK_ALLOC(STACK_GROW(epp->ep_minsaddr, 
+           access_size), noaccess_size);
+       if (noaccess_size > 0) {
+               NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, noaccess_size,
+                   noaccess_linear_min, NULL, 0, VM_PROT_NONE);
+       }
+       KASSERT(access_size > 0);
+       NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, access_size,
+           access_linear_min, NULL, 0, 
+           VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
+
+       return 0;
+}



Home | Main Index | Thread Index | Old Index