Summary of modules changes for the 5.13 merge window:

- Fix an age old bug involving jump_calls and static_labels when
  can't unload modules, so normally the __exit sections of a module are
  not loaded at all. However, dynamic code patching (jump_label,
  static_call, alternatives) can have sites in __exit sections even if
  __exit is never executed.

  Reported by Peter Zijlstra: "Alternatives, jump_labels and static_call
  all can have relocations into __exit code.  Not loading it at all would
  be BAD." Therefore, load the __exit sections even when
  CONFIG_MODULE_UNLOAD=n, and discard them after init.

Signed-off-by: Jessica Yu <>
module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD

Dynamic code patching (alternatives, jump_label and static_call) can
have sites in __exit code, even it __exit is never executed. Therefore
__exit must be present at runtime, at least for as long as __init code

Additionally, for jump_label and static_call, the __exit sites must also
identify as within_module_init(), such that the infrastructure is aware
to never touch them after module init -- alternatives are only ran once
at init and hence don't have this particular constraint.

By making __exit identify as __init for MODULE_UNLOAD, the above is

So, when !CONFIG_MODULE_UNLOAD, the section ordering should look like the
following, with the .exit sections moved to the init region of the module.

Core section allocation order:
 	.note.* sections
 Init section allocation order:

[jeyu: thanks to Peter Zijlstra for most of changelog]

Acked-by: Peter Zijlstra (Intel) <>
Signed-off-by: Jessica Yu <>
1 file changed