Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp400379pxf; Wed, 24 Mar 2021 07:32:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy5iLX8ZbihecYZTs1gt1kssuAZcMaBBRwe8oSovGJPVqKD1VVVrtmIWbK1QSxJ8Ml6+GE X-Received: by 2002:a05:6402:31a7:: with SMTP id dj7mr3789837edb.33.1616596357291; Wed, 24 Mar 2021 07:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616596357; cv=none; d=google.com; s=arc-20160816; b=FAtGk2cOwozx3UI42md09QWI0flff20a3khFbv6OCPLjzU3FF9KpE3PJlJfaZ8ciAw NeWQFyt2ywbi+5nhqyUhjGYgbFANIUGCVhqLJbpY+5Qnd5A/FeJI7ejVu4Z/FdeUQdRB sU8woNRjdqdwsXItgYiLvAgLb81zROiT9LE2G3jgpQKKmQ/vrNEMH6Nf85tM+yO39xBv q2+26ch3cx3hbNAuAdRTxth0tRLSP2mDAFhY2PeFT6iIOMoE1XrH1Pgd0XKbbKwI5QDR 2byyHo7YzJ2kQM/ROXTo2f/CKa8zDcWl8FPhqTg+yBYaDkt912D/eJpEmWSZZSJA9O77 efBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=DxIVPfQCMqOrZn3/5HfacoYgZRK3+zxnaLQGxHn6K+M=; b=kz1WsZK8fVXrwTGgA+8H5Cu13AH+69ljyeqs4zyd+XJi8aOygTQ6+878VecQ1gdVQ1 lwkmF02jNgzOuXk1k6HQ5u0UJMrAM4R8dlhu9ehA8wcAZB05807VMtHo52mc/ADESPZI Ug6lftESh/p0gNHO05kY9TXqBuP2t6sNaGJNVx05tXWANiEBSBW7JVSJgeUkx7U7hB/2 cSOrjURPGBjAqq6i3dUxiFZSBJelK3YNWsITr2IrOmzl2lIA1fuSAU32KOJis6/ZmkvQ lDd9jtgDoBO9PvfcimX7LXWdLWzL+v3to43wItBn8PJo91WxOj00cSGeXUz7r8BQVwwc oXYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@schauer.dev header.s=dkim header.b=yTw6RPSY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=schauer.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si2013020ejr.278.2021.03.24.07.32.13; Wed, 24 Mar 2021 07:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@schauer.dev header.s=dkim header.b=yTw6RPSY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=schauer.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236115AbhCXO3j (ORCPT + 99 others); Wed, 24 Mar 2021 10:29:39 -0400 Received: from mail.kurz.pw ([89.163.159.92]:37426 "EHLO mail.kurz.pw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236060AbhCXO3Q (ORCPT ); Wed, 24 Mar 2021 10:29:16 -0400 X-Greylist: delayed 325 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Mar 2021 10:29:16 EDT Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id F09D0123E06; Wed, 24 Mar 2021 15:23:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schauer.dev; s=dkim; t=1616595824; h=from:subject:date:message-id:to:cc:mime-version:content-type; bh=DxIVPfQCMqOrZn3/5HfacoYgZRK3+zxnaLQGxHn6K+M=; b=yTw6RPSYj4Ukv9RWSh8QyNZ43Fkqk/o6fNvu/M+eLw4HeVVhvydpa3wip0SRSgw7Xo5Oi3 8c2hhAXtK4yB0tA8Qut8LzHV3R5wYNCqehTfs4kJ7MutwSPVgX7+Iwg6hCxBiLNZlVcYN4 FLlLZ87pjTlwPcBLOUswyrFay2phahU= Date: Wed, 24 Mar 2021 15:23:32 +0100 From: Lukas Schauer To: linux-kernel@vger.kernel.org Cc: Alan Cox , David Howells Subject: [PATCH] fs/pipe: wakeup wr_wait after setting max_usage Message-ID: <20210324142332.xfcuvuv2lfjkfznn@vista> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hiyo6ox56cbjkj3z" Content-Disposition: inline X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --hiyo6ox56cbjkj3z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline With commit c73be61cede5882f9605a852414db559c0ebedfd a regression was introduced that would lock up resized pipes under certain conditions. In that 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, resulting in a deadlock. This patch moves the wakeup for pipe->wr_wait back to the original pipe_set_size function, after pipe->max_usage has actually been updated. --- fs/pipe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index bfd946a9ad01..58916ad905b4 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1282,8 +1282,6 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots) pipe->tail = tail; pipe->head = head; - /* This might have made more room for writers */ - wake_up_interruptible(&pipe->wr_wait); return 0; } @@ -1335,6 +1333,10 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) pipe->max_usage = nr_slots; pipe->nr_accounted = nr_slots; + + /* This might have made more room for writers */ + wake_up_interruptible(&pipe->wr_wait); + return pipe->max_usage * PAGE_SIZE; out_revert_acct: -- 2.31.0 --hiyo6ox56cbjkj3z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEPC8mBeB4oeGPR5OQnE2+bPQ48zMFAmBbS2QACgkQnE2+bPQ4 8zPF1gf+K13g+OsRDdSXWdNCbpNPQRolHWCzgGfDtSL9zyTlLmWS7CBj6Jn/zmxK 6j914SRe8adddCHpLS9XQ16mbf6qRtyUIMCep8DY58mcZ2V5GPqf0PfvgtMGN6EQ sVFMdiTqedbiDOv8K3fxcpRCxYu4O4rCEp0bATAzvu/w3jGm7pWWJhZn94mr/v5C kLNMGBKltJIC/+xMvKQ/LmFB8WKTE6k5yf1qjLAp3/82ua8Wm/cYZ5izuwEWANgP t8bhL4z3mfss+nEXAIJ6nXVZ471THjkG968DENBNYfun5EIvXXWUqFJ98F5vNt4g kqyV2le88n/qmI4dISB0mPfbiLI53A== =Q8eY -----END PGP SIGNATURE----- --hiyo6ox56cbjkj3z--