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=1796385575; b=UjkJ07p83G7AaLID1tbRpGEavn5TyYpF2jLssH9OIdRB/BMtB0YSCEpmjS1LSHhLJr61 DAiZ9w58mdE3fw5NhqNkPCSQdSwecdkS1HGnld4TKnsXQAkeESDZ4YRqUofAxSRVj9qp5 AdfVfw2tCyAPbwC535TsO+HmKo4tx3NmNT8ZKMmHGQecb809duoGpGwCMbEzImnisTKbw yNGA2VrDPwow8XJsq5LaniGvsbF2LOUcZbDHuEecPRwnP577qIOVfgfMsQgdjx+JsGMG2 HtNp47xQtL4LNsCRHL+A/o2MMlOHq76lvF+ZeLgfKAl6JGl6auHLiHJj3lF+/AUNeog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385575; 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=31NKt1PBScQ4n1NQRPp6LpejHvSExJ44jGUhrRAPZuI=; b=rzsMTAiOwFC1iGSS74x1RFSrYXD9/r/A5ZZxXUFA/esiovmbB3wEcI/kLuOx7t81NuAZ i/nNy4roaabZSJq+kV0qbjLY3fSQjGxlbtoeXGrcJfdKPXbjDnr4LvjDDHStaVW8fDxB0 rD8Q9fZApHT7T+/0EIT/PTHX4HvpoKMA6hQ3lJ+tzIxQFlag3yXBeBbpJcxkD+FoeKKFv ec25SKhm6/tbJZZIdxQ63USy8hWOzcgQeaTBDpljgCBqhJIX+B6a3vv/xJ48i1Bhpxmxs pZuQ4jyJM+OkAkTF7rInvKyOQS4hPLNo62KYdJ23bMX3eL2BDcydFlFjB5NymwwVKQA== 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=XQEw7e9B; 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 C9AD0606A322; Fri, 4 Dec 2026 11:59:35 +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=XQEw7e9B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FAE21F000CE; Fri, 4 Dec 2026 11:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385575; bh=31NKt1PBScQ4n1NQRPp6LpejHvSExJ44jGUhrRAPZuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XQEw7e9BcX+bgPo9XHM2THEJYq3KBqtv3HfD0GG8xMDWImj/rDVg3OTiH42U0oIkr 0I4PLtv6yeMUDPzBJE/89xQwwIDyfCk/kWiQZDAsGJDf+47iaHtLx24vQtGbVMj89C mgHZji4hQpNsligjumx4Gx6DswSWkEGr22iE8x0E= 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.6 0606/1167] dm thin: avoid wrapping no_space_timeout Date: Fri, 4 Dec 2026 19:00:33 +0900 Message-ID: <20261204100717.845747579@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 @@ -2546,7 +2546,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