[MIPS] Fixup secure computing stuff.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
@ -132,7 +132,6 @@ void output_thread_defines(void)
|
||||
offset("#define THREAD_ECODE ", struct task_struct, \
|
||||
thread.error_code);
|
||||
offset("#define THREAD_TRAPNO ", struct task_struct, thread.trap_no);
|
||||
offset("#define THREAD_MFLAGS ", struct task_struct, thread.mflags);
|
||||
offset("#define THREAD_TRAMP ", struct task_struct, \
|
||||
thread.irix_trampoline);
|
||||
offset("#define THREAD_OLDCTX ", struct task_struct, \
|
||||
|
@ -50,6 +50,7 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
|
||||
cpumask_t effective_mask;
|
||||
int retval;
|
||||
struct task_struct *p;
|
||||
struct thread_info *ti;
|
||||
|
||||
if (len < sizeof(new_mask))
|
||||
return -EINVAL;
|
||||
@ -93,16 +94,16 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
|
||||
read_unlock(&tasklist_lock);
|
||||
|
||||
/* Compute new global allowed CPU set if necessary */
|
||||
if ((p->thread.mflags & MF_FPUBOUND)
|
||||
&& cpus_intersects(new_mask, mt_fpu_cpumask)) {
|
||||
ti = task_thread_info(p);
|
||||
if (test_ti_thread_flag(ti, TIF_FPUBOUND) &&
|
||||
cpus_intersects(new_mask, mt_fpu_cpumask)) {
|
||||
cpus_and(effective_mask, new_mask, mt_fpu_cpumask);
|
||||
retval = set_cpus_allowed(p, effective_mask);
|
||||
} else {
|
||||
p->thread.mflags &= ~MF_FPUBOUND;
|
||||
clear_ti_thread_flag(ti, TIF_FPUBOUND);
|
||||
retval = set_cpus_allowed(p, new_mask);
|
||||
}
|
||||
|
||||
|
||||
out_unlock:
|
||||
put_task_struct(p);
|
||||
unlock_cpu_hotplug();
|
||||
|
@ -77,7 +77,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
|
||||
status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|KU_MASK);
|
||||
#ifdef CONFIG_64BIT
|
||||
status &= ~ST0_FR;
|
||||
status |= (current->thread.mflags & MF_32BIT_REGS) ? 0 : ST0_FR;
|
||||
status |= test_thread_flag(TIF_32BIT_REGS) ? 0 : ST0_FR;
|
||||
#endif
|
||||
status |= KU_USER;
|
||||
regs->cp0_status = status;
|
||||
|
@ -20,11 +20,11 @@
|
||||
#include <linux/mm.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <linux/audit.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/user.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/signal.h>
|
||||
#include <linux/audit.h>
|
||||
#include <linux/seccomp.h>
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/cpu.h>
|
||||
@ -470,12 +470,17 @@ static inline int audit_arch(void)
|
||||
*/
|
||||
asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
|
||||
{
|
||||
/* do the secure computing check first */
|
||||
if (!entryexit)
|
||||
secure_computing(regs->regs[0]);
|
||||
|
||||
if (unlikely(current->audit_context) && entryexit)
|
||||
audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]),
|
||||
regs->regs[2]);
|
||||
|
||||
if (!(current->ptrace & PT_PTRACED))
|
||||
goto out;
|
||||
|
||||
if (!test_thread_flag(TIF_SYSCALL_TRACE))
|
||||
goto out;
|
||||
|
||||
@ -493,9 +498,10 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
|
||||
send_sig(current->exit_code, current, 1);
|
||||
current->exit_code = 0;
|
||||
}
|
||||
out:
|
||||
|
||||
out:
|
||||
if (unlikely(current->audit_context) && !entryexit)
|
||||
audit_syscall_entry(audit_arch(), regs->regs[2],
|
||||
audit_syscall_entry(audit_arch(), regs->regs[0],
|
||||
regs->regs[4], regs->regs[5],
|
||||
regs->regs[6], regs->regs[7]);
|
||||
}
|
||||
|
@ -281,16 +281,24 @@ asmlinkage int sys_set_thread_area(unsigned long addr)
|
||||
|
||||
asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
switch(cmd) {
|
||||
switch (cmd) {
|
||||
case MIPS_ATOMIC_SET:
|
||||
printk(KERN_CRIT "How did I get here?\n");
|
||||
return -EINVAL;
|
||||
|
||||
case MIPS_FIXADE:
|
||||
tmp = current->thread.mflags & ~3;
|
||||
current->thread.mflags = tmp | (arg1 & 3);
|
||||
if (arg1 & ~3)
|
||||
return -EINVAL;
|
||||
|
||||
if (arg1 & 1)
|
||||
set_thread_flag(TIF_FIXADE);
|
||||
else
|
||||
clear_thread_flag(TIF_FIXADE);
|
||||
if (arg1 & 2)
|
||||
set_thread_flag(TIF_LOGADE);
|
||||
else
|
||||
clear_thread_flag(TIF_FIXADE);
|
||||
|
||||
return 0;
|
||||
|
||||
case FLUSH_CACHE:
|
||||
|
@ -775,7 +775,7 @@ static void mt_ase_fp_affinity(void)
|
||||
cpus_and(tmask, current->thread.user_cpus_allowed,
|
||||
mt_fpu_cpumask);
|
||||
set_cpus_allowed(current, tmask);
|
||||
current->thread.mflags |= MF_FPUBOUND;
|
||||
set_thread_flag(TIF_FPUBOUND);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_MIPS_MT_FPAFF */
|
||||
|
@ -524,7 +524,7 @@ asmlinkage void do_ade(struct pt_regs *regs)
|
||||
goto sigbus;
|
||||
|
||||
pc = (unsigned int __user *) exception_epc(regs);
|
||||
if (user_mode(regs) && (current->thread.mflags & MF_FIXADE) == 0)
|
||||
if (user_mode(regs) && !test_thread_flag(TIF_FIXADE))
|
||||
goto sigbus;
|
||||
if (unaligned_action == UNALIGNED_ACTION_SIGNAL)
|
||||
goto sigbus;
|
||||
|
Reference in New Issue
Block a user