All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Liu <ltao@redhat.com>
To: yamazaki-msmt@nec.com, k-hagio-ab@nec.com, kexec@lists.infradead.org
Cc: aravinda@linux.vnet.ibm.com, stephen.s.brennan@oracle.com,
	kjlx@templeofstupid.com, Tao Liu <ltao@redhat.com>
Subject: [PATCH] Add erase_sample extension as an data erase reference
Date: Thu, 11 Jun 2026 11:42:50 +1200	[thread overview]
Message-ID: <20260610234249.10993-2-ltao@redhat.com> (raw)
In-Reply-To: <20260414102656.55200-1-ltao@redhat.com>

This patch will add a erase_sample.c as a data erase reference. It will
erase all tasks & threads's comm[] member within their task_struct, as
a result, you will see the ps info outputted by crash utility similiar
as follows:

 crash> ps
  ...
  1       0  10  ffff96b7c0980000  IN   0.0    25504    15704  XXXXXXXXXXXXXXX
  2       0  15  ffff96b7c0982f40  IN   0.0        0        0  [XXXXXXXXXXXXXXX]
  3       2   2  ffff96b7c09a0000  IN   0.0        0        0  [XXXXXXXXXXXXXXX]
  4       2   0  ffff96b7c09a2f40  ID   0.0        0        0  [XXXXXXXXXXXXXXX]
  5       2   0  ffff96b7c09a8000  ID   0.0        0        0  [XXXXXXXXXXXXXXX]

The comm[] erasure doesn't cause critical info loss and has slight
impact on vmcore analyze, so it is safe to take it as an example for
developers.

Signed-off-by: Tao Liu <ltao@redhat.com>
---

Hi maintainers,

This patch should be applied upon "[PATCH v5][makedumpfile 9/9] Add amdgpu mm
pages filtering extension". Since this patch doesn't do 
modifications on any previous patches, and you are reviewing v5, so I
post appended to v5. If this causes any confusing, I'm happy to post a
v6 with a cleaner format. Thanks!

---
 extensions/Makefile       |  2 +-
 extensions/erase_sample.c | 78 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 extensions/erase_sample.c

diff --git a/extensions/Makefile b/extensions/Makefile
index c1dbc4f..9dd4f8e 100644
--- a/extensions/Makefile
+++ b/extensions/Makefile
@@ -1,5 +1,5 @@
 CC ?= gcc
-CONTRIB_SO := sample.so amdgpu_filter.so
+CONTRIB_SO := sample.so erase_sample.so amdgpu_filter.so
 
 all: $(CONTRIB_SO)
 
diff --git a/extensions/erase_sample.c b/extensions/erase_sample.c
new file mode 100644
index 0000000..7c935d1
--- /dev/null
+++ b/extensions/erase_sample.c
@@ -0,0 +1,78 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "../makedumpfile.h"
+#include "../btf_info.h"
+#include "../kallsyms.h"
+#include "../extension.h"
+#include "../erase_info.h"
+
+INIT_MOD_STRUCT_MEMBER(vmlinux, task_struct, tasks);
+INIT_MOD_STRUCT_MEMBER(vmlinux, task_struct, thread_node);
+INIT_MOD_STRUCT_MEMBER(vmlinux, task_struct, signal);
+INIT_MOD_STRUCT_MEMBER(vmlinux, signal_struct, thread_head);
+INIT_MOD_STRUCT_MEMBER(vmlinux, task_struct, comm);
+INIT_MOD_SYM(vmlinux, init_task);
+
+#define MOD_MEMBER_OFF(MOD, S, M) \
+	GET_MOD_STRUCT_MEMBER_MOFF(MOD, S, M) / 8
+#define KERN_MEMBER_OFF(S, M) MOD_MEMBER_OFF(vmlinux, S, M)
+#define GET_KERN_STRUCT_MEMBER_MSIZE(S, M) \
+	GET_MOD_STRUCT_MEMBER_MSIZE(vmlinux, S, M)
+#define GET_KERN_SYM(SYM) GET_MOD_SYM(vmlinux, SYM)
+
+/* task_struct.comm eraser */
+static bool erase_task_struct_comm(void)
+{
+	uint64_t task_list, init_task, comm, signal, thread_head, thread_list;
+	uint32_t size;
+
+	init_task = GET_KERN_SYM(init_task);
+	size = GET_KERN_STRUCT_MEMBER_MSIZE(task_struct, comm);
+	task_list = init_task + KERN_MEMBER_OFF(task_struct, tasks);
+
+	/* Iterate all tasks */
+	do {
+		thread_list = task_list - KERN_MEMBER_OFF(task_struct, tasks) +
+			KERN_MEMBER_OFF(task_struct, thread_node);
+		if (!readmem(VADDR, task_list - KERN_MEMBER_OFF(task_struct, tasks) +
+			KERN_MEMBER_OFF(task_struct, signal), &signal, sizeof(uint64_t))) {
+			ERRMSG("Can't get task_struct member signal!\n");
+			goto out;
+		}
+		thread_head = signal + KERN_MEMBER_OFF(signal_struct, thread_head);
+
+		/* Iterate all threads of the task */
+		do {
+			comm = thread_list - KERN_MEMBER_OFF(task_struct, thread_node) +
+				KERN_MEMBER_OFF(task_struct, comm);
+
+			if (!update_filter_info_raw(comm, 'X', size)) {
+				ERRMSG("Failed update filter info!\n");
+				goto out;
+			}
+
+			thread_list = next_list(thread_list);
+		} while (thread_list != thread_head);
+
+		task_list = next_list(task_list);
+	} while (task_list != init_task + KERN_MEMBER_OFF(task_struct, tasks));
+
+	return true;
+out:
+	return false;
+}
+
+void extension_init(void)
+{
+	if (!erase_task_struct_comm()) {
+		ERRMSG("erase_sample.so: erase fail!\n");
+		goto out;
+	}
+	MSG("erase_sample.so: erase success!\n");
+out:
+	return;
+}
+
+__attribute__((destructor))
+void extension_cleanup(void) { }
+
-- 
2.47.0



      parent reply	other threads:[~2026-06-10 23:53 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 10:26 [PATCH v5][makedumpfile 0/9] btf/kallsyms based makedumpfile extension for mm page filtering Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 1/9] Reserve sections for makedumpfile and extenions Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 2/9] Implement kernel kallsyms resolving Tao Liu
2026-06-15  8:09   ` HAGIO KAZUHITO(萩尾 一仁)
2026-06-15 23:04     ` Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 3/9] Implement kernel btf resolving Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 4/9] Implement kernel module's kallsyms resolving Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 5/9] Implement kernel module's btf resolving Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 6/9] Add makedumpfile extensions support Tao Liu
2026-06-15  8:09   ` HAGIO KAZUHITO(萩尾 一仁)
2026-06-15 17:12     ` Stephen Brennan
2026-06-15 23:03       ` Tao Liu
2026-06-16  1:39         ` HAGIO KAZUHITO(萩尾 一仁)
2026-06-16  2:17           ` Tao Liu
2026-06-16  7:51             ` HAGIO KAZUHITO(萩尾 一仁)
2026-06-16 10:31               ` Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 7/9] Add sample extension as an example reference Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 8/9] Doc: Add --extension option to makedumpfile manual Tao Liu
2026-04-14 10:26 ` [PATCH v5][makedumpfile 9/9] Add amdgpu mm pages filtering extension Tao Liu
2026-05-20  4:55 ` [PATCH v5][makedumpfile 0/9] btf/kallsyms based makedumpfile extension for mm page filtering Tao Liu
2026-05-28 18:37 ` Stephen Brennan
2026-05-28 22:02   ` Tao Liu
2026-05-29 21:11 ` Krister Johansen
2026-06-01 23:12   ` Tao Liu
2026-06-02  0:47     ` Krister Johansen
2026-06-02  3:04       ` Tao Liu
2026-06-02  4:49         ` Krister Johansen
2026-06-11  1:24           ` Tao Liu
2026-06-10 23:42 ` Tao Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260610234249.10993-2-ltao@redhat.com \
    --to=ltao@redhat.com \
    --cc=aravinda@linux.vnet.ibm.com \
    --cc=k-hagio-ab@nec.com \
    --cc=kexec@lists.infradead.org \
    --cc=kjlx@templeofstupid.com \
    --cc=stephen.s.brennan@oracle.com \
    --cc=yamazaki-msmt@nec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.