Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Sep 2020 00:26:04 +0000 (UTC)
From:      Chuck Silvers <chs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r365351 - head/sys/kern
Message-ID:  <202009050026.0850Q4Gk023051@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: chs
Date: Sat Sep  5 00:26:03 2020
New Revision: 365351
URL: https://svnweb.freebsd.org/changeset/base/365351

Log:
  vfs: avoid exposing partially constructed vnodes
  
  If multiple threads race calling vfs_hash_insert() while creating vnodes
  with the same identity, all of the vnodes which lose the race must be
  destroyed before any other thread can see them. Previously this was
  accomplished by the vput() in vfs_hash_insert() resulting in the vnode's
  VOP_INACTIVE() method calling vgone() before the vnode lock was unlocked,
  but at some point changes to the the vnode refcount/inactive logic have caused
  that to no longer work, leading to crashes, so instead vfs_hash_insert()
  must call vgone() itself before calling vput() on vnodes which lose the race.
  
  Reviewed by:	mjg, kib
  Sponsored by:	Netflix
  Differential Revision:	https://reviews.freebsd.org/D26291

Modified:
  head/sys/kern/vfs_hash.c

Modified: head/sys/kern/vfs_hash.c
==============================================================================
--- head/sys/kern/vfs_hash.c	Sat Sep  5 00:20:32 2020	(r365350)
+++ head/sys/kern/vfs_hash.c	Sat Sep  5 00:26:03 2020	(r365351)
@@ -172,6 +172,7 @@ vfs_hash_insert(struct vnode *vp, u_int hash, int flag
 			rw_wlock(&vfs_hash_lock);
 			LIST_INSERT_HEAD(&vfs_hash_side, vp, v_hashlist);
 			rw_wunlock(&vfs_hash_lock);
+			vgone(vp);
 			vput(vp);
 			if (!error)
 				*vpp = vp2;



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