[PATCH v1 05/19] livepatch: Remove "data" from struct klp_state

From
Petr Mladek <pmladek@suse.com>
Date
2025-01-15 08:25:35
Also in
lkml
Reply to
Petr Mladek, 2025-01-15
The "data" pointer in "struct klp_state" is associated with the lifetime of
the livepatch module, not the livepatch state. This means it's lost when a
livepatch is replaced, even if the new livepatch supports the same state.

Shadow variables provide a more reliable way to attach data to a livepatch
state. Their lifetime can be tied to the state's lifetime by:

- Sharing the same "id"
- Setting "is_shadow" in "struct klp_state"

Removing the "data" pointer prevents potential issues once per-object
callbacks are removed, as it cannot be used securely in that context.

Signed-off-by: Petr Mladek <pmladek@suse.com>
---
 include/linux/livepatch.h | 2 --
 1 file changed, 2 deletions(-)
diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index 56e71d488e71..d02d7a616338 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -175,14 +175,12 @@ struct klp_state_callbacks {
  * @block_disable: the state disablement is not supported
  * @is_shadow:	the state handles lifetime of a shadow variable with
  *		the same @id
- * @data:	custom data
  */
 struct klp_state {
 	unsigned long id;
 	struct klp_state_callbacks callbacks;
 	bool block_disable;
 	bool is_shadow;
-	void *data;
 };
 
 /**
-- 
2.47.1
Thread (24 messages) 24 messages, 2 authors, last reply 2025-03-17
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help