summaryrefslogtreecommitdiff
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-01-20 11:27:53 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-01-20 11:27:53 +0000
commitb1debdf727116f16170aa85959010013dd34583e (patch)
treeb2f6cee252eb75c2e5b8874177dcccb398a63941 /sys/kern/kern_exec.c
parent5553da18201980ea91c0445a3120d60334ec5ae5 (diff)
When a process is exec:ing mark it with a flag. Check that flag in ptrace
and procfs (and possibly more places in the future) and simply refuse to fiddle with the execing process. This is an ugly hack, but this far we haven't been successful in creating a race-free exec.
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 6bec610b8e2..b8b6b6d479a 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.62 2001/12/19 08:58:06 art Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.63 2002/01/20 11:27:52 art Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -250,6 +250,12 @@ sys_execve(p, v, retval)
extern struct emul emul_native;
/*
+ * Cheap solution to complicated problems.
+ * Mark this process as "leave me alone, I'm execing".
+ */
+ p->p_flag |= P_INEXEC;
+
+ /*
* figure out the maximum size of an exec header, if necessary.
* XXX should be able to keep LKM code from modifying exec switch
* when we're still using it, but...
@@ -614,6 +620,7 @@ sys_execve(p, v, retval)
if (KTRPOINT(p, KTR_EMUL))
ktremul(p, p->p_emul->e_name);
#endif
+ p->p_flag &= ~P_INEXEC;
return (0);
bad:
@@ -632,6 +639,7 @@ bad:
freehdr:
free(pack.ep_hdr, M_EXEC);
+ p->p_flag &= ~P_INEXEC;
return (error);
exec_abort:
@@ -655,6 +663,7 @@ free_pack_abort:
exit1(p, -1);
/* NOTREACHED */
+ p->p_flag &= ~P_INEXEC;
return (0);
}