Skip to contentSkip to conversation

mm/kfence: print disabling or re-enabling message

PATCH Superseded Jackie Liu 2 participants 3 messages May 18, 2022

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jackie Liu

author
#0 lore raw

PATCH v3 1/1 mm/kfence: print disabling or re-enabling message

From: Jackie Liu <[email protected]>

By printing information, we can friendly prompt the status change information of kfence by dmesg and record by syslog.

---
v1->v2:
fixup by Marco Elver <[email protected]>
v2->v3:
write kfence_enabled=false only true before

 mm/kfence/core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
mm/kfence/core.c +8 -2
index 11a954763be9..41840b8d9cb3 100644
@@ -67,8 +67,13 @@ static int param_set_sample_interval(const char *val, const struct kernel_param
 	if (ret < 0)
 		return ret;
 
-	if (!num) /* Using 0 to indicate KFENCE is disabled. */
-		WRITE_ONCE(kfence_enabled, false);
+	/* Using 0 to indicate KFENCE is disabled. */
+	if (!num) {
+		if (READ_ONCE(kfence_enabled)) {
+			pr_info("disabled\n");
+			WRITE_ONCE(kfence_enabled, false);
+		}
+	}
 
 	*((unsigned long *)kp->arg) = num;
 
@@ -874,6 +879,7 @@ static int kfence_enable_late(void)
 
 	WRITE_ONCE(kfence_enabled, true);
 	queue_delayed_work(system_unbound_wq, &kfence_timer, 0);
+	pr_info("re-enabled\n");
 	return 0;
 }
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 22 lines · Jackie Liu

From: Jackie Liu <[email protected]>

By printing information, we can friendly prompt the status change information of kfence by dmesg and record by syslog.

---
v1->v2:
fixup by Marco Elver <[email protected]>
v2->v3:
write kfence_enabled=false only true before

 mm/kfence/core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
mm/kfence/core.c +0 -0
index 11a954763be9..41840b8d9cb3 100644

mm/kfence/core.c static int param_set_sample_interval(const char *val, const struct kernel_param · line 72

Quoted 8 lines
mm/kfence/core.c +3 -2
@@ -67,8 +67,13 @@ static int param_set_sample_interval(const char *val, const struct kernel_param
        if (ret < 0)
                return ret;
 
-       if (!num) /* Using 0 to indicate KFENCE is disabled. */
-               WRITE_ONCE(kfence_enabled, false);
+       /* Using 0 to indicate KFENCE is disabled. */
+       if (!num) {
+               if (READ_ONCE(kfence_enabled)) {

Now you could just write

  if (!num && READ_ONCE(kfence_enabled)) {
    ....
Quoted 18 lines
mm/kfence/core.c +5 -1
+                       pr_info("disabled\n");
+                       WRITE_ONCE(kfence_enabled, false);
+               }
+       }
 
        *((unsigned long *)kp->arg) = num;
 
@@ -874,6 +879,7 @@ static int kfence_enable_late(void)
 
        WRITE_ONCE(kfence_enabled, true);
        queue_delayed_work(system_unbound_wq, &kfence_timer, 0);
+       pr_info("re-enabled\n");
        return 0;
 }
 
--

2.25.1

author
#2 lore raw
Quoted 34 lines · Marco Elver
Quoted 22 lines · Jackie Liu

From: Jackie Liu <[email protected]>

By printing information, we can friendly prompt the status change information of kfence by dmesg and record by syslog.

---
v1->v2:
fixup by Marco Elver <[email protected]>
v2->v3:
write kfence_enabled=false only true before

  mm/kfence/core.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
mm/kfence/core.c +0 -0
index 11a954763be9..41840b8d9cb3 100644

mm/kfence/core.c static int param_set_sample_interval(const char *val, const struct kernel_param · line 72

Quoted 8 lines
mm/kfence/core.c +3 -2
@@ -67,8 +67,13 @@ static int param_set_sample_interval(const char *val, const struct kernel_param
         if (ret < 0)
                 return ret;
 
-       if (!num) /* Using 0 to indicate KFENCE is disabled. */
-               WRITE_ONCE(kfence_enabled, false);
+       /* Using 0 to indicate KFENCE is disabled. */
+       if (!num) {
+               if (READ_ONCE(kfence_enabled)) {

Now you could just write

Quoted 1 line
   if (!num && READ_ONCE(kfence_enabled)) {

Sure.

Quoted 20 lines
     ....
Quoted 18 lines
mm/kfence/core.c +5 -1
+                       pr_info("disabled\n");
+                       WRITE_ONCE(kfence_enabled, false);
+               }
+       }
 
         *((unsigned long *)kp->arg) = num;
 
@@ -874,6 +879,7 @@ static int kfence_enable_late(void)
 
         WRITE_ONCE(kfence_enabled, true);
         queue_delayed_work(system_unbound_wq, &kfence_timer, 0);
+       pr_info("re-enabled\n");
         return 0;
  }
 
--

2.25.1