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.