svn commit: r276904 - head/sys/kern

Xin LI delphij at FreeBSD.org
Sat Jan 10 06:48:37 UTC 2015


Author: delphij
Date: Sat Jan 10 06:48:35 2015
New Revision: 276904
URL: https://svnweb.freebsd.org/changeset/base/276904

Log:
  Improve style and fix a possible use-after-free case introduced in r268384
  by reinitializing the 'freestate' pointer after freeing the memory.
  
  Obtained from:	HardenedBSD (71fab80c5dd3034b71a29a61064625018671bbeb)
  PR:		194525
  Submitted by:	Oliver Pinter <oliver.pinter at hardenedbsd.org>
  MFC after:	2 weeks

Modified:
  head/sys/kern/kern_lockf.c

Modified: head/sys/kern/kern_lockf.c
==============================================================================
--- head/sys/kern/kern_lockf.c	Sat Jan 10 03:29:17 2015	(r276903)
+++ head/sys/kern/kern_lockf.c	Sat Jan 10 06:48:35 2015	(r276904)
@@ -740,12 +740,13 @@ retry_setlock:
 
 	VI_UNLOCK(vp);
 
-	if (freestate) {
+	if (freestate != NULL) {
 		sx_xlock(&lf_lock_states_lock);
 		LIST_REMOVE(freestate, ls_link);
 		sx_xunlock(&lf_lock_states_lock);
 		sx_destroy(&freestate->ls_lock);
 		free(freestate, M_LOCKF);
+		freestate = NULL;
 	}
 
 	if (error == EDOOFUS) {


More information about the svn-src-all mailing list