diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-02-15 04:26:28 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-02-15 04:26:28 +0000 |
commit | b861cd7b54c3de28426491f9752a022262f3dc88 (patch) | |
tree | 1d33033d095b99ded617a883d8dd5c8770958218 /sys/crypto | |
parent | 9db6da3ecdf09727884dc8eb4e22146c7707b98b (diff) |
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/crypto')
-rw-r--r-- | sys/crypto/cryptodev.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/crypto/cryptodev.c b/sys/crypto/cryptodev.c index d502f3dde9c..a6fd1be0ccb 100644 --- a/sys/crypto/cryptodev.c +++ b/sys/crypto/cryptodev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptodev.c,v 1.77 2011/01/11 16:06:40 deraadt Exp $ */ +/* $OpenBSD: cryptodev.c,v 1.78 2012/02/15 04:26:27 guenther Exp $ */ /* * Copyright (c) 2001 Theo de Raadt @@ -34,6 +34,7 @@ #include <sys/systm.h> #include <sys/malloc.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/file.h> #include <sys/filedesc.h> #include <sys/errno.h> @@ -666,7 +667,9 @@ cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) TAILQ_INIT(&fcr->csessions); fcr->sesn = 0; + fdplock(p->p_fd); error = falloc(p, &f, &fd); + fdpunlock(p->p_fd); if (error) { free(fcr, M_XDATA); return (error); |