diff options
author | 2012-02-15 04:26:27 +0000 | |
---|---|---|
committer | 2012-02-15 04:26:27 +0000 | |
commit | 638f0017823ed0e106d01f08deef215e05f1e560 (patch) | |
tree | cba8201347fdd0e19f16ceee4f173da6d23b9754 /sys/kern/exec_script.c | |
parent | 82571/82572 do not properly set byte enables 2 and 3 on MSI (diff) | |
download | wireguard-openbsd-638f0017823ed0e106d01f08deef215e05f1e560.tar.xz wireguard-openbsd-638f0017823ed0e106d01f08deef215e05f1e560.zip |
Hold struct filedesc's fd_lock when writing to the fd_ofiles, fd_ofileflags,
or fd_{lo,hi}maps members, or when doing a read for a write. Fixes hangs
when an rthreaded processes sleeps while copying the fd table for fork()
and catches another thread with the lock.
ok jsing@ tedu@
Diffstat (limited to 'sys/kern/exec_script.c')
-rw-r--r-- | sys/kern/exec_script.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c index dc1cc381b84..a6d730f8ece 100644 --- a/sys/kern/exec_script.c +++ b/sys/kern/exec_script.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_script.c,v 1.26 2011/07/07 23:45:00 matthew Exp $ */ +/* $OpenBSD: exec_script.c,v 1.27 2012/02/15 04:26:27 guenther Exp $ */ /* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */ /* @@ -187,7 +187,10 @@ check_shell: panic("exec_script_makecmds: epp already has a fd"); #endif - if ((error = falloc(p, &fp, &epp->ep_fd))) + fdplock(p->p_fd); + error = falloc(p, &fp, &epp->ep_fd); + fdpunlock(p->p_fd); + if (error) goto fail; epp->ep_flags |= EXEC_HASFD; @@ -298,7 +301,9 @@ fail: /* kill the opened file descriptor, else close the file */ if (epp->ep_flags & EXEC_HASFD) { epp->ep_flags &= ~EXEC_HASFD; + fdplock(p->p_fd); (void) fdrelease(p, epp->ep_fd); + fdpunlock(p->p_fd); } else vn_close(scriptvp, FREAD, p->p_ucred, p); |