Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Dec 2017 13:32:49 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r327060 - stable/10/sys/fs/devfs
Message-ID:  <201712211332.vBLDWn5U051199@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Dec 21 13:32:49 2017
New Revision: 327060
URL: https://svnweb.freebsd.org/changeset/base/327060

Log:
  MFC r326851:
  In devfs_lookupx() dotdot lookup case, avoid dereferencing
  dvp->v_mount after dvp is unlocked.

Modified:
  stable/10/sys/fs/devfs/devfs_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- stable/10/sys/fs/devfs/devfs_vnops.c	Thu Dec 21 13:30:56 2017	(r327059)
+++ stable/10/sys/fs/devfs/devfs_vnops.c	Thu Dec 21 13:32:49 2017	(r327060)
@@ -869,6 +869,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
 	struct devfs_dirent *de, *dd;
 	struct devfs_dirent **dde;
 	struct devfs_mount *dmp;
+	struct mount *mp;
 	struct cdev *cdev;
 	int error, flags, nameiop, dvplocked;
 	char specname[SPECNAMELEN + 1], *pname;
@@ -880,7 +881,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
 	td = cnp->cn_thread;
 	flags = cnp->cn_flags;
 	nameiop = cnp->cn_nameiop;
-	dmp = VFSTODEVFS(dvp->v_mount);
+	mp = dvp->v_mount;
+	dmp = VFSTODEVFS(mp);
 	dd = dvp->v_data;
 	*vpp = NULLVP;
 
@@ -913,8 +915,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
 			return (ENOENT);
 		dvplocked = VOP_ISLOCKED(dvp);
 		VOP_UNLOCK(dvp, 0);
-		error = devfs_allocv(de, dvp->v_mount,
-		    cnp->cn_lkflags & LK_TYPE_MASK, vpp);
+		error = devfs_allocv(de, mp, cnp->cn_lkflags & LK_TYPE_MASK,
+		    vpp);
 		*dm_unlock = 0;
 		vn_lock(dvp, dvplocked | LK_RETRY);
 		return (error);
@@ -999,8 +1001,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
 			return (0);
 		}
 	}
-	error = devfs_allocv(de, dvp->v_mount, cnp->cn_lkflags & LK_TYPE_MASK,
-	    vpp);
+	error = devfs_allocv(de, mp, cnp->cn_lkflags & LK_TYPE_MASK, vpp);
 	*dm_unlock = 0;
 	return (error);
 }



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