Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jul 2021 16:59:00 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 10db1896495b - main - fifofs: fifo vnode might be relocked before VOP_OPEN() is called
Message-ID:  <202107271659.16RGx0Sf083540@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

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

commit 10db1896495b744aa5b039dd4ef1973b7a339379
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-07-22 10:27:43 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-07-27 16:58:47 +0000

    fifofs: fifo vnode might be relocked before VOP_OPEN() is called
    
    Handle it in fifo_close by checking for v_fifoinfo == NULL
    
    Reported and tested by: pho
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D31310
---
 sys/fs/fifofs/fifo_vnops.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c
index d2a51de84fba..861f1b40a744 100644
--- a/sys/fs/fifofs/fifo_vnops.c
+++ b/sys/fs/fifofs/fifo_vnops.c
@@ -282,9 +282,21 @@ fifo_close(ap)
 	struct pipe *cpipe;
 
 	vp = ap->a_vp;
+	ASSERT_VOP_ELOCKED(vp, "fifo_close");
 	fip = vp->v_fifoinfo;
+
+	/*
+	 * During open, it is possible that the fifo vnode is relocked
+	 * after the vnode is instantiated but before VOP_OPEN() is
+	 * done.  For instance, vn_open_vnode() might need to upgrade
+	 * vnode lock, or ffs_vput_pair() needs to unlock vp to sync
+	 * dvp.  In this case, reclaim can observe us with v_fifoinfo
+	 * equal to NULL.
+	 */
+	if (fip == NULL)
+		return (0);
+
 	cpipe = fip->fi_pipe;
-	ASSERT_VOP_ELOCKED(vp, "fifo_close");
 	if (ap->a_fflag & FREAD) {
 		fip->fi_readers--;
 		if (fip->fi_readers == 0) {



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