mm/hugetlb: fix early boot crash on parameters without '=' separator
Subsystems (3)
PATCH 1/1 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.
Fixes 5b47c02967ab ("mm/hugetlb: convert cmdline parameters from setup to early")
Signed-off-by Thorsten Blum <[email protected]>
--- mm/hugetlb.c | 3 +++ 1 file changed, 3 insertions(+)
mm/hugetlb.c +3 -0
@@ -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 ;
Quoted 9 lines · Thorsten Blum
If hugepages, hugepagesz, or
default_hugepageszare specified on the kernel command line without the '=' separator, early parameter parsing passes NULL tohugetlb_add_param(), which dereferences it instrlen()and can crash the system during early boot.
Quoted 5 lines
Reject NULL values in
hugetlb_add_param()and return-EINVALinstead.Fixes 5b47c02967ab ("mm/hugetlb: convert cmdline parameters from setup to early")Signed-off-by Thorsten Blum <[email protected]>
Reviewed-by Muchun Song <[email protected]>
Thanks.