Re: [PATCH v7 00/15] kexec: Fix CMA and elf header leaks and rework

From: Jinjie Ruan

Date: Wed Nov 04 2026 - 22:46:30 EST




在 2026/11/4 22:56, Mike Rapoport 写道:
> Hi Jinjie,
>

Hi Mike,

>> ARM64, LoongArch and RISC-V load the elf core header, initrd, DTB
>> and cmdline parameters with almost identical code. This series fixes
>> the bugs in that path. And as Mike suggested, rework the common part
>> into a helper.
>>
>> Patch 1 stops using the Image text_offset for arm64, which breaks CMA
>> segments in both the load and release paths, and rejects images with
>> a non-zero value.
>>
>> Patches 2-7 fix the CMA page and elf core header leaks in the retry
>> loops in arm64 and LoongArch, also fix a modified_cmdline leak
>> in LoongArch.
>
> These mix fixes that can be easily merged via arch trees and something
> that depends on a change to the generic kexec code.

Thank you! I will split them to send in v8.

>
> Besides, elf_headers leak and arm64's text_offset fixes should be
> applied to most if not all stable kernels, while CMA fixes are only for
> the relatively new kernels.

You are right. arm64 text_offset fix involves many versions.

If I remember correctly, the CMA patch that was fixed was only merged
this year.

>
> I'd suggest splitting
>
> arm64: kexec_file: Stop using the Image text_offset
> arm64: kexec_file: Fix elf_headers memory leak in retry loop
>
> and sending as pure arm64 material, and
>
>
> LoongArch: kexec_file: Fix elf_headers memory leak in retry loop
> LoongArch: kexec_file: Fix a modified_cmdline leak
>
> as pure LoongArch material.
>
> And then working on CMA fixes after these land.


I agree with doing this; the patch will be cleaner and won't mix
different architectures with common code.

>
> If there are real dependencies or potential conflicts, b4 prep can help
> you with managing them.

Indeed.

>
>> Patches 8-10 pass the kbuf fields to crash_prepare_headers() to
>> simplfy code.
>>
>> Patch 11 frees the elf core header from the generic post-load cleanup.
>>
>> Patches 12-15 add kexec_load_other_segments() and convert the three
>> architectures, and arch_kexec_setup_other_segments() builds
>> the architecture specific boot parameters (a DTB or a command line).
>
> I think the refactoring should go before the identical fixes in arch/
> code.

However, this will cause trouble for the fix patch in the stable round.

>

--
Best regards,
Jinjie