From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1856E55E5E; Wed, 21 Feb 2024 13:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708523890; cv=none; b=rPSSXBJ/Xl7U4mRb99qNCA7UiONhEM4zPrCwdRSVAeDYTe/q01fAt+mew5eUwLtR42k75u38w6akm4vqlEcb7O8AGv1ChQu0faMLm7evOLUePEmAnHQNicW2LrTCoPgIOYrYGO2IwLHDdfPfsC3GQ55ZIQpMYYfwuaVPs/LDABA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708523890; c=relaxed/simple; bh=3l6AhkzGK43htIm2KnJFYruMyfqn0q2Cod3LOJBmVLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rGlWgRVCLlBqMJqF/j/Zq0W12AYVQxoTF2/PmQ7GPTJSgYJ03cwCg6oMEsRk145TY5b86usSNXerEXHRpMXiAso3BeHWKxENMa9hAp4VQ8QUhMXXTveFeoxdG75kTbN4WTZ3g+VVucX7gI08xrRytWRCW6WZMJwbtgs7//YNiFs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nvKN+bz0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nvKN+bz0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79D67C433F1; Wed, 21 Feb 2024 13:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708523890; bh=3l6AhkzGK43htIm2KnJFYruMyfqn0q2Cod3LOJBmVLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nvKN+bz0OrGuQqrKqkKtwyNor5yqaIQoYq16yX+lRpLMEdu2mxy9XCZI0j8E4V5d6 VHiy8wg6SzCZE7ajcJGJPvPPcoJ1X72zWvPI8PI5hWh7+IE7b0b2TQ877OQw/YP2Bc lZyVarfW3ep17oo5pqhwpSRLuorzP/xNU9/HSkBg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Howells , Lukas Schauer , Christian Brauner , Sasha Levin Subject: [PATCH 5.10 082/379] pipe: wakeup wr_wait after setting max_usage Date: Wed, 21 Feb 2024 14:04:21 +0100 Message-ID: <20240221125957.334471427@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221125954.917878865@linuxfoundation.org> References: <20240221125954.917878865@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lukas Schauer [ Upstream commit e95aada4cb93d42e25c30a0ef9eb2923d9711d4a ] Commit c73be61cede5 ("pipe: Add general notification queue support") a regression was introduced that would lock up resized pipes under certain conditions. See the reproducer in [1]. The commit resizing the pipe ring size was moved to a different function, doing that moved the wakeup for pipe->wr_wait before actually raising pipe->max_usage. If a pipe was full before the resize occured it would result in the wakeup never actually triggering pipe_write. Set @max_usage and @nr_accounted before waking writers if this isn't a watch queue. Link: https://bugzilla.kernel.org/show_bug.cgi?id=212295 [1] Link: https://lore.kernel.org/r/20231201-orchideen-modewelt-e009de4562c6@brauner Fixes: c73be61cede5 ("pipe: Add general notification queue support") Reviewed-by: David Howells Cc: Signed-off-by: Lukas Schauer [Christian Brauner : rewrite to account for watch queues] Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/pipe.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 7b3e94baba21..588fe37d8d95 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1300,6 +1300,11 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots) pipe->tail = tail; pipe->head = head; + if (!pipe_has_watch_queue(pipe)) { + pipe->max_usage = nr_slots; + pipe->nr_accounted = nr_slots; + } + spin_unlock_irq(&pipe->rd_wait.lock); /* This might have made more room for writers */ @@ -1351,8 +1356,6 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) if (ret < 0) goto out_revert_acct; - pipe->max_usage = nr_slots; - pipe->nr_accounted = nr_slots; return pipe->max_usage * PAGE_SIZE; out_revert_acct: -- 2.43.0