Skip to content

Commit c45b354

Browse files
tobluxakpm00
authored andcommitted
mm/hugetlb: fix early boot crash on parameters without '=' separator
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. Link: https://lore.kernel.org/20260409105437.108686-4-thorsten.blum@linux.dev Fixes: 5b47c02 ("mm/hugetlb: convert cmdline parameters from setup to early") Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Muchun Song <muchun.song@linux.dev> Cc: David Hildenbrand <david@kernel.org> Cc: Frank van der Linden <fvdl@google.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 2f529e7 commit c45b354

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

mm/hugetlb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4226,6 +4226,9 @@ static __init int hugetlb_add_param(char *s, int (*setup)(char *))
42264226
size_t len;
42274227
char *p;
42284228

4229+
if (!s)
4230+
return -EINVAL;
4231+
42294232
if (hugetlb_param_index >= HUGE_MAX_CMDLINE_ARGS)
42304233
return -EINVAL;
42314234

0 commit comments

Comments
 (0)