Module Name:    src
Committed By:   kamil
Date:           Thu Oct  3 23:11:11 UTC 2019

Modified Files:
        src/sys/kern: sys_ptrace_common.c

Log Message:
Add two KASSERTS in the ptrace(2) kernel code

Verify that we will never return empty ptrace_state for CHILD/LWP event.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/sys_ptrace_common.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.62 src/sys/kern/sys_ptrace_common.c:1.63
--- src/sys/kern/sys_ptrace_common.c:1.62	Thu Oct  3 22:48:44 2019
+++ src/sys/kern/sys_ptrace_common.c	Thu Oct  3 23:11:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.62 2019/10/03 22:48:44 kamil Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.63 2019/10/03 23:11:11 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.62 2019/10/03 22:48:44 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.63 2019/10/03 23:11:11 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -702,6 +702,10 @@ ptrace_get_process_state(struct proc *t,
 		memset(&ps, 0, sizeof(ps));
 	} else {
 		si = &t->p_sigctx.ps_info;
+
+		KASSERT(si->_reason._ptrace_state._pe_report_event > 0);
+		KASSERT(si->_reason._ptrace_state._option._pe_other_pid > 0);
+
 		ps.pe_report_event = si->_reason._ptrace_state._pe_report_event;
 
 		CTASSERT(sizeof(ps.pe_other_pid) == sizeof(ps.pe_lwp));

Reply via email to