[PATCH 2/2] cache: fix integer conversion error in parsing cache_pool_max_chunks
Ming-Hung Tsai <[email protected]> Mon, 17 Mar 2025 15:51:25 +0800
| Newsgroups | gmane.linux.lvm.devel |
|---|---|
| Message-ID | <[email protected]> |
The allocation/cache_pool_max_chunks config is read as an int32_t, then converted to uint64_t. If the value in lvm.conf exceeds INT32_MAX, conversion to uint64_t results in truncation followed by sign extension, causing the original unsigned representation to be lost. For example, a config value of 6442450944 is converted to 18446744071562067968. This fix preserves the original u64 value from the parser. Further adjustments should be applied to fit dm-cache's metadata limits. Signed-off-by: Ming-Hung Tsai <[email protected]> --- lib/config/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config/config.c b/lib/config/config.c index 9df9c925c152..fc7d16279f31 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -2555,7 +2555,7 @@ uint64_t get_default_allocation_cache_pool_max_chunks_CFG(struct cmd_context *cm * newer targets may scale better. */ uint64_t default_max_chunks = DEFAULT_CACHE_POOL_MAX_CHUNKS; - uint64_t max_chunks = find_config_tree_int(cmd, allocation_cache_pool_max_chunks_CFG, profile); + uint64_t max_chunks = find_config_tree_int64(cmd, allocation_cache_pool_max_chunks_CFG, profile); if (!max_chunks) max_chunks = default_max_chunks; -- 2.47.0