Author: trasz
Date: Sun Oct 18 14:34:13 2015
New Revision: 289511
URL: https://svnweb.freebsd.org/changeset/base/289511

Log:
  MFC r286237:
  
  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.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/sys/geom/geom_dev.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/geom/geom_dev.c
==============================================================================
--- stable/10/sys/geom/geom_dev.c       Sun Oct 18 14:31:54 2015        
(r289510)
+++ stable/10/sys/geom/geom_dev.c       Sun Oct 18 14:34:13 2015        
(r289511)
@@ -399,6 +399,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;
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to