summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-08-03 16:35:18 +0000
committertrasz <trasz@FreeBSD.org>2015-08-03 16:35:18 +0000
commitf15074a1857df917230bbf5adab4b7c74621482c (patch)
tree9f9d085852a3e0b4c279c0450e56626cb8df4eac /sys/geom
parentb3cc954757e517fc939e4621cd2f7aa38e33eba7 (diff)
downloadFreeBSD-src-f15074a1857df917230bbf5adab4b7c74621482c.zip
FreeBSD-src-f15074a1857df917230bbf5adab4b7c74621482c.tar.gz
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
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom_dev.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
index 2539e1b..3df7f3e 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -401,6 +401,20 @@ g_dev_close(struct cdev *dev, int flags, int fmt, struct thread *td)
#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;
OpenPOWER on IntegriCloud