From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 879A12EFD9B for ; Sun, 1 Mar 2026 12:13:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772367191; cv=none; b=d0Nailcpi6feezBIGnYvArpesnEd3rCsMiBUFKO9tf4sYnALxxqOTym2R/1uVBJI2hp9fopMdc59bzNiWkdp3FepwTOCUpOHa2mqD7j0IyO1oS3cpmYTKcb5kFYAGPPsG2Bcb0a2vpa2m4VGvlLbiCs1xMvxOjYDJTulC+KkgaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772367191; c=relaxed/simple; bh=uX8A44SxXKx1uH8L1Lk4KNdt6rElyXSaUriUmaLcTyI=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=mdHHqo+c9x3TGkxFc9XG2vuzJUNG/uIt2YkWsT+xMby2LiReFHNSRoTOSqFaAdgJLFIEX2zvc/Z7ctFkXapJEHDjb/oj3w3h1Y8YXY8hCkrak3/LqN3Kv9OE2w1Xe7AylwUJ+2OxrzjM/UESGkgyrDkBq1TNEhrL5DXi9Z5poIg= 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=FwuWru2G; arc=none smtp.client-ip=91.218.175.172 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="FwuWru2G" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772367186; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FRkD3wbtkceNfxmRtoUU+xZb4D0dkZtxHdFfwEotEkU=; b=FwuWru2GI+sMs3ZoxxmH8Sn3IVHPOg62BT4zqPDcDfOe+2TuZvuLQMXc7o1IsCIxTC759q yG4WVoxIMG6Ogfzzi815ZmFlm3NlS8JYe7/efnaP0fVlMamkE2L0RnRYkM0E8s55g64Kec l88nYpOLKsSs3AiQI8AU5wUsKoN1jIM= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81.1.4\)) Subject: Re: [PATCH RESEND] x86/boot: Replace simple_strtoull in parse_gb_huge_pages X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum In-Reply-To: <20260301104454.GBaaQYpia9Kcul6bbo@fat_crate.local> Date: Sun, 1 Mar 2026 13:13:01 +0100 Cc: Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Changyuan Lyu , Alexander Graf , Andrew Morton , "Mike Rapoport (Microsoft)" , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <1360622D-8B92-451B-80E8-7377F81028FB@linux.dev> References: <20260202173223.865709-1-thorsten.blum@linux.dev> <20260301104454.GBaaQYpia9Kcul6bbo@fat_crate.local> To: Borislav Petkov X-Migadu-Flow: FLOW_OUT On 1. Mar 2026, at 11:44, Borislav Petkov wrote: > On Mon, Feb 02, 2026 at 06:32:20PM +0100, Thorsten Blum wrote: >> Replace simple_strtoull() with the recommended boot_kstrtoul() for >> parsing the 'hugepages=3D' boot parameter. Unlike simple_strtoull(), = which >> returns an unsigned long long, boot_kstrtoul() converts the string >> directly to an unsigned long and avoids implicit casting. >=20 > "The respective kstrtol(), kstrtoll(), kstrtoul(), and kstrtoull() = functions > tend to be the correct replacements, though note that those require = the string > to be NUL or newline terminated." >=20 > Where are we making sure of that? next_arg() provides NUL-terminated substrings, but 'val' could be NULL when '=3D' is missing in the boot parameter, but that would also break memparse() and simple_strtoull(). Should I fix this for both 'hugepagesz' and 'hugepages' in this patch? Something like this: diff --git a/arch/x86/boot/compressed/kaslr.c = b/arch/x86/boot/compressed/kaslr.c index 3b0948ad449f..b98b574dd937 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -202,9 +202,15 @@ static unsigned long max_gb_huge_pages; static void parse_gb_huge_pages(char *param, char *val) { static bool gbpage_sz; - char *p; =20 if (!strcmp(param, "hugepagesz")) { + char *p; + + if (!val) { + warn("Missing value in hugepagesz=3D boot = parameter\n"); + return; + } + p =3D val; if (memparse(p, &p) !=3D PUD_SIZE) { gbpage_sz =3D false; @@ -218,8 +224,13 @@ static void parse_gb_huge_pages(char *param, char = *val) } =20 if (!strcmp(param, "hugepages") && gbpage_sz) { - p =3D val; - max_gb_huge_pages =3D simple_strtoull(p, &p, 0); + if (!val) { + warn("Missing value in hugepages=3D boot = parameter\n"); + return; + } + + if (boot_kstrtoul(val, 0, &max_gb_huge_pages)) + warn("Failed to parse hugepages=3D boot = parameter\n"); return; } }