Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jul 2021 22:17:20 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b9ca419a21d1 - main - fifo: Explicitly initialize generation numbers when opening
Message-ID:  <202107132217.16DMHKAF060730@gitrepo.freebsd.org>

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

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

commit b9ca419a21d109948bf0fcea5c59725f1fe0cd7b
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-07-13 21:45:49 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-07-13 21:45:49 +0000

    fifo: Explicitly initialize generation numbers when opening
    
    The fi_rgen and fi_wgen fields are generation numbers used when sleeping
    waiting for the other end of the fifo to be opened.  The fields were not
    explicitly initialized after allocation, but this was harmless.  To
    avoid false positives from KMSAN, though, ensure that they get
    initialized to zero.
    
    Reported by:    KMSAN
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
---
 sys/fs/fifofs/fifo_vnops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c
index 33c2c8ab2951..d2a51de84fba 100644
--- a/sys/fs/fifofs/fifo_vnops.c
+++ b/sys/fs/fifofs/fifo_vnops.c
@@ -154,9 +154,9 @@ fifo_open(ap)
 		error = pipe_named_ctor(&fpipe, td);
 		if (error != 0)
 			return (error);
-		fip = malloc(sizeof(*fip), M_VNODE, M_WAITOK);
+		fip = malloc(sizeof(*fip), M_VNODE, M_WAITOK | M_ZERO);
 		fip->fi_pipe = fpipe;
-		fpipe->pipe_wgen = fip->fi_readers = fip->fi_writers = 0;
+		fpipe->pipe_wgen = 0;
  		KASSERT(vp->v_fifoinfo == NULL, ("fifo_open: v_fifoinfo race"));
 		vp->v_fifoinfo = fip;
 	}



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