From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 3353A3B6C0B for ; Thu, 9 Apr 2026 10:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775732179; cv=none; b=p8r2cJUkf5sokC7ewEBQ9FVhJsliwibcMc7TTQLIXn1CoFiwoKoxm05a2jI515HtIZAVGlrXSInYs21c1hTTBC7GooK/hp29n2gRY+V4opaJ5tQav9sHh+hQtORPIexXqBk0TdZczrAyHWVWT+NTP1gVw7el4leSsxEfOoNf5fc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775732179; c=relaxed/simple; bh=lHhYUZEteG6CqChaxjtIhI6uj6mYGGHKGTcq5jFslNY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MK22aKFCRCmoaw/e5ocgE23NFiyxA4xtm+tA1PpyKjYfHwyDrYSgtmiBLvg10vFX7uNGnGRK2j9weGrmpvSAwPWlBJF7YSUSrGzePuDJRfKsmn7lBZzpva0XH+FHwEJpdVhfCDiverFG2vp7bOnlM5YfmMYqVbrOci2PdA/La8k= 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=jTkQ23nS; arc=none smtp.client-ip=91.218.175.173 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="jTkQ23nS" 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=1775732166; 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=RXnQZXBYa3vuKgwomSApzbPI2ilGOJnfCFu3tAYxZYE=; b=jTkQ23nSIGAct5EbtU5wkME0Jo50XoaZjEwlRExYqRInSP5Yd7p8AkLyAUK5xLR6A3FxqY Kko6YFhj1Zn8GGVbS5M9yh8K84G8GbczwZC/phUvWnrqbD3MIEzbERI7qeK6WVg1uxvjhV lyhokgv6Erru55AunByy49Tqi6a+2kU= From: Thorsten Blum To: Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Frank van der Linden Cc: Thorsten Blum , stable@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/hugetlb: fix early boot crash on parameters without '=' separator Date: Thu, 9 Apr 2026 12:54:40 +0200 Message-ID: <20260409105437.108686-4-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=918; i=thorsten.blum@linux.dev; h=from:subject; bh=2OC4+YvS7JeDbioJ5TEwE9zyKJ+wa0upJUfw7ypAZ/A=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJnXW3PrJqhuWL3/6r7vc7iSeKs+XHm+dMOc63csZ5RJm n2wfOFs01HKwiDGxSArpsjyYNaPGb6lNZWbTCJ2wsxhZQIZwsDFKQATOfid4X+oVwFfyc2fU3im H1itdVKYz+rD9wWPPmUyKE73Fz9yNrWPkWHe6ab5DzPkRH9oq2b47Xpw29stbME+7Slndsxtu/2 Q24gVAA== X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT If hugepages, hugepagesz, or default_hugepagesz are specified on the kernel command line without the '=' separator, early parameter parsing passes NULL to hugetlb_add_param(), which dereferences it in strlen() and can crash the system during early boot. Reject NULL values in hugetlb_add_param() and return -EINVAL instead. Fixes: 5b47c02967ab ("mm/hugetlb: convert cmdline parameters from setup to early") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum --- mm/hugetlb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 327eaa4074d3..9fda39132d26 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4252,6 +4252,9 @@ static __init int hugetlb_add_param(char *s, int (*setup)(char *)) size_t len; char *p; + if (!s) + return -EINVAL; + if (hugetlb_param_index >= HUGE_MAX_CMDLINE_ARGS) return -EINVAL;