mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-13 10:02:38 +00:00
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. Reviewed by: kib, jhb, rwatson Approved by: re (gjb) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6927
This commit is contained in:
parent
a02e196edd
commit
6ea906eec0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302151
@ -295,14 +295,14 @@ shm_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user