From 3052b5a9494e8e8aff670164f197ecbb72bfe1cc Mon Sep 17 00:00:00 2001 From: tls Date: Wed, 15 May 1996 06:17:47 +0000 Subject: [PATCH] fix obscure problem involving ptrace of init --- sys/kern/sys_process.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index cc0de581a311..d25180a2d48e 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_process.c,v 1.54 1996/02/09 19:00:14 christos Exp $ */ +/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- * Copyright (c) 1994 Christopher G. Demetriou. All rights reserved. @@ -96,6 +96,7 @@ sys_ptrace(p, v, retval) if (SCARG(uap, req) == PT_TRACE_ME) t = p; else { + /* Find the process we're supposed to be operating on. */ if ((t = pfind(SCARG(uap, pid))) == NULL) return (ESRCH); @@ -123,12 +124,21 @@ sys_ptrace(p, v, retval) /* * (3) it's not owned by you, or is set-id on exec - * (unless you're root). + * (unless you're root), or... */ if ((t->p_cred->p_ruid != p->p_cred->p_ruid || ISSET(t->p_flag, P_SUGID)) && (error = suser(p->p_ucred, &p->p_acflag)) != 0) return (error); + + /* + * (4) ...it's init, which controls the security level + * of the entire system, and the system was not + * compiled with permanently insecure mode turned + * on. + */ + if ((t->p_pid == 1) && (securelevel > -1)) + return (EPERM); break; case PT_READ_I: