Commit 1c24198e authored by Anton Blanchard's avatar Anton Blanchard

ppc64: Add security and AIO syscalls

ppc64: copy FE0 and FE1 bits into MSR when ptracing
ppc64: warn when registering duplicate ioctls
parent e4bbce8a
...@@ -4590,9 +4590,12 @@ int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, u ...@@ -4590,9 +4590,12 @@ int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, u
return -ENOMEM; return -ENOMEM;
memset(additional_ioctls, 0, PAGE_SIZE); memset(additional_ioctls, 0, PAGE_SIZE);
} }
for (i = 0; i < PAGE_SIZE/sizeof(struct ioctl_trans); i++) for (i = 0; i < PAGE_SIZE/sizeof(struct ioctl_trans); i++) {
if (!additional_ioctls[i].cmd) if (!additional_ioctls[i].cmd)
break; break;
if (additional_ioctls[i].cmd == cmd)
printk("duplicate ioctl found: %x\n", cmd);
}
if (i == PAGE_SIZE/sizeof(struct ioctl_trans)) if (i == PAGE_SIZE/sizeof(struct ioctl_trans))
return -ENOMEM; return -ENOMEM;
additional_ioctls[i].cmd = cmd; additional_ioctls[i].cmd = cmd;
......
...@@ -728,11 +728,16 @@ _GLOBAL(sys_call_table32) ...@@ -728,11 +728,16 @@ _GLOBAL(sys_call_table32)
.llong .sys_futex .llong .sys_futex
.llong .sys32_sched_setaffinity .llong .sys32_sched_setaffinity
.llong .sys32_sched_getaffinity .llong .sys32_sched_getaffinity
.llong .sys_ni_syscall /* reserved for security */ .llong .sys_security
.llong .sys_ni_syscall /* 225 - reserved for tux */ .llong .sys_ni_syscall /* 225 - reserved for tux */
.llong .sys32_sendfile64 .llong .sys32_sendfile64
.llong .sys_ni_syscall /* reserved for sys_io_setup */
.llong .sys_ni_syscall /* reserved for sys_io_destroy */
.llong .sys_ni_syscall /* reserved for sys_io_getevents */
.llong .sys_ni_syscall /* 230 - reserved for sys_io_submit */
.llong .sys_ni_syscall /* reserved for sys_io_cancel */
.rept NR_syscalls-226 .rept NR_syscalls-231
.llong .sys_ni_syscall .llong .sys_ni_syscall
.endr .endr
#endif #endif
...@@ -963,10 +968,15 @@ _GLOBAL(sys_call_table) ...@@ -963,10 +968,15 @@ _GLOBAL(sys_call_table)
.llong .sys_futex .llong .sys_futex
.llong .sys_sched_setaffinity .llong .sys_sched_setaffinity
.llong .sys_sched_getaffinity .llong .sys_sched_getaffinity
.llong .sys_ni_syscall /* reserved for security */ .llong .sys_security
.llong .sys_ni_syscall /* reserved for tux */ .llong .sys_ni_syscall /* 225 - reserved for tux */
.llong .sys_ni_syscall /* 225 - 32bit only sendfile64 */ .llong .sys_ni_syscall /* 32bit only sendfile64 */
.llong .sys_io_setup
.rept NR_syscalls-226 .llong .sys_io_destroy
.llong .sys_io_getevents
.llong .sys_io_submit /* 230 */
.llong .sys_io_cancel
.rept NR_syscalls-231
.llong .sys_ni_syscall .llong .sys_ni_syscall
.endr .endr
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/elf.h> #include <linux/elf.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/init_task.h> #include <linux/init_task.h>
#include <linux/prctl.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -234,9 +235,6 @@ void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp) ...@@ -234,9 +235,6 @@ void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp)
current->thread.fpscr = 0; current->thread.fpscr = 0;
} }
/* XXX temporary */
#define PR_FP_EXC_PRECISE 3 /* precise exception mode */
int set_fpexc_mode(struct task_struct *tsk, unsigned int val) int set_fpexc_mode(struct task_struct *tsk, unsigned int val)
{ {
struct pt_regs *regs = tsk->thread.regs; struct pt_regs *regs = tsk->thread.regs;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -58,6 +59,9 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -58,6 +59,9 @@ int sys_ptrace(long request, long pid, long addr, long data)
/* are we already being traced? */ /* are we already being traced? */
if (current->ptrace & PT_PTRACED) if (current->ptrace & PT_PTRACED)
goto out; goto out;
ret = security_ops->ptrace(current->parent, current);
if (ret)
goto out;
/* set the ptrace bit in the process flags. */ /* set the ptrace bit in the process flags. */
current->ptrace |= PT_PTRACED; current->ptrace |= PT_PTRACED;
ret = 0; ret = 0;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -47,6 +48,9 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -47,6 +48,9 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
/* are we already being traced? */ /* are we already being traced? */
if (current->ptrace & PT_PTRACED) if (current->ptrace & PT_PTRACED)
goto out; goto out;
ret = security_ops->ptrace(current->parent, current);
if (ret)
goto out;
/* set the ptrace bit in the process flags. */ /* set the ptrace bit in the process flags. */
current->ptrace |= PT_PTRACED; current->ptrace |= PT_PTRACED;
ret = 0; ret = 0;
......
...@@ -3486,7 +3486,7 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * ...@@ -3486,7 +3486,7 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
bprm.sh_bang = 0; bprm.sh_bang = 0;
bprm.loader = 0; bprm.loader = 0;
bprm.exec = 0; bprm.exec = 0;
bprm.security = NULL;
bprm.mm = mm_alloc(); bprm.mm = mm_alloc();
retval = -ENOMEM; retval = -ENOMEM;
if (!bprm.mm) if (!bprm.mm)
...@@ -3504,6 +3504,10 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * ...@@ -3504,6 +3504,10 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
if ((retval = bprm.envc) < 0) if ((retval = bprm.envc) < 0)
goto out_mm; goto out_mm;
retval = security_ops->bprm_alloc_security(&bprm);
if (retval)
goto out;
retval = prepare_binprm(&bprm); retval = prepare_binprm(&bprm);
if (retval < 0) if (retval < 0)
goto out; goto out;
...@@ -3522,9 +3526,11 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * ...@@ -3522,9 +3526,11 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
goto out; goto out;
retval = search_binary_handler(&bprm,regs); retval = search_binary_handler(&bprm,regs);
if (retval >= 0) if (retval >= 0) {
/* execve success */ /* execve success */
security_ops->bprm_free_security(&bprm);
return retval; return retval;
}
out: out:
/* Something went wrong, return the inode and free the argument pages*/ /* Something went wrong, return the inode and free the argument pages*/
...@@ -3534,6 +3540,9 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * ...@@ -3534,6 +3540,9 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
__free_page(page); __free_page(page);
} }
if (bprm.security)
security_ops->bprm_free_security(&bprm);
out_mm: out_mm:
mmdrop(bprm.mm); mmdrop(bprm.mm);
......
...@@ -19,9 +19,20 @@ ...@@ -19,9 +19,20 @@
*/ */
static inline unsigned long get_reg(struct task_struct *task, int regno) static inline unsigned long get_reg(struct task_struct *task, int regno)
{ {
if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) unsigned long tmp = 0;
return ((unsigned long *)task->thread.regs)[regno];
return 0; /*
* Put the correct FP bits in, they might be wrong as a result
* of our lazy FP restore.
*/
if (regno == PT_MSR) {
tmp = ((unsigned long *)task->thread.regs)[PT_MSR];
tmp |= task->thread.fpexc_mode;
} else if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) {
tmp = ((unsigned long *)task->thread.regs)[regno];
}
return tmp;
} }
/* /*
......
...@@ -236,6 +236,11 @@ ...@@ -236,6 +236,11 @@
#define __NR_security 224 #define __NR_security 224
#define __NR_tuxcall 225 #define __NR_tuxcall 225
#define __NR_sendfile64 226 #define __NR_sendfile64 226
#define __NR_io_setup 227
#define __NR_io_destroy 228
#define __NR_io_getevents 229
#define __NR_io_submit 230
#define __NR_io_cancel 231
#define __NR(n) #n #define __NR(n) #n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment