From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (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 41B3523741 for ; Thu, 6 Aug 2026 00:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785977192; cv=none; b=NtLl1/JGtIoogEMlpnOtTaj8YK4AUodZWbWlojBhR/ApPNxGx6G0NzhgkPgkqjhT+O4kqT9444X3HUl1VUCr8VB9wUGylzD2ix1xkC5nbQLhSqci2vGjbMlIifNGmU5iIfStMT9Q1e0WQ5NnLeSajzFmjs/Dw8De/nDs6F0M4/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785977192; c=relaxed/simple; bh=BWxzPJlDOQrzqqF1GTcQaxD8NPg/gUz5h0hFSKTSxE8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=m5BVymwRHYdBaKQWB5Su75IxTG6k3JtT6fCHVLk9YJYaloAMBj1Bqg7THefPl/5x5XMC9eQ1XZp3yXn8lytzUTEmDm0UDSvqSzrezsofTHKOAGkIqh2Jg1DVbIvFCEMTmQ26DMZyEBi7dDM6DcEOxaVrRvDeN0SSCbNaQolWXPI= 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=OYcIFQGy; arc=none smtp.client-ip=91.218.175.185 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="OYcIFQGy" 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=1785977186; 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=YhvDn5Po+cfi6IVgjrY4eL8GriNDWwITsE8A7C/EfUI=; b=OYcIFQGyXZmmROar6HLe4YuJb2xX8DmpoeTyDs2CfsSRPuhRheccDrdUlQ4ZinsKyDFFVh Xq1kxfZgh20HA6XJ+2c7I6cwmY3k5MhH07RTdzdfAggjbWeTAti416QRnBTtaCjicSthz7 sctG6P3OPE9di/FDI5fUsonh37WN08Q= From: Ye Liu To: Andrew Morton , Vlastimil Babka Cc: Ye Liu , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: debug_page_alloc: fix NULL buf in debug_guardpage_minorder_setup Date: Thu, 6 Aug 2026 08:45:55 +0800 Message-Id: <20260806004556.2633049-1-ye.liu@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Ye Liu If the kernel command line includes "debug_guardpage_minorder" without an equals sign (i.e., no value is provided), the early parameter parser passes a NULL buf pointer to the setup function. kstrtouint() does not perform a NULL check on its input and calls directly into kstrtoull() which dereferences s[0] unconditionally, leading to a NULL pointer dereference and early boot crash. Additionally, the error path's pr_err("%s", buf) would also crash with a NULL format argument. Signed-off-by: Ye Liu --- mm/debug_page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/debug_page_alloc.c b/mm/debug_page_alloc.c index 41e3d1f1ad96..fd2664c3c86a 100644 --- a/mm/debug_page_alloc.c +++ b/mm/debug_page_alloc.c @@ -22,8 +22,8 @@ static int __init debug_guardpage_minorder_setup(char *buf) { unsigned int res; - if (kstrtouint(buf, 10, &res) < 0 || res > MAX_PAGE_ORDER / 2) { - pr_err("Bad debug_guardpage_minorder value: %s\n", buf); + if (!buf || kstrtouint(buf, 10, &res) < 0 || res > MAX_PAGE_ORDER / 2) { + pr_err("Bad debug_guardpage_minorder value: %s\n", buf ?: "(missing)"); return 0; } _debug_guardpage_minorder = res; -- 2.25.1