diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index ee376beedaf96ca31cc3066d06cedf59a552290f..6290f6f79c457f103810ab041d1966afd6a26700 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -413,8 +413,12 @@ int __secure_computing(int this_syscall)
 			goto skip;
 		case SECCOMP_RET_TRACE:
 			/* Skip these calls if there is no tracer. */
-			if (!ptrace_event_enabled(current, PTRACE_EVENT_SECCOMP))
+			if (!ptrace_event_enabled(current, PTRACE_EVENT_SECCOMP)) {
+				/* Make sure userspace sees an ENOSYS. */
+				syscall_set_return_value(current,
+					task_pt_regs(current), -ENOSYS, 0);
 				goto skip;
+			}
 			/* Allow the BPF to provide the event message */
 			ptrace_event(PTRACE_EVENT_SECCOMP, data);
 			/*