From owner-freebsd-current@FreeBSD.ORG Sat Sep 5 19:41:51 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7FE681065670 for ; Sat, 5 Sep 2009 19:41:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by mx1.freebsd.org (Postfix) with ESMTP id 180E98FC0A for ; Sat, 5 Sep 2009 19:41:50 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n85Jfhr5014189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 Sep 2009 22:41:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n85JfhaP000786; Sat, 5 Sep 2009 22:41:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n85JfhcM000785; Sat, 5 Sep 2009 22:41:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 5 Sep 2009 22:41:43 +0300 From: Kostik Belousov To: Bruce Cran Message-ID: <20090905194142.GE47688@deviant.kiev.zoral.com.ua> References: <20090905195913.0000358e@unknown> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZRyEpB+iJ+qUx0kp" Content-Disposition: inline In-Reply-To: <20090905195913.0000358e@unknown> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: bzeeb+freebsd+lor@zabbadoz.net, current@freebsd.org Subject: Re: LOR: kern_exec.c and vfs_cache.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 19:41:51 -0000 --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--