Re: [RFC PATCH v4 03/13] module: Move livepatch support to a separate file

From: Petr Mladek
Date: Tue Feb 08 2022 - 06:51:28 EST


On Sun 2022-01-30 21:32:04, Aaron Tomlin wrote:
> No functional change.
>
> This patch migrates livepatch support (i.e. used during module
> add/or load and remove/or deletion) from core module code into
> kernel/module/livepatch.c. At the moment it contains code to
> persist Elf information about a given livepatch module, only.
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index f4338235ed2c..c7daac4d16ee 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -663,17 +663,23 @@ static inline bool module_requested_async_probing(struct module *module)
> return module && module->async_probe_requested;
> }
>
> -#ifdef CONFIG_LIVEPATCH
> static inline bool is_livepatch_module(struct module *mod)
> {
> - return mod->klp;
> + if (IS_ENABLED(CONFIG_LIVEPATCH)) {
> + if (mod->klp)
> + return true;
> + }
> + return false;

The following is easier to follow for me. But it is a matter of taste.
Feel free to use whatever you prefer.

return IS_ENABLED(CONFIG_LIVEPATCH) && mod->klp;

> }
> -#else /* !CONFIG_LIVEPATCH */
> -static inline bool is_livepatch_module(struct module *mod)
> +
> +static inline bool set_livepatch_module(struct module *mod)
> {
> + if (IS_ENABLED(CONFIG_LIVEPATCH)) {
> + mod->klp = true;
> + return true;
> + }
> return false;

This should go to internal.h.

Alternative is to move both is_livepatch_module() and
set_livepatch_module() into include/linux/livepatch.h.

I do not have strong opinion.

> }
> -#endif /* CONFIG_LIVEPATCH */
>
> bool is_module_sig_enforced(void);
> void set_module_sig_enforced(void);

Otherwise, it looks good to me.

Best Regards,
Petr