git: d1d675cb304c - main - freevnode(): lock the freeing vnode around destroy_vpollinfo()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 12 Nov 2021 23:04:19 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=d1d675cb304c3cca824fbc9f932dc9d655b1ad24

commit d1d675cb304c3cca824fbc9f932dc9d655b1ad24
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-11-02 02:49:13 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-11-12 23:01:02 +0000

    freevnode(): lock the freeing vnode around destroy_vpollinfo()
    
    to satisfy locking requirements of knlist manipulations.
    
    Reported and tested by: pho
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D32761
---
 sys/kern/vfs_subr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 181d0004e940..c0214e570628 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1896,7 +1896,9 @@ freevnode(struct vnode *vp)
 	mac_vnode_destroy(vp);
 #endif
 	if (vp->v_pollinfo != NULL) {
+		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 		destroy_vpollinfo(vp->v_pollinfo);
+		VOP_UNLOCK(vp);
 		vp->v_pollinfo = NULL;
 	}
 	vp->v_mountedhere = NULL;