Thread (39 messages) 39 messages, 8 authors, 2022-02-09

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

From: Petr Mladek <pmladek@suse.com>
Date: 2022-02-08 11:51:28
Also in: live-patching, lkml

On Sun 2022-01-30 21:32:04, Aaron Tomlin wrote:
quoted hunk ↗ jump to hunk
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;
quoted hunk ↗ jump to hunk
 }
-#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.
quoted hunk ↗ jump to hunk
 }
-#endif /* CONFIG_LIVEPATCH */
 
 bool is_module_sig_enforced(void);
 void set_module_sig_enforced(void);
Otherwise, it looks good to me.

Best Regards,
Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help