# \[PATCH v1 05/19\] livepatch: Remove "data" from struct klp\_state

- From: Petr Mladek \<pmladek@suse.com\>
- Date: 2025-01-15 08:25:35 
- List: live-patching
- Page: https://ratatoskr.run/live-patching/2025/01/2890889
- Thread: https://ratatoskr.run/live-patching/2025/01/2890883/t.md

```text
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

```
