Message ID | 20190201162608.20815-1-jean-philippe.brucker@arm.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Commit | ea5736805190e912903c27c9f17c7a4341a405e9 |
Headers | show |
Series | arm64: kexec_file: handle empty command-line | expand |
On Fri, Feb 01, 2019 at 04:26:08PM +0000, Jean-Philippe Brucker wrote: > Calling strlen() on cmdline == NULL produces a segfault. Since having a > NULL cmdline is valid, handle this case explicitly. By "segfault" you mean kernel oops, right? If so, I'll pick this up as a fix, thanks. Will
On 05/02/2019 09:34, Will Deacon wrote: > On Fri, Feb 01, 2019 at 04:26:08PM +0000, Jean-Philippe Brucker wrote: >> Calling strlen() on cmdline == NULL produces a segfault. Since having a >> NULL cmdline is valid, handle this case explicitly. > > By "segfault" you mean kernel oops, right? If so, I'll pick this up as a > fix, thanks. Yes, that's what I meant Thanks, Jean
diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index f2c211a6229b..58871333737a 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -120,10 +120,12 @@ static int create_dtb(struct kimage *image, { void *buf; size_t buf_size; + size_t cmdline_len; int ret; + cmdline_len = cmdline ? strlen(cmdline) : 0; buf_size = fdt_totalsize(initial_boot_params) - + strlen(cmdline) + DTB_EXTRA_SPACE; + + cmdline_len + DTB_EXTRA_SPACE; for (;;) { buf = vmalloc(buf_size);
Calling strlen() on cmdline == NULL produces a segfault. Since having a NULL cmdline is valid, handle this case explicitly. Fixes: 52b2a8af7436 ("arm64: kexec_file: load initrd and device-tree") Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> --- arch/arm64/kernel/machine_kexec_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)