Skip to content

Commit 910cd32

Browse files
committed
parisc: Fix and enable seccomp filter support
The seccomp filter support requires careful handling of task registers. This includes reloading of the return value (%r28) and proper syscall exit if secure_computing() returned -1. Additionally we need to sign-extend the syscall number from signed 32bit to signed 64bit in do_syscall_trace_enter() since the ptrace interface only allows storing 32bit values in compat mode. Signed-off-by: Helge Deller <[email protected]> Cc: [email protected] # v4.5
1 parent 4f4acc9 commit 910cd32

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

arch/parisc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ config PARISC
2929
select TTY # Needed for pdc_cons.c
3030
select HAVE_DEBUG_STACKOVERFLOW
3131
select HAVE_ARCH_AUDITSYSCALL
32+
select HAVE_ARCH_SECCOMP_FILTER
3233
select ARCH_NO_COHERENT_DMA_MMAP
3334

3435
help

arch/parisc/include/asm/syscall.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ static inline void syscall_get_arguments(struct task_struct *tsk,
3939
}
4040
}
4141

42+
static inline void syscall_set_return_value(struct task_struct *task,
43+
struct pt_regs *regs,
44+
int error, long val)
45+
{
46+
regs->gr[28] = error ? error : val;
47+
}
48+
49+
static inline void syscall_rollback(struct task_struct *task,
50+
struct pt_regs *regs)
51+
{
52+
/* do nothing */
53+
}
54+
4255
static inline int syscall_get_arch(void)
4356
{
4457
int arch = AUDIT_ARCH_PARISC;

arch/parisc/kernel/ptrace.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
270270
long do_syscall_trace_enter(struct pt_regs *regs)
271271
{
272272
/* Do the secure computing check first. */
273-
secure_computing_strict(regs->gr[20]);
273+
if (secure_computing() == -1)
274+
return -1;
274275

275276
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
276277
tracehook_report_syscall_entry(regs)) {
@@ -296,7 +297,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
296297
regs->gr[23] & 0xffffffff);
297298

298299
out:
299-
return regs->gr[20];
300+
/*
301+
* Sign extend the syscall number to 64bit since it may have been
302+
* modified by a compat ptrace call
303+
*/
304+
return (int) ((u32) regs->gr[20]);
300305
}
301306

302307
void do_syscall_trace_exit(struct pt_regs *regs)

arch/parisc/kernel/syscall.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ tracesys_next:
329329

330330
ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
331331
LDREG TI_TASK(%r1), %r1
332+
LDREG TASK_PT_GR28(%r1), %r28 /* Restore return value */
332333
LDREG TASK_PT_GR26(%r1), %r26 /* Restore the users args */
333334
LDREG TASK_PT_GR25(%r1), %r25
334335
LDREG TASK_PT_GR24(%r1), %r24
@@ -342,6 +343,7 @@ tracesys_next:
342343
stw %r21, -56(%r30) /* 6th argument */
343344
#endif
344345

346+
cmpib,COND(=),n -1,%r20,tracesys_exit /* seccomp may have returned -1 */
345347
comiclr,>>= __NR_Linux_syscalls, %r20, %r0
346348
b,n .Ltracesys_nosys
347349

0 commit comments

Comments
 (0)