Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Mar 2019 19:37:07 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r344819 - stable/12/sys/kern
Message-ID:  <201903051937.x25Jb7jB079186@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Mar  5 19:37:06 2019
New Revision: 344819
URL: https://svnweb.freebsd.org/changeset/base/344819

Log:
  MFC r344278:
  Move a racy assertion in filt_pipewrite().
  
  PR:	235640

Modified:
  stable/12/sys/kern/sys_pipe.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/sys_pipe.c
==============================================================================
--- stable/12/sys/kern/sys_pipe.c	Tue Mar  5 19:17:24 2019	(r344818)
+++ stable/12/sys/kern/sys_pipe.c	Tue Mar  5 19:37:06 2019	(r344819)
@@ -1743,15 +1743,19 @@ static int
 filt_pipewrite(struct knote *kn, long hint)
 {
 	struct pipe *wpipe;
-   
+
+	/*
+	 * If this end of the pipe is closed, the knote was removed from the
+	 * knlist and the list lock (i.e., the pipe lock) is therefore not held.
+	 */
 	wpipe = kn->kn_hook;
-	PIPE_LOCK_ASSERT(wpipe, MA_OWNED);
 	if (wpipe->pipe_present != PIPE_ACTIVE ||
 	    (wpipe->pipe_state & PIPE_EOF)) {
 		kn->kn_data = 0;
 		kn->kn_flags |= EV_EOF;
 		return (1);
 	}
+	PIPE_LOCK_ASSERT(wpipe, MA_OWNED);
 	kn->kn_data = (wpipe->pipe_buffer.size > 0) ?
 	    (wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) : PIPE_BUF;
 	if (wpipe->pipe_state & PIPE_DIRECTW)



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