From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (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 159FD3C5DBE for ; Thu, 9 Apr 2026 16:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775751389; cv=none; b=Bm8/OVzyjq8Ba6Jf9/ioXzbArGLI22azhpoWGqpbaus2e2Z7pCDrOQ7X5vYZX8hXJvNHZlRmectfaFA5hPD1igfHOT35X7MJQP9V1rRH/kxyKeXShL+gjPF2DN/rJaHFqU7AQvhnqA5vSD5F2EHeqo2tcPglXdgi6VPLLNeMM5s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775751389; c=relaxed/simple; bh=PCWms9kjQChrhv9F1yxYkvJ7L052GCCc/OW/8FiP3n4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=br0oZ81+5Opv8ut3fraUqfPvpRn2PFzVsxliXZKnlmqS3vLn4sTGcDcshhobxByeCqBqOLD7/WiBUezj7XcolMvQQVnnNvtZSb/3n/2dwiDUclaBCoVWl7XqT8i/PatiNQ+vQScN9bQatFMkLDqrbd9lce3UbuYN/Km7n35vQeY= 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=lFUCYcoZ; arc=none smtp.client-ip=91.218.175.181 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="lFUCYcoZ" 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=1775751386; 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=tMNsyiGa0G5+P1LcfG/z2C0Plb5ag4zvZ4Hw6hQ7n+4=; b=lFUCYcoZ0Wl+vxRWdFoAsXt5PHJhhsQweyow9tzfxKPN5sFnoYvJCU4AuygwpCRsRXjRpH OGeLygLtGCjj6ZjX+nrZVU8YOne6WJ1cZoqxR+fScV7ti4Lc5tgYlwFCb9Mg0nqZFGtlZj gchba6IoaJqAYtjKaamiFRhWZemYwAE= From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Changyuan Lyu , Andrew Morton , Alexander Graf , "Mike Rapoport (Microsoft)" Cc: Thorsten Blum , linux-kernel@vger.kernel.org Subject: [PATCH v2] x86/boot/compressed: use boot_kstrtoul() for hugepages= parsing Date: Thu, 9 Apr 2026 18:15:59 +0200 Message-ID: <20260409161600.152012-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1452; i=thorsten.blum@linux.dev; h=from:subject; bh=PCWms9kjQChrhv9F1yxYkvJ7L052GCCc/OW/8FiP3n4=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJnXLxzoe1q2embI89mXrfZcm3dC541nGmPQ5eQQXc+mS I0z6c80OkpZGMS4GGTFFFkezPoxw7e0pnKTScROmDmsTCBDGLg4BWAi3TqMDJuW+MXych1+7FR5 mLF93bVJnSHNKVEc63YLcZpoMBXxFDAyTHu0d4KhhefvI72ZN3YmqMzd5hGzsnE+g+1a7QZVvcd 3GQE= X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Replace simple_strtoull() with boot_kstrtoul() for parsing the hugepages= boot parameter. Unlike simple_strtoull(), boot_kstrtoul() performs strict validation and returns an error on invalid inputs instead of silently accepting partial input. Use boot_kstrtoul() to reject and warn about invalid hugepages= values. boot_kstrtoul() also converts the input directly to an unsigned long and avoids implicit casting. Signed-off-by: Thorsten Blum --- Changes in v2: - Adjust warning message (Boris) - The value pointer cannot be NULL after [1] has been applied (Boris) - Update patch subject and description - Link to v1: https://lore.kernel.org/lkml/20260202173223.865709-1-thorsten.blum@linux.dev/ [1] https://lore.kernel.org/lkml/20260409105437.108686-4-thorsten.blum@linux.dev/ --- arch/x86/boot/compressed/kaslr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 3b0948ad449f..8e4bf5365ac6 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -219,7 +219,8 @@ static void parse_gb_huge_pages(char *param, char *val) if (!strcmp(param, "hugepages") && gbpage_sz) { p = val; - max_gb_huge_pages = simple_strtoull(p, &p, 0); + if (boot_kstrtoul(p, 0, &max_gb_huge_pages)) + warn("Failed to parse hugepages= boot parameter\n"); return; } }