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
return -ENOMEM;
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)
break;
if (additional_ioctls[i].cmd == cmd)
printk("duplicate ioctl found: %x\n", cmd);
}
if (i == PAGE_SIZE/sizeof(struct ioctl_trans))
return -ENOMEM;
additional_ioctls[i].cmd = cmd;
......
......@@ -728,11 +728,16 @@ _GLOBAL(sys_call_table32)
.llong .sys_futex
.llong .sys32_sched_setaffinity
.llong .sys32_sched_getaffinity
.llong .sys_ni_syscall /* reserved for security */
.llong .sys_security
.llong .sys_ni_syscall /* 225 - reserved for tux */
.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
.endr
#endif
......@@ -963,10 +968,15 @@ _GLOBAL(sys_call_table)
.llong .sys_futex
.llong .sys_sched_setaffinity
.llong .sys_sched_getaffinity
.llong .sys_ni_syscall /* reserved for security */
.llong .sys_ni_syscall /* reserved for tux */
.llong .sys_ni_syscall /* 225 - 32bit only sendfile64 */
.rept NR_syscalls-226
.llong .sys_security
.llong .sys_ni_syscall /* 225 - reserved for tux */
.llong .sys_ni_syscall /* 32bit only sendfile64 */
.llong .sys_io_setup
.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
.endr
......@@ -30,6 +30,7 @@
#include <linux/elf.h>
#include <linux/init.h>
#include <linux/init_task.h>
#include <linux/prctl.h>
#include <asm/pgtable.h>
#include <asm/uaccess.h>
......@@ -234,9 +235,6 @@ void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp)
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)
{
struct pt_regs *regs = tsk->thread.regs;
......
......@@ -25,6 +25,7 @@
#include <linux/errno.h>
#include <linux/ptrace.h>
#include <linux/user.h>
#include <linux/security.h>
#include <asm/uaccess.h>
#include <asm/page.h>
......@@ -58,6 +59,9 @@ int sys_ptrace(long request, long pid, long addr, long data)
/* are we already being traced? */
if (current->ptrace & PT_PTRACED)
goto out;
ret = security_ops->ptrace(current->parent, current);
if (ret)
goto out;
/* set the ptrace bit in the process flags. */
current->ptrace |= PT_PTRACED;
ret = 0;
......
......@@ -25,6 +25,7 @@
#include <linux/errno.h>
#include <linux/ptrace.h>
#include <linux/user.h>
#include <linux/security.h>
#include <asm/uaccess.h>
#include <asm/page.h>
......@@ -47,6 +48,9 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
/* are we already being traced? */
if (current->ptrace & PT_PTRACED)
goto out;
ret = security_ops->ptrace(current->parent, current);
if (ret)
goto out;
/* set the ptrace bit in the process flags. */
current->ptrace |= PT_PTRACED;
ret = 0;
......
......@@ -3486,7 +3486,7 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
bprm.sh_bang = 0;
bprm.loader = 0;
bprm.exec = 0;
bprm.security = NULL;
bprm.mm = mm_alloc();
retval = -ENOMEM;
if (!bprm.mm)
......@@ -3504,6 +3504,10 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_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;
......@@ -3522,9 +3526,11 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_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*/
......@@ -3534,6 +3540,9 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
__free_page(page);
}
if (bprm.security)
security_ops->bprm_free_security(&bprm);
out_mm:
mmdrop(bprm.mm);
......
......@@ -19,9 +19,20 @@
*/
static inline unsigned long get_reg(struct task_struct *task, int regno)
{
if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long)))
return ((unsigned long *)task->thread.regs)[regno];
return 0;
unsigned long tmp = 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 @@
#define __NR_security 224
#define __NR_tuxcall 225
#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
......
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