summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-12-27 08:39:42 +0000
committeralfred <alfred@FreeBSD.org>2002-12-27 08:39:42 +0000
commit8c99fb48c77891dd9847117ad025ce08215e71fd (patch)
tree9fa9515089ff35c1dc1c7689aa6b80fb8dd5f152
parentbaa27ec2ab63c9f960ba6639448d4dbc4ec095ba (diff)
downloadFreeBSD-src-8c99fb48c77891dd9847117ad025ce08215e71fd.zip
FreeBSD-src-8c99fb48c77891dd9847117ad025ce08215e71fd.tar.gz
Lock filedesc while performing a range check on the file descriptor.
Reviewed by: alc
-rw-r--r--sys/kern/vfs_aio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 9fde837..45b25fc 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -1326,8 +1326,10 @@ _aio_aqueue(struct thread *td, struct aiocb *job, struct aio_liojob *lj, int typ
/*
* Range check file descriptor.
*/
+ FILEDESC_LOCK(fdp);
fd = aiocbe->uaiocb.aio_fildes;
if (fd >= fdp->fd_nfiles) {
+ FILEDESC_UNLOCK(fdp);
uma_zfree(aiocb_zone, aiocbe);
if (type == 0)
suword(&job->_aiocb_private.error, EBADF);
@@ -1337,12 +1339,14 @@ _aio_aqueue(struct thread *td, struct aiocb *job, struct aio_liojob *lj, int typ
fp = aiocbe->fd_file = fdp->fd_ofiles[fd];
if ((fp == NULL) || ((opcode == LIO_WRITE) && ((fp->f_flag & FWRITE) ==
0))) {
+ FILEDESC_UNLOCK(fdp);
uma_zfree(aiocb_zone, aiocbe);
if (type == 0)
suword(&job->_aiocb_private.error, EBADF);
return EBADF;
}
fhold(fp);
+ FILEDESC_UNLOCK(fdp);
if (aiocbe->uaiocb.aio_offset == -1LL) {
error = EINVAL;
OpenPOWER on IntegriCloud