aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2007-07-25 11:19:33 -0400
committerRalf Baechle <ralf@linux-mips.org>2007-07-31 16:35:21 -0400
commit293c5bd13f124c325f74f89ad26edf5612ce7235 (patch)
tree6de7ce919a10c58e29093776c02e61d7127ed12b /arch/mips
parent01754bbc692929e446e600f69b41013e554399a6 (diff)
[MIPS] Fixup secure computing stuff.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/mips/kernel/asm-offsets.c1
-rw-r--r--arch/mips/kernel/mips-mt-fpaff.c9
-rw-r--r--arch/mips/kernel/process.c2
-rw-r--r--arch/mips/kernel/ptrace.c14
-rw-r--r--arch/mips/kernel/syscall.c18
-rw-r--r--arch/mips/kernel/traps.c2
-rw-r--r--arch/mips/kernel/unaligned.c2
8 files changed, 32 insertions, 18 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1e3aeccd7322..410b9d185739 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1772,7 +1772,7 @@ config KEXEC
1772 1772
1773config SECCOMP 1773config SECCOMP
1774 bool "Enable seccomp to safely compute untrusted bytecode" 1774 bool "Enable seccomp to safely compute untrusted bytecode"
1775 depends on PROC_FS && BROKEN 1775 depends on PROC_FS
1776 default y 1776 default y
1777 help 1777 help
1778 This kernel feature is useful for number crunching applications 1778 This kernel feature is useful for number crunching applications
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index 3b27309d54b1..013327286c26 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -132,7 +132,6 @@ void output_thread_defines(void)
132 offset("#define THREAD_ECODE ", struct task_struct, \ 132 offset("#define THREAD_ECODE ", struct task_struct, \
133 thread.error_code); 133 thread.error_code);
134 offset("#define THREAD_TRAPNO ", struct task_struct, thread.trap_no); 134 offset("#define THREAD_TRAPNO ", struct task_struct, thread.trap_no);
135 offset("#define THREAD_MFLAGS ", struct task_struct, thread.mflags);
136 offset("#define THREAD_TRAMP ", struct task_struct, \ 135 offset("#define THREAD_TRAMP ", struct task_struct, \
137 thread.irix_trampoline); 136 thread.irix_trampoline);
138 offset("#define THREAD_OLDCTX ", struct task_struct, \ 137 offset("#define THREAD_OLDCTX ", struct task_struct, \
diff --git a/arch/mips/kernel/mips-mt-fpaff.c b/arch/mips/kernel/mips-mt-fpaff.c
index ede5d73d652e..892665bb12b1 100644
--- a/arch/mips/kernel/mips-mt-fpaff.c
+++ b/arch/mips/kernel/mips-mt-fpaff.c
@@ -50,6 +50,7 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
50 cpumask_t effective_mask; 50 cpumask_t effective_mask;
51 int retval; 51 int retval;
52 struct task_struct *p; 52 struct task_struct *p;
53 struct thread_info *ti;
53 54
54 if (len < sizeof(new_mask)) 55 if (len < sizeof(new_mask))
55 return -EINVAL; 56 return -EINVAL;
@@ -93,16 +94,16 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
93 read_unlock(&tasklist_lock); 94 read_unlock(&tasklist_lock);
94 95
95 /* Compute new global allowed CPU set if necessary */ 96 /* Compute new global allowed CPU set if necessary */
96 if ((p->thread.mflags & MF_FPUBOUND) 97 ti = task_thread_info(p);
97 && cpus_intersects(new_mask, mt_fpu_cpumask)) { 98 if (test_ti_thread_flag(ti, TIF_FPUBOUND) &&
99 cpus_intersects(new_mask, mt_fpu_cpumask)) {
98 cpus_and(effective_mask, new_mask, mt_fpu_cpumask); 100 cpus_and(effective_mask, new_mask, mt_fpu_cpumask);
99 retval = set_cpus_allowed(p, effective_mask); 101 retval = set_cpus_allowed(p, effective_mask);
100 } else { 102 } else {
101 p->thread.mflags &= ~MF_FPUBOUND; 103 clear_ti_thread_flag(ti, TIF_FPUBOUND);
102 retval = set_cpus_allowed(p, new_mask); 104 retval = set_cpus_allowed(p, new_mask);
103 } 105 }
104 106
105
106out_unlock: 107out_unlock:
107 put_task_struct(p); 108 put_task_struct(p);
108 unlock_cpu_hotplug(); 109 unlock_cpu_hotplug();
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index bd05f5a927ea..e6ce943099a0 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -77,7 +77,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
77 status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|KU_MASK); 77 status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|KU_MASK);
78#ifdef CONFIG_64BIT 78#ifdef CONFIG_64BIT
79 status &= ~ST0_FR; 79 status &= ~ST0_FR;
80 status |= (current->thread.mflags & MF_32BIT_REGS) ? 0 : ST0_FR; 80 status |= test_thread_flag(TIF_32BIT_REGS) ? 0 : ST0_FR;
81#endif 81#endif
82 status |= KU_USER; 82 status |= KU_USER;
83 regs->cp0_status = status; 83 regs->cp0_status = status;
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 893e7bccf226..bbd57b20b43e 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -20,11 +20,11 @@
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/ptrace.h> 22#include <linux/ptrace.h>
23#include <linux/audit.h>
24#include <linux/smp.h> 23#include <linux/smp.h>
25#include <linux/user.h> 24#include <linux/user.h>
26#include <linux/security.h> 25#include <linux/security.h>
27#include <linux/signal.h> 26#include <linux/audit.h>
27#include <linux/seccomp.h>
28 28
29#include <asm/byteorder.h> 29#include <asm/byteorder.h>
30#include <asm/cpu.h> 30#include <asm/cpu.h>
@@ -470,12 +470,17 @@ static inline int audit_arch(void)
470 */ 470 */
471asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) 471asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
472{ 472{
473 /* do the secure computing check first */
474 if (!entryexit)
475 secure_computing(regs->regs[0]);
476
473 if (unlikely(current->audit_context) && entryexit) 477 if (unlikely(current->audit_context) && entryexit)
474 audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]), 478 audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]),
475 regs->regs[2]); 479 regs->regs[2]);
476 480
477 if (!(current->ptrace & PT_PTRACED)) 481 if (!(current->ptrace & PT_PTRACED))
478 goto out; 482 goto out;
483
479 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 484 if (!test_thread_flag(TIF_SYSCALL_TRACE))
480 goto out; 485 goto out;
481 486
@@ -493,9 +498,10 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
493 send_sig(current->exit_code, current, 1); 498 send_sig(current->exit_code, current, 1);
494 current->exit_code = 0; 499 current->exit_code = 0;
495 } 500 }
496 out: 501
502out:
497 if (unlikely(current->audit_context) && !entryexit) 503 if (unlikely(current->audit_context) && !entryexit)
498 audit_syscall_entry(audit_arch(), regs->regs[2], 504 audit_syscall_entry(audit_arch(), regs->regs[0],
499 regs->regs[4], regs->regs[5], 505 regs->regs[4], regs->regs[5],
500 regs->regs[6], regs->regs[7]); 506 regs->regs[6], regs->regs[7]);
501} 507}
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 541b5005957e..7c800ec3ff55 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -281,16 +281,24 @@ asmlinkage int sys_set_thread_area(unsigned long addr)
281 281
282asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3) 282asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
283{ 283{
284 int tmp; 284 switch (cmd) {
285
286 switch(cmd) {
287 case MIPS_ATOMIC_SET: 285 case MIPS_ATOMIC_SET:
288 printk(KERN_CRIT "How did I get here?\n"); 286 printk(KERN_CRIT "How did I get here?\n");
289 return -EINVAL; 287 return -EINVAL;
290 288
291 case MIPS_FIXADE: 289 case MIPS_FIXADE:
292 tmp = current->thread.mflags & ~3; 290 if (arg1 & ~3)
293 current->thread.mflags = tmp | (arg1 & 3); 291 return -EINVAL;
292
293 if (arg1 & 1)
294 set_thread_flag(TIF_FIXADE);
295 else
296 clear_thread_flag(TIF_FIXADE);
297 if (arg1 & 2)
298 set_thread_flag(TIF_LOGADE);
299 else
300 clear_thread_flag(TIF_FIXADE);
301
294 return 0; 302 return 0;
295 303
296 case FLUSH_CACHE: 304 case FLUSH_CACHE:
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index ce277cb34dd0..c8e291c83057 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -775,7 +775,7 @@ static void mt_ase_fp_affinity(void)
775 cpus_and(tmask, current->thread.user_cpus_allowed, 775 cpus_and(tmask, current->thread.user_cpus_allowed,
776 mt_fpu_cpumask); 776 mt_fpu_cpumask);
777 set_cpus_allowed(current, tmask); 777 set_cpus_allowed(current, tmask);
778 current->thread.mflags |= MF_FPUBOUND; 778 set_thread_flag(TIF_FPUBOUND);
779 } 779 }
780 } 780 }
781#endif /* CONFIG_MIPS_MT_FPAFF */ 781#endif /* CONFIG_MIPS_MT_FPAFF */
diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c
index 8b9c34ffae18..5565b89b98e6 100644
--- a/arch/mips/kernel/unaligned.c
+++ b/arch/mips/kernel/unaligned.c
@@ -524,7 +524,7 @@ asmlinkage void do_ade(struct pt_regs *regs)
524 goto sigbus; 524 goto sigbus;
525 525
526 pc = (unsigned int __user *) exception_epc(regs); 526 pc = (unsigned int __user *) exception_epc(regs);
527 if (user_mode(regs) && (current->thread.mflags & MF_FIXADE) == 0) 527 if (user_mode(regs) && !test_thread_flag(TIF_FIXADE))
528 goto sigbus; 528 goto sigbus;
529 if (unaligned_action == UNALIGNED_ACTION_SIGNAL) 529 if (unaligned_action == UNALIGNED_ACTION_SIGNAL)
530 goto sigbus; 530 goto sigbus;