]> git.neil.brown.name Git - history.git/commitdiff
[SPARC64]: Synchronize with 2.5.x changes
authorDavid S. Miller <davem@nuts.ninka.net>
Fri, 23 Aug 2002 21:00:43 +0000 (14:00 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Fri, 23 Aug 2002 21:00:43 +0000 (14:00 -0700)
- Some places need to include sched.h because the already include ptrace.h
- CLONE_{SET,CLEAR}TID support
- Clear PT_DTRACE when execve succeeds.
- Add security bits to ptrace and sys32_execve
- Add sys_security to syscall tables.

arch/sparc64/kernel/irq.c
arch/sparc64/kernel/process.c
arch/sparc64/kernel/ptrace.c
arch/sparc64/kernel/sys_sparc32.c
arch/sparc64/kernel/systbls.S
arch/sparc64/mm/fault.c
include/asm-sparc64/unistd.h

index 8b2feb44d3649be70c8fe0e742ed0b11b0355630..a6734ad19d66367684d9515c061e36d8c852993b 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/sched.h>
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/kernel_stat.h>
index 8203b2a127d5080512669f1decf756125fb16cfa..54e9dcb930e77b5a56fc54516901dd5c46278a7d 100644 (file)
@@ -591,6 +591,8 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
        p->thread.smp_lock_pc = 0;
 #endif
 
+       p->user_tid = NULL;
+
        /* Calculate offset to stack_frame & pt_regs */
        child_trap_frame = ((char *)t) + (THREAD_SIZE - (TRACEREG_SZ+REGWIN_SZ));
        memcpy(child_trap_frame, (((struct reg_window *)regs)-1), (TRACEREG_SZ+REGWIN_SZ));
@@ -647,6 +649,19 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
        /* Set the second return value for the parent. */
        regs->u_regs[UREG_I1] = 0;
 
+       if (!(clone_flags & (CLONE_SETTID | CLONE_CLEARTID)))
+               return 0;
+
+       if (t->flags & _TIF_32BIT)
+               t->kregs->u_regs[UREG_G2] &= 0xffffffff;
+
+       if (clone_flags & CLONE_SETTID)
+               if (put_user(p->pid, (int *)t->kregs->u_regs[UREG_G2]))
+                       return -EFAULT;
+
+       if (clone_flags & CLONE_CLEARTID)
+               p->user_tid = (int *) t->kregs->u_regs[UREG_G2];
+
        return 0;
 }
 
@@ -791,6 +806,7 @@ asmlinkage int sparc_execve(struct pt_regs *regs)
                current_thread_info()->xfsr[0] = 0;
                current_thread_info()->fpsaved[0] = 0;
                regs->tstate &= ~TSTATE_PEF;
+               current->ptrace &= ~PT_DTRACE;
        }
 out:
        return error;
index 2e68cf1eb5281235b051ee549ae79e9aef77d7d8..c1ef6e0c2b4c66429abf3efdd80c8f8f103169e2 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/user.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
+#include <linux/security.h>
 
 #include <asm/asi.h>
 #include <asm/pgtable.h>
@@ -132,11 +133,19 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
        }
 #endif
        if (request == PTRACE_TRACEME) {
+               int ret;
+
                /* are we already being traced? */
                if (current->ptrace & PT_PTRACED) {
                        pt_error_return(regs, EPERM);
                        goto out;
                }
+               ret = security_ops->ptrace(current->parent, current);
+               if (ret) {
+                       pt_error_return(regs, -ret);
+                       goto out;
+               }
+
                /* set the ptrace bit in the process flags. */
                current->ptrace |= PT_PTRACED;
                pt_succ_return(regs, 0);
index ddf0392850c94ec89065660b75d10adcab064007..7be1895eedb350f9b8566babbbbddb4a9c9b5dde 100644 (file)
@@ -57,6 +57,7 @@
 #include <asm/uaccess.h>
 #include <asm/fpumacro.h>
 #include <asm/semaphore.h>
+#include <asm/mmu_context.h>
 
 #include <net/scm.h>
 
@@ -2873,26 +2874,30 @@ do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * regs)
        int retval;
        int i;
 
-       bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
-       memset(bprm.page, 0, MAX_ARG_PAGES * sizeof(bprm.page[0]));
-
        file = open_exec(filename);
 
        retval = PTR_ERR(file);
        if (IS_ERR(file))
                return retval;
 
+       bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
+       memset(bprm.page, 0, MAX_ARG_PAGES * sizeof(bprm.page[0]));
+
        bprm.file = file;
        bprm.filename = filename;
        bprm.sh_bang = 0;
        bprm.loader = 0;
        bprm.exec = 0;
-
+       bprm.security = NULL;
        bprm.mm = mm_alloc();
        retval = -ENOMEM;
        if (!bprm.mm) 
                goto out_file;
 
+       retval = init_new_context(current, bprm.mm);
+       if (retval < 0)
+               goto out_mm;
+
        bprm.argc = count32(argv, bprm.p / sizeof(u32));
        if ((retval = bprm.argc) < 0)
                goto out_mm;
@@ -2901,6 +2906,10 @@ do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * regs)
        if ((retval = bprm.envc) < 0)
                goto out_mm;
 
+       retval = security_ops->bprm_alloc_security(&bprm);
+       if (retval) 
+               goto out;
+
        retval = prepare_binprm(&bprm);
        if (retval < 0)
                goto out;
@@ -2919,9 +2928,11 @@ do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * regs)
                goto out;
 
        retval = search_binary_handler(&bprm, regs);
-       if (retval >= 0)
+       if (retval >= 0) {
                /* execve success */
+               security_ops->bprm_free_security(&bprm);
                return retval;
+       }
 
 out:
        /* Something went wrong, return the inode and free the argument pages*/
@@ -2931,6 +2942,9 @@ out:
                        __free_page(page);
        }
 
+       if (bprm.security)
+               security_ops->bprm_free_security(&bprm);
+
 out_mm:
        mmdrop(bprm.mm);
 
@@ -2971,6 +2985,7 @@ asmlinkage int sparc32_execve(struct pt_regs *regs)
                current_thread_info()->xfsr[0] = 0;
                current_thread_info()->fpsaved[0] = 0;
                regs->tstate &= ~TSTATE_PEF;
+               current->ptrace &= ~PT_DTRACE;
        }
 out:
         return error;
index 81c6c0496cd7308badcf25118c77967fa6134a55..af3513e58ae14baae2f3ceb35c5e853c812ad36d 100644 (file)
@@ -50,7 +50,7 @@ sys_call_table32:
 /*140*/        .word sys32_sendfile64, sys_nis_syscall, sys_futex, sys_gettid, sys32_getrlimit
        .word sys32_setrlimit, sys_pivot_root, sys32_prctl, sys32_pciconfig_read, sys32_pciconfig_write
 /*150*/        .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
-       .word sys32_fcntl64, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
+       .word sys32_fcntl64, sys_security, sys32_statfs, sys32_fstatfs, sys_oldumount
 /*160*/        .word sys32_sched_setaffinity, sys32_sched_getaffinity, sys_getdomainname, sys_setdomainname, sys_nis_syscall
        .word sys_quotactl, sys_nis_syscall, sys32_mount, sys_ustat, sys_setxattr
 /*170*/        .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys32_getdents
@@ -109,7 +109,7 @@ sys_call_table:
 /*140*/        .word sys_sendfile64, sys_getpeername, sys_futex, sys_gettid, sys_getrlimit
        .word sys_setrlimit, sys_pivot_root, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
 /*150*/        .word sys_getsockname, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
-       .word sys_nis_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
+       .word sys_nis_syscall, sys_security, sys_statfs, sys_fstatfs, sys_oldumount
 /*160*/        .word sys_sched_setaffinity, sys_sched_getaffinity, sys_getdomainname, sys_setdomainname, sys_utrap_install
        .word sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_setxattr
 /*170*/        .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys_getdents
index 2ba62cfbb4b3acf4815304e3cd9bb6a8ae235d54..3798f6d6781bbecc2d98c58806becb959943e225 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/sched.h>
 #include <linux/ptrace.h>
 #include <linux/mman.h>
 #include <linux/signal.h>
index a45d5f4b1358fed2c181e5b9203b5922481c0c55..2b09e8888220b699a2d5cd084841f03233437f57 100644 (file)
 #define __NR_poll               153 /* Common                                      */
 #define __NR_getdents64                154 /* Linux specific                              */
 /* #define __NR_fcntl64         155    Linux sparc32 Specific                      */
-/* #define __NR_getdirentries   156    SunOS Specific                              */
+#define __NR_security           156 /* getdirentries under SunOS                   */
 #define __NR_statfs             157 /* Common                                      */
 #define __NR_fstatfs            158 /* Common                                      */
 #define __NR_umount             159 /* Common                                      */