From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388302; b=IhrkiUnVpzFOK3Mm1/uGCkNPA2sW/ZIcbkOSSM9qsNWD/YBwpFQyv1ZTdsDbkJvfCg9p Wk0AgL/AK3SAgW0pMPwXTtYFmjJrLwG7y2CgxdNklUIB7C7mAntjMIwqeJxOhGdD4pPIj RGq05ScewDphLcc1ZFJct6NszJT1NmsdeZL8K7U8FfRQ77Zr3+LR+72iZXdHGVzjWJhjG biQtFHxHr9AsnKbjJM7snZpcfjTXttTxqT0eM0RhYSAV7AsZobQALIuOnVc8aPjUmoNmq 5gu3vovke0LggdQXa+Rgzkf5TeyxmWKsp3tzHyqmgRkJlPsqzhtAfy3aMfIHM6s5tiA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388302; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=gskOwhqESSQcaJDecMfWqeA/xgbugPPeA1LKkcv+aPw=; b=r2PZRpfAIlskl2ftPr1RMt9hgYvWPHFOpVHNnXvPzdKhtP24FHaNPFDjlzjNePHVu5GM OKhTkbGmUeNReFlJHh8c9EsuwtgGFDUrMcPiXClL76KnCGx123Fi/xH5hEYwHLjDL+D32 OtaXCe3yantcEt/RI40VIOKI35zX47oGcRHQopsz2RL/o6Yhf7pfZ60vQCSSbQuIn9hqc daTEJqtD1SG83alcgNSGW13F0Unhw0jQwElEtbE2UVhxy+MyzGArOMAGAeECa0XlDB3Jk KLrFkdtt1PsMa1dzQyPQluNzf+hLdnKsmNfxD7J9MkE3CYawRDaKQZgXYM39y1K+3YQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OIpKpGww; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3710B606A337; Fri, 4 Dec 2026 12:45:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OIpKpGww Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9A5C1F00A07; Fri, 4 Dec 2026 12:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388302; bh=gskOwhqESSQcaJDecMfWqeA/xgbugPPeA1LKkcv+aPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OIpKpGwwdBun0xieS76YBAxru77NluZ40/4+O8aCEdXvZsdqyPta+h2UwjFFcTu0R WgHg2oGCy0kRK3c+0sewl94TQql3aOJl5FYrLOfvXbrDiDLcG2VnEN8+KsDVZ4ObC9 VuZKtfvch9hzUlgonZWlUN2byQjcZ1rzzO7ogCPo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yingjie Wang <1075151112@qq.com>, Mikulas Patocka Subject: [PATCH 6.1 0563/1059] dm thin: avoid wrapping no_space_timeout Date: Fri, 4 Dec 2026 19:01:34 +0900 Message-ID: <20261204100658.751979882@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yingjie Wang <1075151112@qq.com> commit bcb78d49620f666b4a9d62997691e8d031fd4ebc upstream. set_pool_mode() converts the no_space_timeout module parameter with READ_ONCE(no_space_timeout_secs) * HZ. The usual arithmetic conversions evaluate the product as unsigned int, so it can wrap before being stored in the unsigned long delay. With HZ=1000, 4294968 seconds becomes 704 jiffies: a pool that runs out of data space switches to error_if_no_space and fails queued writes with -ENOSPC after about 0.7 seconds. Widen the value before the multiplication and cap it at MAX_JIFFY_OFFSET / HZ, so large timeouts no longer wrap into short delays. On 32-bit kernels, values beyond the supported jiffies range saturate at the largest whole-second delay not exceeding MAX_JIFFY_OFFSET. The timer wheel's existing handling of very long delays is unchanged. Fixes: 80c578930ce7 ("dm thin: add 'no_space_timeout' dm-thin-pool module param") Cc: stable@vger.kernel.org Signed-off-by: Yingjie Wang <1075151112@qq.com> Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-thin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -2524,7 +2524,9 @@ static void set_pool_mode(struct pool *p struct pool_c *pt = pool->ti->private; bool needs_check = dm_pool_metadata_needs_check(pool->pmd); enum pool_mode old_mode = get_pool_mode(pool); - unsigned long no_space_timeout = READ_ONCE(no_space_timeout_secs) * HZ; + unsigned long no_space_timeout = + min_t(unsigned long, READ_ONCE(no_space_timeout_secs), + MAX_JIFFY_OFFSET / HZ) * HZ; /* * Never allow the pool to transition to PM_WRITE mode if user