]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/hugetlb: fix early boot crash on parameters without '=' separator
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 9 Apr 2026 10:54:40 +0000 (12:54 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 18 Apr 2026 07:10:55 +0000 (00:10 -0700)
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: 5b47c02967ab ("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>
mm/hugetlb.c

index 88009cd2a846c19d5ae56671ee13389e9be9c3b8..e8024574a2d4b4f7f6345c3059460af999c2d0d4 100644 (file)
@@ -4226,6 +4226,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;