Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jul 2016 11:45:54 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r302323 - stable/10/sys/kern
Message-ID:  <201607031145.u63BjsQb029173@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607031145.u63BjsQb029173>