Skip to content

Commit ab9b07d

Browse files
author
Brian Foster
committed
pipe: wakeup wr_wait after setting max_usage
Upstream Status: linux.git JIRA: https://issues.redhat.com/browse/RHEL-37087 CVE: CVE-2023-52672 commit e95aada Author: Lukas Schauer <lukas@schauer.dev> Date: Fri Dec 1 11:11:28 2023 +0100 pipe: wakeup wr_wait after setting max_usage Commit c73be61 ("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: c73be61 ("pipe: Add general notification queue support") Reviewed-by: David Howells <dhowells@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Lukas Schauer <lukas@schauer.dev> [Christian Brauner <brauner@kernel.org>: rewrite to account for watch queues] Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Brian Foster <bfoster@redhat.com>
1 parent 1aa74b1 commit ab9b07d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/pipe.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,11 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
13131313
pipe->tail = tail;
13141314
pipe->head = head;
13151315

1316+
if (!pipe_has_watch_queue(pipe)) {
1317+
pipe->max_usage = nr_slots;
1318+
pipe->nr_accounted = nr_slots;
1319+
}
1320+
13161321
spin_unlock_irq(&pipe->rd_wait.lock);
13171322

13181323
/* This might have made more room for writers */
@@ -1364,8 +1369,6 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)
13641369
if (ret < 0)
13651370
goto out_revert_acct;
13661371

1367-
pipe->max_usage = nr_slots;
1368-
pipe->nr_accounted = nr_slots;
13691372
return pipe->max_usage * PAGE_SIZE;
13701373

13711374
out_revert_acct:

0 commit comments

Comments
 (0)