2021-05-14 19:56:38

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH v2] module: check for exit sections in layout_sections() instead of module_init_section()

On Fri, May 14, 2021 at 06:09:04PM +0200, Jessica Yu wrote:
> Previously, when CONFIG_MODULE_UNLOAD=n, the module loader just does not
> attempt to load exit sections since it never expects that any code in those
> sections will ever execute. However, dynamic code patching (alternatives,
> jump_label and static_call) can have sites in __exit code, even if __exit is
> never executed. Therefore __exit must be present at runtime, at least for as
> long as __init code is.
>
> Commit 33121347fb1c ("module: treat exit sections the same as init
> sections when !CONFIG_MODULE_UNLOAD") solves the requirements of
> jump_labels and static_calls by putting the exit sections in the init
> region of the module so that they are at least present at init, and
> discarded afterwards. It does this by including a check for exit
> sections in module_init_section(), so that it also returns true for exit
> sections, and the module loader will automatically sort them in the init
> region of the module.
>
> However, the solution there was not completely arch-independent. ARM is
> a special case where it supplies its own module_{init, exit}_section()
> functions. Instead of pushing the exit section checks into
> module_init_section(), just implement the exit section check in
> layout_sections(), so that we don't have to touch arch-dependent code.
>
> Fixes: 33121347fb1c ("module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD")
> Signed-off-by: Jessica Yu <[email protected]>

Looks good!

Reviewed-by: Russell King (Oracle) <[email protected]>

Thanks!

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!


2021-05-17 08:01:00

by Jessica Yu

[permalink] [raw]
Subject: Re: [PATCH v2] module: check for exit sections in layout_sections() instead of module_init_section()

+++ Russell King (Oracle) [14/05/21 18:09 +0100]:
>On Fri, May 14, 2021 at 06:09:04PM +0200, Jessica Yu wrote:
>> Previously, when CONFIG_MODULE_UNLOAD=n, the module loader just does not
>> attempt to load exit sections since it never expects that any code in those
>> sections will ever execute. However, dynamic code patching (alternatives,
>> jump_label and static_call) can have sites in __exit code, even if __exit is
>> never executed. Therefore __exit must be present at runtime, at least for as
>> long as __init code is.
>>
>> Commit 33121347fb1c ("module: treat exit sections the same as init
>> sections when !CONFIG_MODULE_UNLOAD") solves the requirements of
>> jump_labels and static_calls by putting the exit sections in the init
>> region of the module so that they are at least present at init, and
>> discarded afterwards. It does this by including a check for exit
>> sections in module_init_section(), so that it also returns true for exit
>> sections, and the module loader will automatically sort them in the init
>> region of the module.
>>
>> However, the solution there was not completely arch-independent. ARM is
>> a special case where it supplies its own module_{init, exit}_section()
>> functions. Instead of pushing the exit section checks into
>> module_init_section(), just implement the exit section check in
>> layout_sections(), so that we don't have to touch arch-dependent code.
>>
>> Fixes: 33121347fb1c ("module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD")
>> Signed-off-by: Jessica Yu <[email protected]>
>
>Looks good!
>
>Reviewed-by: Russell King (Oracle) <[email protected]>
>
>Thanks!

Queued, thanks for the review Russell!

Jessica