From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8DB1309F08 for ; Thu, 30 Jul 2026 09:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785402414; cv=none; b=uv7/kPWZvuuIRoU89qD9n8nsQU1wNZrjjW0I97JU3KlKqKB6X41KQOD2adbR3lv7G1vy6MYuWM3XcuqXq6ev6g6EWzaB+On9lcf3NQusotT1Mi1CrEICCx33EPrBidVEh+JE+X92pT86ffGrkK/M8W7W4EaSUuauUdHlWAbRP/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785402414; c=relaxed/simple; bh=IkBr0RaGunvEhbuxv/oD2qoRSURPTDKuYQtUfAZxb20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eJ5cn21FQZhKVRgoG2L2rff95JIfU8lfC/MJ95nZ6A7ijJoC+rXoIIwbP/JxBFyWSvXlmKyOqlkDpApXxto7QUquCkj/tyINVW1BbNCL6DTAWk9tBI+7RI9t5HCl1lX855ZHwq3TTnSDQPvX51hCku39lNadO4qIJIEMMfShoc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Wa1GAv63; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wa1GAv63" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-39c8dbf4f38so15267161fa.3 for ; Thu, 30 Jul 2026 02:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785402411; x=1786007211; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AxWmC90sRXwr8zyhQC/Nw/p1hseuCo/SkMIrvBLGNgc=; b=Wa1GAv63Vkl8WAYlDWI9MMNKGYHbHufxkpXwafX0QaldiBHzwFxpQ3PK6a0EHege02 nD4uAR90nCStc/rf5aOqlKsgpGoVoIGATu4d17NfBxLT67wXb8Uh5hZO7QzV/U5jsKet LQG4FbxNePCljGOEaPfbAVvjbMafO0zW3Y5wGqI7OQglQKf+rOFIlRtIfysajrsvRpxU lkNWtwn9n5iTZzv8zk0zNy9texBlamWFkBfjwZb/P9lADgrLB2+vM1KHC9/YICw4J7UL HZNxA7W9Vsjd8FdQPI+MrppkgXCjHwJHXORkjJrzOpqaNudtJL+2dywh1+urL+kRdzE9 EvMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785402411; x=1786007211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=AxWmC90sRXwr8zyhQC/Nw/p1hseuCo/SkMIrvBLGNgc=; b=MjwV42EGI+XBr+F6y7UyysHZGUix0Upqw4jjtqGblccY/M3KN1DxtqpycYLjGZKU8m Qy7g4vnIk5QFdNDdNxXhqWjSHKM9QrFcBTtMeqLepMBssB7VcLkOMIf2wdWLNoZE0bed qBtNtrvyJC4iGEwAaC9koPLS6AJciObNjpN8ISwhrszxg8lwAVUjwm2QqHYe083Hfkgf NukREQejQydW4kMDVMwEKEnmb3pOkGSEp6c9pkIwDeuWGFvS/gcBxLrE6N6ZkVrM0E9O MWdDEKsgvwSkp5MlYiyDHwaHUrnLI0K09pmKKJtwCjWhpenvR+fV1Bn+88TXuY/LGTin AxWA== X-Forwarded-Encrypted: i=1; AHgh+Rp255s3uT9Ze4IViSMMsAZjU7raTXmf8Mu4X7Cbfz6BTq9RUOjIXQlJV36GkQIOMSR/vCV4mr0MCMxppB0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0y0IBoy60OOdoUZ7ZYfhxB1ca0erax+0rMs+A+83CglXPnWDD cylycALWq5wpw9ND6K3IQLwzGY7wU6Yt4VVFRMyvI4qLI5St9lMF1DRZ30XViw== X-Gm-Gg: AR+sD13BChtY4xmB6nIJMfffjibFWI+q67sZj5vCQpgsRteYdRshxpkcqkaWrGtRF09 mSS4GSR2hGG5bbQan2ZgCLfSEJ0ckbLndoaIOS8MA8v3R8beXWJmRGVP68nfYTA0EBFADbSVfxz J0K+wO8Pm3h45Scq72gaYHE+uyhXgf9t3e1SpGzlrNzXzMZlCzayJI1cF4+lgu0j5VKoDalg5Dy 0sb1rxT5AsrRH+/MRQ9yPM0vlimqMeuzG+oEAxZezbjc/AimcqmTUvgySrqAHWtGmBCjZCm5dkF l2PM5TRHdLk0KAsI/7RHAWQ+oFJqZ17AKl7fZI93NF9F7J0eUHDGFZ//MWzfwWi1SNuc1pnCpY2 Bmkl7yLvkgGmmAg19au2cTDlFcIGkPaOS4c9GHMVo+2L2pBSU3GrnSuneYLA9H4+Gpo20OCR1E0 mwEfboAVzGZu9zmGsIx5lPxLtCrvSJcb1OiHBztgf29l2vGFR3ZZRxU4pgpoPKIf05MXouVe2tM vhFcFl8e14W58O03uVxoASOSx4dU8lRy9nFGrwoqP+/h8Cd6HIFbo3OFQ== X-Received: by 2002:a05:651c:1504:b0:39b:224f:93a1 with SMTP id 38308e7fff4ca-39f6d0c5d95mr3342871fa.38.1785402410327; Thu, 30 Jul 2026 02:06:50 -0700 (PDT) Received: from localhost.localdomain (46-138-176-102.dynamic.spd-mgts.ru. [46.138.176.102]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-39f6ac80d6bsm1928641fa.29.2026.07.30.02.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 02:06:49 -0700 (PDT) From: Artem Lytkin To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, urezki@gmail.com, willy@infradead.org, shivamkalra98@zohomail.in, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/3] mm/vmalloc: stop truncating byte counts derived from nr_pages Date: Thu, 30 Jul 2026 12:06:25 +0300 Message-ID: <20260730090628.65814-1-iprintercanon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260729175708.7074-1-iprintercanon@gmail.com> References: <20260729175708.7074-1-iprintercanon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Andrew asked for a v2 of the nr_pages widening, rebased on mm-new, with the changelog clarified on what has actually been observed. The widening reverts the two casts added by the patches I sent on 25 July, so it needs those in the tree first, and they are not in mm-new, mm-unstable or mm-hotfixes-unstable today. They are here as 1/3 and 2/3 so that the series applies and Sashiko can chew on it. 2/3 is byte for byte what I sent; 1/3 has one corrected sentence in its changelog and the same one-line diff. Keeping the three separate is deliberate. 1/3 is a one-line fix for a v7.2 regression and carries a Fixes: tag, so it is the part that wants to go in on its own. 3/3 is a type change across the file. On what has been seen in practice, since v1 of 3/3 read as though the bug had been hit: it has not. There is no report behind any of this, I found it reading the code. What is reachable is the 4 GiB truncation in vread_iter(), which needs a machine with more than 4 GiB of memory and nothing else, and makes /proc/kcore return zeros for such an area while reporting a successful read. The vrealloc() case has the same cause but stays latent, no in-tree caller grows an allocation that far. The rest is unexercised, and 3/3 now separates the two thresholds instead of lumping them together: 2^32 pages, where the field truncates, is 16 TiB and out of reach of any hardware, while 2^31, where the plain int page indexes break, is 8 TiB and only out of reach because nothing asks for an area that large. Changes in v2: - rebased on mm-new - 3/3: the changelog separates what is reachable, what is latent and what is merely unexercised, and answers the 16 TiB question directly - 3/3: the note on the mapping path no longer calls the int *nr cursor a cap, since it is an overflow and not a bound, and no longer claims that every user outside mm/vmalloc.c only indexes or shifts the count. Three of them pass it to a narrower parameter, which is now named - 1/3: dropped the claim that alloc_large_system_hash() cannot reach a 4 GiB area. Its cap is a sixteenth of memory, so it can on a 64 GiB machine, just not without an explicit table size on the command line v1 of 3/3: https://lore.kernel.org/linux-mm/20260729175708.7074-1-iprintercanon@gmail.com/ 1/3 and 2/3 as first posted: https://lore.kernel.org/linux-mm/20260725132201.88279-1-iprintercanon@gmail.com/ Checked on x86-64: vmlinux and modules build clean, and mm/vmalloc.c plus every file that touches vm_struct::nr_pages are clean at W=1, with HAVE_ARCH_HUGE_VMALLOC, NUMA, KEXEC_HANDOVER, DEBUG_KMEMLEAK, DMA_API_DEBUG and PROC_KCORE enabled. sizeof(struct vm_struct) measured against the real headers: 72 bytes before and after with HAVE_ARCH_HUGE_VMALLOC=n, 72 to 80 with it enabled, both sizes inside the kmalloc-96 bucket that __get_vm_area_node() already allocates from. Artem Lytkin (3): mm/vmalloc: fix 32-bit truncation of the area size in vread_iter() mm/vmalloc: fix 32-bit truncation in the vrealloc() grow-in-place check mm/vmalloc: make vm_struct.nr_pages an unsigned long include/linux/vmalloc.h | 2 +- mm/vmalloc.c | 58 ++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 31 deletions(-) base-commit: eee677bbc48890b2bcaa42ea7942478302937a09 -- 2.43.0