summaryrefslogtreecommitdiff
path: root/sys/kern/exec_script.c
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2001-06-15 17:24:19 +0000
committerthorpej <thorpej@NetBSD.org>2001-06-15 17:24:19 +0000
commit7660fd850de3d2d42e873568909551781749012e (patch)
tree0c7d5a2970d79ccace13587980f7030c34583a6d /sys/kern/exec_script.c
parent94c4987ecd64ad37b2d1865fa902b5aaa4e82140 (diff)
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).
Diffstat (limited to 'sys/kern/exec_script.c')
-rw-r--r--sys/kern/exec_script.c11
1 files changed, 7 insertions, 4 deletions
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)