From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 2E9533BADB4 for ; Thu, 9 Apr 2026 11:07:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775732847; cv=none; b=olbOxKs+8SZjTfyeHiNI3pUZjDChWm33SA1jAvrl6TYRkva484L64eHQacX2pKhxCa6xvqots+hW9uZ6lyWSphvJOYQ6UJizKzaGRfIoIaY5Ln2qtf9vsljQ7szfDFioAf8flmp3hAGgSnBk80XDUao8YyTLSGm7r83a+JRiFeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775732847; c=relaxed/simple; bh=9JKGx38FSGG6Nz7wxP/TB3E0ebPEyEU8JlSvdZZ7I+o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a34at8Dhj/8pO/zMb5orJm3x6DXK1ehGBKj/OP0BmLX6wwsglQpjtDQiBOUKDQ+HUQr5tKwRPrDqEM8VtWNNRSijNsMcqp9HrfA9g2q3b//PrKUu3O1/lB9hR/QFzXdN5myLC8/rOqYyHg8B+RoP7fN9jJIMWGxgw5sydZYr//Q= 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=aMq3y8kY; arc=none smtp.client-ip=91.218.175.188 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="aMq3y8kY" Date: Thu, 9 Apr 2026 13:07:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775732844; 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: in-reply-to:in-reply-to:references:references; bh=3MOpz5+g3vfa9VgxYUiXiTPDPttF9omv9Zm7Y7PMt3M=; b=aMq3y8kYSk6U9TF0ya6Y/9TkYR10vSjPrmQ8LQXBHvijn1e+4kwhrbKyShdznxhl1jF8AL 1PmEl4vGdt5H3N4MydL5ojRcIdlIj4i7jeZPY1QseRpWoe33wkgR5u8Dq+xLzotpDVN1EU L1adr84WH1v7z77OOjzhsSnHHhUQ+kc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum To: Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Mike Rapoport (Microsoft)" , Andrew Morton , Changyuan Lyu , Alexander Graf , Baoquan He , stable@vger.kernel.org, Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/boot: Fix NULL dereference for missing hugepagesz/hugepages value Message-ID: References: <20260302205901.39610-1-thorsten.blum@linux.dev> <20260313204243.GIabR2w3PqVcFxg66B@fat_crate.local> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260313204243.GIabR2w3PqVcFxg66B@fat_crate.local> X-Migadu-Flow: FLOW_OUT On Fri, Mar 13, 2026 at 09:42:43PM +0100, Borislav Petkov wrote: > On Mon, Mar 02, 2026 at 09:58:59PM +0100, Thorsten Blum wrote: > > In parse_gb_huge_pages(), 'val' can be NULL if '=' is missing from the > > boot parameter. The code passes 'val' to memparse() and > > simple_strtoull(), which can dereference NULL. > > > > Reject 'hugepagesz' and 'hugepages' when no value has been provided and > > log a warning. > > > > Fixes: 9b912485e0e7 ("x86/boot/KASLR: Add two new functions for 1GB huge pages handling") > > Cc: stable@vger.kernel.org > > Signed-off-by: Thorsten Blum > > --- > > arch/x86/boot/compressed/kaslr.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c > > index 3b0948ad449f..88ccc3b2c5aa 100644 > > --- a/arch/x86/boot/compressed/kaslr.c > > +++ b/arch/x86/boot/compressed/kaslr.c > > @@ -205,6 +205,11 @@ static void parse_gb_huge_pages(char *param, char *val) > > char *p; > > > > if (!strcmp(param, "hugepagesz")) { > > + if (!val) { > > + warn("Missing value in hugepagesz= boot parameter\n"); > > + return; > > + } > > + > > p = val; > > if (memparse(p, &p) != PUD_SIZE) { > > gbpage_sz = false; > > @@ -218,6 +223,11 @@ static void parse_gb_huge_pages(char *param, char *val) > > } > > > > if (!strcmp(param, "hugepages") && gbpage_sz) { > > + if (!val) { > > + warn("Missing value in hugepages= boot parameter\n"); > > + return; > > + } > > + > > p = val; > > max_gb_huge_pages = simple_strtoull(p, &p, 0); > > return; > > The intent is good even if it is not working fully yet, see below. I fixed this with [*], which prevents parse_gb_huge_pages() from being called with a NULL pointer in the first place. Please drop this patch. > [...] Thanks, Thorsten [*] https://lore.kernel.org/lkml/20260409105437.108686-4-thorsten.blum@linux.dev/