Re: [POC 2/7] livepatch: Allow to handle lifetime of shadow variables using the livepatch state

From
Miroslav Benes <mbenes@suse.cz>
Date
2024-07-25 11:31:51
Also in
lkml
Reply to
Petr Mladek, 2023-11-10
quoted hunk ↗ jump to hunk
diff --git a/kernel/livepatch/state.c b/kernel/livepatch/state.c
index 6693d808106b..4ec65afe3a43 100644
--- a/kernel/livepatch/state.c
+++ b/kernel/livepatch/state.c
@@ -198,11 +198,17 @@ void klp_release_states(struct klp_patch *patch)
 		if (is_state_in_other_patches(patch, state))
 			continue;
 
-		if (!state->callbacks.release)
-			continue;
-
-		if (state->callbacks.setup_succeeded)
+		if (state->callbacks.release && state->callbacks.setup_succeeded)
 			state->callbacks.release(patch, state);
+
+		if (state->is_shadow)
+			klp_shadow_free_all(state->id, state->callbacks.shadow_dtor);
The following
quoted hunk ↗ jump to hunk
+		/*
+		 * The @release callback is supposed to restore the original
+		 * state before the @setup callback was called.
+		 */
+		state->callbacks.setup_succeeded = 0;
should go to the previous patch perhaps?

Miroslav
Thread (22 messages) 22 messages, 4 authors, last reply 2024-08-16
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