From 7660fd850de3d2d42e873568909551781749012e Mon Sep 17 00:00:00 2001 From: thorpej Date: Fri, 15 Jun 2001 17:24:19 +0000 Subject: In check_exec(), don't bother checking P_TRACED along with MNT_NOSUID, just check MNT_NOSUID to clear the S{U,G}ID bits in the attributes for the vnode we're about to exec. We now check P_TRACED right before we would actually perform the s{u,g}id function in the exec code. This closes a race condition between exec of a setuid binary and ptrace(2). --- sys/kern/exec_script.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sys/kern/exec_script.c') diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c index 51b31aabf9c..0f34d060774 100644 --- a/sys/kern/exec_script.c +++ b/sys/kern/exec_script.c @@ -1,4 +1,4 @@ -/* $NetBSD: exec_script.c,v 1.28 2001/06/14 20:32:47 thorpej Exp $ */ +/* $NetBSD: exec_script.c,v 1.29 2001/06/15 17:24:19 thorpej Exp $ */ /* * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou @@ -143,8 +143,9 @@ exec_script_makecmds(struct proc *p, struct exec_package *epp) check_shell: #ifdef SETUIDSCRIPTS /* - * MNT_NOSUID and STRC are already taken care of by check_exec, - * so we don't need to worry about them now or later. + * MNT_NOSUID has already taken care of by check_exec, + * so we don't need to worry about it now or later. We + * will need to check P_TRACED later, however. */ script_sbits = epp->ep_vap->va_mode & (S_ISUID | S_ISGID); if (script_sbits != 0) { @@ -260,7 +261,9 @@ check_shell: #ifdef SETUIDSCRIPTS /* * set thing up so that set-id scripts will be - * handled appropriately + * handled appropriately. P_TRACED will be + * checked later when the shell is actually + * exec'd. */ epp->ep_vap->va_mode |= script_sbits; if (script_sbits & S_ISUID) -- cgit