Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Dec 2019 01:32:15 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r355894 - stable/12/sys/geom
Message-ID:  <201912190132.xBJ1WFLW042831@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Dec 19 01:32:15 2019
New Revision: 355894
URL: https://svnweb.freebsd.org/changeset/base/355894

Log:
  MFC r355438: Block ioctls for dying GEOM_DEV instances.
  
  For normal I/Os consumer and provider statuses are checked by g_io_check().
  But ioctl calls often do not go through it, being dispatched directly. This
  change makes their semantics more alike, protecting lower levels.

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

Modified: stable/12/sys/geom/geom_dev.c
==============================================================================
--- stable/12/sys/geom/geom_dev.c	Thu Dec 19 01:30:29 2019	(r355893)
+++ stable/12/sys/geom/geom_dev.c	Thu Dec 19 01:32:15 2019	(r355894)
@@ -489,12 +489,6 @@ g_dev_close(struct cdev *dev, int flags, int fmt, stru
 	return (error);
 }
 
-/*
- * XXX: Until we have unmessed the ioctl situation, there is a race against
- * XXX: a concurrent orphanization.  We cannot close it by holding topology
- * XXX: since that would prevent us from doing our job, and stalling events
- * XXX: will break (actually: stall) the BSD disklabel hacks.
- */
 static int
 g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
 {
@@ -506,6 +500,12 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data
 	cp = dev->si_drv2;
 	pp = cp->provider;
 
+	/* If consumer or provider is dying, don't disturb. */
+	if (cp->flags & G_CF_ORPHAN)
+		return (ENXIO);
+	if (pp->error)
+		return (pp->error);
+
 	error = 0;
 	KASSERT(cp->acr || cp->acw,
 	    ("Consumer with zero access count in g_dev_ioctl"));
@@ -628,8 +628,6 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data
 		error = g_io_getattr("GEOM::ident", cp, &i, data);
 		break;
 	case DIOCGPROVIDERNAME:
-		if (pp == NULL)
-			return (ENOENT);
 		strlcpy(data, pp->name, i);
 		break;
 	case DIOCGSTRIPESIZE:



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