From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0DC9265623 for ; Fri, 27 Mar 2026 10:16:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774606618; cv=none; b=RCLng25Dkz0LzMQNmb/uhA60y3Tn5gHkI5XJ7r3v7QVbK48coLqUIcS9xjrMIbgOn761EhXNjv+udy0AR6kHATvpJ/46d8s8QnH/WVX3fJuFzNdH9DVlaTQO2yrE9l6tdTbXKHSQ/VQV6FxilfbTvNJ37yLFFkj4Co+vIPM95TI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774606618; c=relaxed/simple; bh=YxRvdPpK+jiro3W3O1dwFmU6uwq2bSZ4k6w8U5gArlw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nOt8ulJAH+cBWsJRBK1JGUAJfyQuO0Lt8mS8UBj6EghO9LN019CYr7B3HRIcbRsomidV+1bwvWsUVrAWAjB6Vk3aKRs3RXLAcYsipFwAiYJOHBZwq7BRNY+4eNNsa67SP0n2fLqC1SzQKZM0hbJ5lw6fSlE6nMXmg2Pn4VJnwpU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=PR1RYbV7; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PR1RYbV7" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774606613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WthTZaMy2BJ2+J1txdM2eJcQIE72Zdbwhyjf9kXV4DI=; b=PR1RYbV7qRtmkzE39wUIuSYmVE1LqNgDV+7oN71W3GwSs7Q5323+o9f45tDk8yeFhje7wR zJAfuyKeEaTnTfLCiXN9y1noHFclpYdNIjMn9XuX9jqn4CFeepDjCqUN1HCmbrQlGvlosO kWkarM/SIEMOM9VycfEOd9bL89WqhHI= From: Qi Zheng To: hannes@cmpxchg.org, hughd@google.com, mhocko@suse.com, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, david@kernel.org, ljs@kernel.org, ziy@nvidia.com, harry.yoo@oracle.com, yosry.ahmed@linux.dev, imran.f.khan@oracle.com, kamalesh.babulal@oracle.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, chenridong@huaweicloud.com, mkoutny@suse.com, akpm@linux-foundation.org, hamzamahfooz@linux.microsoft.com, apais@linux.microsoft.com, lance.yang@linux.dev, bhe@redhat.com, usamaarif642@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH v3 0/3] fix unexpected type conversions and potential overflows Date: Fri, 27 Mar 2026 18:16:27 +0800 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Qi Zheng Changes in v3: - squash [PATCH v2 4/4] into [PATCH v2 2/4] (suggested-by Lorenzo Stoakes) - split complex calculation into multiple steps (suggested-by Lorenzo Stoakes) - collect Reviewed-bys - rebase onto the next-20260326 Changes in v2: - modified all commit messages. (suggested-by Lorenzo Stoakes) - added a fix patch to resolve the unexpected massive positive number (pointed-by Harry Yoo and sashiko) - fix the print type mismatch in [PATCH 3/3] - collect Reviewed-by Hi all, As Harry Yoo pointed out [1], in scenarios where massive state updates occur (e.g., during the reparenting of LRU folios), the values passed to memcg stat update functions can accumulate and exceed the upper limit of a 32-bit integer. If the parameter types are not large enough (like 'int') or are handled incorrectly, it can lead to severe truncation, potential overflow issues, and unexpected type conversion bugs. This series aims to address these issues by correcting the parameter types in the relevant functions, and fixing an implicit conversion bug in memcg_state_val_in_pages(). This series is based on the next-20260326. Comments and suggestions are welcome! Thanks, Qi [1]. https://lore.kernel.org/all/acDxaEgnqPI-Z4be@hyeyoo/ Qi Zheng (3): mm: memcontrol: correct the type of stats_updates to unsigned long mm: memcontrol: change val type to long in __mod_memcg_{lruvec_}state() mm: memcontrol: correct the nr_pages parameter type of mem_cgroup_update_lru_size() include/linux/memcontrol.h | 2 +- include/trace/events/memcg.h | 10 ++++----- mm/memcontrol.c | 40 +++++++++++++++++++++--------------- 3 files changed, 29 insertions(+), 23 deletions(-) -- 2.20.1