Authentication-Results: name.execsw.org; dkim=pass (1024-bit key) header.d=netbsd.org header.i=@netbsd.org header.b=eZWLEm8p; dkim=fail reason="signature verification failed" (1024-bit key) header.d=netbsd.org header.i=@netbsd.org header.b=I2GtVwz8 Received: by mail.netbsd.org (Postfix, from userid 605) id 97A6384F47; Thu, 18 Apr 2024 18:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1713464532; bh=w43Z3R+yYBrpOPXgyRyFAx0ZV9w98XTe8M5pYKBbqX8=; h=Date:From:Subject:To:List-Id:Reply-To:List-Unsubscribe; b=eZWLEm8p5FQEASrvjMG9EXvtnY1WxKMj0ljgIZ7oC0QhY4fmMyxFpw3SYrQ1NUZy/ dhSAgKO+wJfWBOBLSA7Jab9ZUFDnJOoVCjl0pB2W0tbvdxtH+GorBwAOO+eBbTUBVm WixSWAsl6olrHzfH5+nHsi1yuPOFgV+iTvxPQ6as= Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 7DE5084F44 for ; Thu, 18 Apr 2024 18:22:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Authentication-Results: mail.netbsd.org (amavisd-new); dkim=pass (1024-bit key) header.d=netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id RPUomqvfVwcO for ; Thu, 18 Apr 2024 18:22:11 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id E7E6E84CE2 for ; Thu, 18 Apr 2024 18:22:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1713464531; bh=w43Z3R+yYBrpOPXgyRyFAx0ZV9w98XTe8M5pYKBbqX8=; h=Date:From:Subject:To:Reply-To; b=I2GtVwz8+CZHC0z/x2hyxtnR8f59X7X2fQi/NGeKmVBkvi0ENCwnkMKEUyUmlRDe+ R6XGlHXjhDhraYzXcvL2fx505B28aolT9nRDV3ncjUIDuIE3QP2paDz8/I7m/uUGf3 V4OhSYBVO9VBmJpAXfL/RvmZHFwLfCRZKIfpJ1tc= Received: by cvs.NetBSD.org (Postfix, from userid 500) id DACF9FA2C; Thu, 18 Apr 2024 18:22:10 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Thu, 18 Apr 2024 18:22:10 +0000 From: "Martin Husemann" Subject: CVS commit: [netbsd-10] src/sys To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20240418182210.DACF9FA2C@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Martin Husemann" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: martin Date: Thu Apr 18 18:22:10 UTC 2024 Modified Files: src/sys/kern [netbsd-10]: init_main.c kern_hook.c vfs_mount.c src/sys/miscfs/procfs [netbsd-10]: procfs.h procfs_subr.c procfs_vfsops.c procfs_vnops.c Log Message: Pull up following revision(s) (requested by hannken in ticket #668): sys/miscfs/procfs/procfs.h: revision 1.83 sys/miscfs/procfs/procfs.h: revision 1.84 sys/kern/vfs_mount.c: revision 1.104 sys/miscfs/procfs/procfs_vnops.c: revision 1.230 sys/kern/init_main.c: revision 1.547 sys/kern/kern_hook.c: revision 1.15 sys/miscfs/procfs/procfs_vfsops.c: revision 1.112 sys/miscfs/procfs/procfs_vfsops.c: revision 1.113 sys/miscfs/procfs/procfs_vfsops.c: revision 1.114 sys/miscfs/procfs/procfs_subr.c: revision 1.117 Print dangling vnode before panic() to help debug. PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs" Protect kernel hooks exechook, exithook and forkhook with rwlock. Lock as writer on establish/disestablish and as reader on list traverse. For exechook ride "exec_lock" as it is already take as reader when traversing the list. Add local locks for exithook and forkhook. Move exec_init before signal_init as signal_init calls exechook_establish() that needs "exec_lock". PR kern/39913 "exec, fork, exit hooks need locking" Add a hashmap to access all procfs nodes by pid. Using the exechook to revoke procfs nodes is racy and may deadlock: one thread runs doexechooks() -> procfs_revoke_vnodes() and wants to suspend the file system for vgone(), while another thread runs a forced unmount, has the file system suspended, tries to disestablish the exechook and waits for doexechooks() to complete. Establish/disestablish the exechook on module load/unload instead mount/unmount and use the hashmap to access all procfs nodes for this pid. May fix PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs" Remove all procfs nodes for this process on process exit. To generate a diff of this commit: cvs rdiff -u -r1.541 -r1.541.2.1 src/sys/kern/init_main.c cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/kern/kern_hook.c cvs rdiff -u -r1.101 -r1.101.2.1 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.82 -r1.82.4.1 src/sys/miscfs/procfs/procfs.h cvs rdiff -u -r1.116 -r1.116.20.1 src/sys/miscfs/procfs/procfs_subr.c cvs rdiff -u -r1.111 -r1.111.4.1 src/sys/miscfs/procfs/procfs_vfsops.c cvs rdiff -u -r1.229 -r1.229.4.1 src/sys/miscfs/procfs/procfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.