Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Aug 2015 16:35:18 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r286237 - head/sys/geom
Message-ID:  <201508031635.t73GZJ5J096309@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Mon Aug  3 16:35:18 2015
New Revision: 286237
URL: https://svnweb.freebsd.org/changeset/base/286237

Log:
  Fix panic that would happen on forcibly unmounting devfs (note that
  as it is now, devfs ignores MNT_FORCE anyway, so it needs to be modified
  to trigger the panic) with consumers still opened.
  
  Note that this still results in a leak of r/w/e counters.  It seems
  to be harmless, though.  If anyone knows a better way to approach
  this - please tell.
  
  Discussed with:	kib@, mav@
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D3050

Modified:
  head/sys/geom/geom_dev.c

Modified: head/sys/geom/geom_dev.c
==============================================================================
--- head/sys/geom/geom_dev.c	Mon Aug  3 16:30:47 2015	(r286236)
+++ head/sys/geom/geom_dev.c	Mon Aug  3 16:35:18 2015	(r286237)
@@ -401,6 +401,20 @@ g_dev_close(struct cdev *dev, int flags,
 #else
 	e = 0;
 #endif
+
+	/*
+	 * The vgonel(9) - caused by eg. forced unmount of devfs - calls
+	 * VOP_CLOSE(9) on devfs vnode without any FREAD or FWRITE flags,
+	 * which would result in zero deltas, which in turn would cause
+	 * panic in g_access(9).
+	 *
+	 * Note that we cannot zero the counters (ie. do "r = cp->acr"
+	 * etc) instead, because the consumer might be opened in another
+	 * devfs instance.
+	 */
+	if (r + w + e == 0)
+		return (EINVAL);
+
 	sc = cp->private;
 	mtx_lock(&sc->sc_mtx);
 	sc->sc_open += r + w + e;



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