[RFC PATCH 1/3] seccomp: Don't allow tracers to abuse RET_TRACE

From: Will Drewry
Date: Thu May 24 2012 - 12:10:27 EST


Ensure that consumers of the PTRACE_EVENT_SECCOMP notification
cannot change the system call number for the traced task
without it resulting in the system call being skipped.

Traditionally, tracers will set the system call number to
-1 to skip the system call. This behavior will work as expected
but the tracer will be unable to remap the system call to a valid
system call after the seccomp policy has been evaluated.

Signed-off-by: Will Drewry <wad@xxxxxxxxxxxx>
---
kernel/seccomp.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index ee376be..33f0ad6 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -425,6 +425,10 @@ int __secure_computing(int this_syscall)
*/
if (fatal_signal_pending(current))
break;
+ /* Skip the system call if the tracer changed it. */
+ if (this_syscall !=
+ syscall_get_nr(current, task_pt_regs(current)))
+ goto skip;
return 0;
case SECCOMP_RET_ALLOW:
return 0;
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/