From b1debdf727116f16170aa85959010013dd34583e Mon Sep 17 00:00:00 2001 From: Artur Grabowski Date: Sun, 20 Jan 2002 11:27:53 +0000 Subject: 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. --- sys/kern/kern_exec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sys/kern/kern_exec.c') 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 $ */ /*- @@ -249,6 +249,12 @@ sys_execve(p, v, retval) int szsigcode; 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 @@ -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); } -- cgit v1.2.3