Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Sep 2009 22:41:43 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Bruce Cran <bruce@cran.org.uk>
Cc:        bzeeb+freebsd+lor@zabbadoz.net, current@freebsd.org
Subject:   Re: LOR: kern_exec.c and vfs_cache.c
Message-ID:  <20090905194142.GE47688@deviant.kiev.zoral.com.ua>
In-Reply-To: <20090905195913.0000358e@unknown>
References:  <20090905195913.0000358e@unknown>

next in thread | previous in thread | raw e-mail | index | archive | help

--ZRyEpB+iJ+qUx0kp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Sep 05, 2009 at 07:59:13PM +0100, Bruce Cran wrote:
> I got this LOR on 8.0-BETA3 when running pmcstat:
>=20
> lock order reversal:
>  1st 0xc55716a0 ufs (ufs) @ /usr/src/sys/kern/kern_exec.c:570
>  2nd 0xc98f5a2c filedesc structure (filedesc structure)
> @ /usr/src/sys/kern/vfs_cache.c:999 KDB: stack backtrace:
> db_trace_self_wrapper(c0c6be4a,e6b5494c,c08bd7f5,c08ae67b,c0c6ed1d,...)
> at db_trace_self_wrapper+0x26
> kdb_backtrace(c08ae67b,c0c6ed1d,c452f500,c452c1d0,e6b549a8,...) at
> kdb_backtrace+0x29
> _witness_debugger(c0c6ed1d,c98f5a2c,c0c638c6,c452c1d0,c0c74e88,...) at
> _witness_debugger+0x25
> witness_checkorder(c98f5a2c,1,c0c74e88,3e7,0,...) at
> witness_checkorder+0x839
> _sx_slock(c98f5a2c,0,c0c74e88,3e7,c497a6c0,...) at _sx_slock+0x85
> vn_fullpath(c497a6c0,c5571648,e6b54aa4,e6b54aa0,0,...) at
> vn_fullpath+0x74 pmc_getfilename(c0c60fc0,3,c497a6c0,e6b54a60,246,...)
> at pmc_getfilename+0x2e
> pmc_hook_handler(c497a6c0,1,e6b54c1c,318,c0c90edb,...) at
> pmc_hook_handler+0x279
> kern_execve(c497a6c0,e6b54c58,0,283052a8,28305348,e164d000,e164d000,e164d=
020,e164d485,e168d000,3fb7b,3,24,0)
> at kern_execve+0xe1c execve(c497a6c0,e6b54cfc,c,c497a6c0,c0d4e474,...)
> at execve+0x4c syscall(e6b54d38) at syscall+0x2a3 Xint0x80_syscall() at
> Xint0x80_syscall+0x20 --- syscall (59, FreeBSD ELF32, execve), eip =3D
> 0x28173eaf, esp =3D 0xbfbfe34c, ebp =3D 0xbfbfe378 ---

The following should fix the LOR and make vfs_mark_atime more resistent
to the supplied doomed vnode.

diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index e770d07..a90968f 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -786,10 +786,12 @@ interpret:
 	 */
 	if (PMC_SYSTEM_SAMPLING_ACTIVE() || PMC_PROC_IS_USING_PMCS(p)) {
 		PROC_UNLOCK(p);
+		VOP_UNLOCK(imgp->vp, 0);
 		pe.pm_credentialschanged =3D credential_changing;
 		pe.pm_entryaddr =3D imgp->entry_addr;
=20
 		PMC_CALL_HOOK_X(td, PMC_FN_PROCESS_EXEC, (void *) &pe);
+		vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
 	} else
 		PROC_UNLOCK(p);
 #else  /* !HWPMC_HOOKS */
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 3beb881..f3ec565 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -4269,8 +4269,12 @@ vfs_read_dirent(struct vop_readdir_args *ap, struct =
dirent *dp, off_t off)
 void
 vfs_mark_atime(struct vnode *vp, struct ucred *cred)
 {
+	struct mount *mp;
=20
-	if ((vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) =3D=3D 0)
+	mp =3D vp->v_mount;
+	VFS_ASSERT_GIANT(mp);
+	ASSERT_VOP_LOCKED(vp, "vfs_mark_atime");
+	if (mp !=3D NULL && (mp->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) =3D=3D 0)
 		(void)VOP_MARKATIME(vp);
 }
=20

--ZRyEpB+iJ+qUx0kp
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAkqivvUACgkQC3+MBN1Mb4gBDACggJevpaxLVWcwmCzono0FYd3H
GEUAn3jOvxujCLQ9F+wFAqtvbCluP7+O
=9i/D
-----END PGP SIGNATURE-----

--ZRyEpB+iJ+qUx0kp--



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