Skip to contentSkip to conversation

livepatch.h: Add comment to klp transition state

PATCH In review [email protected] 3 participants 4 messages Apr 29, 2024 – May 6, 2024 Live patching

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 livepatch.h: Add comment to klp transition state

From: Wardenjohn <[email protected]>

livepatch.h use KLP_UNDEFINED\KLP_UNPATCHED\KLP_PATCHED for klp transition state. When livepatch is ready but idle, using KLP_UNDEFINED seems very confusing. In order not to introduce potential risks to kernel, just update comment to these state.

---
 include/linux/livepatch.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/livepatch.h +3 -3
index 9b9b38e89563..b6a214f2f8e3 100644
@@ -18,9 +18,9 @@
 #if IS_ENABLED(CONFIG_LIVEPATCH)
 
 /* task patch states */
-#define KLP_UNDEFINED	-1
-#define KLP_UNPATCHED	 0
-#define KLP_PATCHED	 1
+#define KLP_UNDEFINED	-1 /* idle, no transition in progress */
+#define KLP_UNPATCHED	 0 /* transitioning to unpatched state */
+#define KLP_PATCHED	 1 /* transitioning to patched state */
 
 /**
  * struct klp_func - function structure for live patching
Signature · 1 line
2.37.3
maintainer
#1 lore raw
Quoted 15 lines · On Mon, Apr 29, 2024 at 03:26:28PM +0800, [email protected] wrote:

From: Wardenjohn <[email protected]>

livepatch.h use KLP_UNDEFINED\KLP_UNPATCHED\KLP_PATCHED for klp transition state. When livepatch is ready but idle, using KLP_UNDEFINED seems very confusing. In order not to introduce potential risks to kernel, just update comment to these state.

---
 include/linux/livepatch.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/livepatch.h +0 -0
index 9b9b38e89563..b6a214f2f8e3 100644

include/linux/livepatch.h line 23

Quoted 9 lines
include/linux/livepatch.h +3 -3
@@ -18,9 +18,9 @@
 #if IS_ENABLED(CONFIG_LIVEPATCH)
 
 /* task patch states */
-#define KLP_UNDEFINED	-1
-#define KLP_UNPATCHED	 0
-#define KLP_PATCHED	 1
+#define KLP_UNDEFINED	-1 /* idle, no transition in progress */
+#define KLP_UNPATCHED	 0 /* transitioning to unpatched state */
+#define KLP_PATCHED	 1 /* transitioning to patched state */

Instead of the comments, how about we just rename them to

KLP_TRANSITION_IDLE
KLP_TRANSITION_UNPATCHED
KLP_TRANSITION_PATCHED

which shouldn't break userspace AFAIK.

Signature · 1 line
Josh
#2 lore raw
Quoted 32 lines · Josh Poimboeuf
Quoted 15 lines · On Mon, Apr 29, 2024 at 03:26:28PM +0800, [email protected] wrote:

From: Wardenjohn <[email protected]>

livepatch.h use KLP_UNDEFINED\KLP_UNPATCHED\KLP_PATCHED for klp transition state. When livepatch is ready but idle, using KLP_UNDEFINED seems very confusing. In order not to introduce potential risks to kernel, just update comment to these state.
---
include/linux/livepatch.h | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/livepatch.h +0 -0
index 9b9b38e89563..b6a214f2f8e3 100644

include/linux/livepatch.h line 23

Quoted 9 lines
include/linux/livepatch.h +3 -3
@@ -18,9 +18,9 @@
 #if IS_ENABLED(CONFIG_LIVEPATCH)
 
 /* task patch states */
-#define KLP_UNDEFINED -1
-#define KLP_UNPATCHED  0
-#define KLP_PATCHED  1
+#define KLP_UNDEFINED -1 /* idle, no transition in progress */
+#define KLP_UNPATCHED  0 /* transitioning to unpatched state */
+#define KLP_PATCHED  1 /* transitioning to patched state */

Instead of the comments, how about we just rename them to

Quoted 8 lines

KLP_TRANSITION_IDLE
KLP_TRANSITION_UNPATCHED
KLP_TRANSITION_PATCHED

which shouldn't break userspace AFAIK.

Signature · 1 line
Josh

Hi Josh!

Renaming them may be a better way as my previous patch. I would like to know why renaming KLP_*** into KLP_TRANSITION_*** will not break userspace while
Renaming KLP_UNDEWFINED to KLP_IDLE would break the userspace.

Meanwhile, I will resubmit another patch renaming the macros as your suggestion ASAP. Thank ~~ :)

--
Wardenjohn

maintainer
#3 lore raw
Quoted 32 lines · zhang warden
Quoted 32 lines · Josh Poimboeuf
Quoted 15 lines · On Mon, Apr 29, 2024 at 03:26:28PM +0800, [email protected] wrote:

From: Wardenjohn <[email protected]>

livepatch.h use KLP_UNDEFINED\KLP_UNPATCHED\KLP_PATCHED for klp transition state. When livepatch is ready but idle, using KLP_UNDEFINED seems very confusing. In order not to introduce potential risks to kernel, just update comment to these state.
---
include/linux/livepatch.h | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/livepatch.h +0 -0
index 9b9b38e89563..b6a214f2f8e3 100644

include/linux/livepatch.h line 23

Quoted 9 lines
include/linux/livepatch.h +3 -3
@@ -18,9 +18,9 @@
 #if IS_ENABLED(CONFIG_LIVEPATCH)
 
 /* task patch states */
-#define KLP_UNDEFINED -1
-#define KLP_UNPATCHED  0
-#define KLP_PATCHED  1
+#define KLP_UNDEFINED -1 /* idle, no transition in progress */
+#define KLP_UNPATCHED  0 /* transitioning to unpatched state */
+#define KLP_PATCHED  1 /* transitioning to patched state */

Instead of the comments, how about we just rename them to

Quoted 5 lines
Quoted 5 lines

KLP_TRANSITION_IDLE
KLP_TRANSITION_UNPATCHED
KLP_TRANSITION_PATCHED

which shouldn't break userspace AFAIK.

Great idea! It is better then nothing.

Quoted 3 lines

Renaming them may be a better way as my previous patch. I would like to know why renaming KLP_*** into KLP_TRANSITION_*** will not break userspace while
Renaming KLP_UNDEWFINED to KLP_IDLE would break the userspace.

As I already wrote in [1], both "task->patch_state == KLP_UNDEFINED" and "KLP_IDLE" are misleading. They are not talking
about the state of the patch but about the state of the transition.

We could not rename the variables because it would break userspace. But we could rename the state names at least.

[1] https://lore.kernel.org/r/Zg7EpZol5jB_gHH9@alley

Best Regards,
Petr