Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Disallow resuming program with PC=0x0 in ptrace(2)
details: https://anonhg.NetBSD.org/src/rev/0154a4491699
branches: trunk
changeset: 998787:0154a4491699
user: kamil <kamil%NetBSD.org@localhost>
date: Wed May 01 17:02:40 2019 +0000
description:
Disallow resuming program with PC=0x0 in ptrace(2)
If the address parameter is 0, report error.
It's a popular mistake to set Program Counter to 0x0.
In certain kernels this is allowable parameter and causes
portability issue.
Disallow explicitly zeroed PC, instead of triggering
a harder to debug crash later.
diffstat:
sys/kern/sys_ptrace_common.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diffs (40 lines):
diff -r 9d522cbff70a -r 0154a4491699 sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c Wed May 01 15:17:49 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c Wed May 01 17:02:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.50 2019/04/30 22:32:01 kamil Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.51 2019/05/01 17:02:40 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.50 2019/04/30 22:32:01 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.51 2019/05/01 17:02:40 kamil Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -1246,6 +1246,21 @@
}
}
+ /*
+ * If the address parameter is 0, report error.
+ *
+ * It's a popular mistake to set Program Counter to 0x0.
+ * In certain kernels this is allowable parameter and causes
+ * portability issue.
+ *
+ * Disallow explicitly zeroed PC, instead of triggering
+ * a harder to debug crash later.
+ */
+ if (addr == 0) {
+ error = EINVAL;
+ break;
+ }
+
/* If the address parameter is not (int *)1, set the pc. */
if ((int *)addr != (int *)1) {
error = process_set_pc(lt, addr);
Home |
Main Index |
Thread Index |
Old Index