[PATCH] riscv: Fix a NULL pointer reference in machine_kexec_prepare

Baoquan He baoquan.he at linux.dev
Sun Jun 28 19:44:54 PDT 2026


On 06/28/26 at 10:38am, Tao Liu wrote:
......
> > >                /*
> > >                 * Some segments (e.g. IMA) reserve space but have no buffer
> > >                 * loaded yet. Skip them as they cannot contain an FDT.
> > >                 */
> > > And is there any other place where the similar issue exists? e.g on LoongArch?
> 
> I have tested in LoongArch, it doesn't have the similar issue. The
> reason is, in arch/loongarch/kernel/machine_kexec.c:machine_kexec_prepare(),
> the unchecked memcpy() only happens for none kexec file load, however
> ima_add_kexec_buffer() requires kexec file load. So the condition
> isn't met.

OK, that's good, thanks for the effort.

> 
> > >
> > > Other than above concerns, this patch looks good to me:
> > >
> > > Acked-by: Baoquan He <bhe at redhat.com>
> 
> Thanks for your code review and suggestions!
> 
> Thanks,
> Tao Liu
> 
> > >
> > > > >                 if (image->file_mode)
> > > > >                         memcpy(&fdt, image->segment[i].buf, sizeof(fdt));
> > > > >                 else if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt)))
> > > > > --
> > > > > 2.47.0
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > linux-riscv mailing list
> > > > linux-riscv at lists.infradead.org
> > > > http://lists.infradead.org/mailman/listinfo/linux-riscv
> > > >
> > >
> 



More information about the linux-riscv mailing list