svn commit: r302323 - stable/10/sys/kern
Jilles Tjoelker
jilles at FreeBSD.org
Sun Jul 3 11:45:55 UTC 2016
Author: jilles
Date: Sun Jul 3 11:45:54 2016
New Revision: 302323
URL: https://svnweb.freebsd.org/changeset/base/302323
Log:
MFC r302151: posixshm: Fix lock leak when mac_posixshm_check_read rejects
read.
While reading the code, I noticed that shm_read() returns without unlocking
foffset and rangelock if mac_posixshm_check_read() rejects the read.
Modified:
stable/10/sys/kern/uipc_shm.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/kern/uipc_shm.c
==============================================================================
--- stable/10/sys/kern/uipc_shm.c Sun Jul 3 01:56:48 2016 (r302322)
+++ stable/10/sys/kern/uipc_shm.c Sun Jul 3 11:45:54 2016 (r302323)
@@ -293,14 +293,14 @@ shm_read(struct file *fp, struct uio *ui
int error;
shmfd = fp->f_data;
- foffset_lock_uio(fp, uio, flags);
- rl_cookie = rangelock_rlock(&shmfd->shm_rl, uio->uio_offset,
- uio->uio_offset + uio->uio_resid, &shmfd->shm_mtx);
#ifdef MAC
error = mac_posixshm_check_read(active_cred, fp->f_cred, shmfd);
if (error)
return (error);
#endif
+ foffset_lock_uio(fp, uio, flags);
+ rl_cookie = rangelock_rlock(&shmfd->shm_rl, uio->uio_offset,
+ uio->uio_offset + uio->uio_resid, &shmfd->shm_mtx);
error = uiomove_object(shmfd->shm_object, shmfd->shm_size, uio);
rangelock_unlock(&shmfd->shm_rl, rl_cookie, &shmfd->shm_mtx);
foffset_unlock_uio(fp, uio, flags);
More information about the svn-src-stable-10
mailing list