Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Jan 2015 06:48:36 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r276904 - head/sys/kern
Message-ID:  <201501100648.t0A6ma3T055037@svn.freebsd.org>

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



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