Blame SOURCES/0023-Fix-kmem-failing-to-print-task-context-when-address-.patch

3ce5e9
From 488896b1ab0ca8bc4cc6aa608b6ee1744ae480e7 Mon Sep 17 00:00:00 2001
3ce5e9
From: Tao Liu <ltao@redhat.com>
3ce5e9
Date: Mon, 19 Sep 2022 17:49:21 +0800
3ce5e9
Subject: [PATCH 23/28] Fix "kmem" failing to print task context when address
3ce5e9
 is vmalloced stack
3ce5e9
3ce5e9
When kernel enabled CONFIG_VMAP_STACK, stack can be allocated to
3ce5e9
vmalloced area. Currently crash didn't handle the case, as a result,
3ce5e9
"kmem" will not print the task context as expected. This patch fix the
3ce5e9
bug by checking if the address is a vmalloced stack first.
3ce5e9
3ce5e9
Before:
3ce5e9
    crash> kmem ffffb7efce9bbe28
3ce5e9
       VMAP_AREA         VM_STRUCT                 ADDRESS RANGE                SIZE
3ce5e9
    ffff94eb9102c640  ffff94eb9102b140  ffffb7efce9b8000 - ffffb7efce9bd000    20480
3ce5e9
3ce5e9
	  PAGE         PHYSICAL      MAPPING       INDEX CNT FLAGS
3ce5e9
    ffffdd28220dc000 1883700000                0        0  1 50000000000000
3ce5e9
3ce5e9
After:
3ce5e9
    crash> kmem ffffb7efce9bbe28
3ce5e9
	PID: 847
3ce5e9
    COMMAND: "khungtaskd"
3ce5e9
       TASK: ffff94f8038f4000  [THREAD_INFO: ffff94f8038f4000]
3ce5e9
	CPU: 72
3ce5e9
      STATE: TASK_RUNNING (PANIC)
3ce5e9
3ce5e9
       VMAP_AREA         VM_STRUCT                 ADDRESS RANGE                SIZE
3ce5e9
    ffff94eb9102c640  ffff94eb9102b140  ffffb7efce9b8000 - ffffb7efce9bd000    20480
3ce5e9
3ce5e9
	  PAGE         PHYSICAL      MAPPING       INDEX CNT FLAGS
3ce5e9
    ffffdd28220dc000 1883700000                0        0  1 50000000000000
3ce5e9
3ce5e9
Signed-off-by: Tao Liu <ltao@redhat.com>
3ce5e9
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
3ce5e9
---
3ce5e9
 memory.c | 4 ++++
3ce5e9
 1 file changed, 4 insertions(+)
3ce5e9
3ce5e9
diff --git a/memory.c b/memory.c
3ce5e9
index a31a430e2823..e44b59d2e805 100644
3ce5e9
--- a/memory.c
3ce5e9
+++ b/memory.c
3ce5e9
@@ -13477,6 +13477,10 @@ kmem_search(struct meminfo *mi)
3ce5e9
 	 *  Check for a valid mapped address.
3ce5e9
 	 */
3ce5e9
 	if ((mi->memtype == KVADDR) && IS_VMALLOC_ADDR(mi->spec_addr)) {
3ce5e9
+		if ((task = stkptr_to_task(vaddr)) && (tc = task_to_context(task))) {
3ce5e9
+			show_context(tc);
3ce5e9
+			fprintf(fp, "\n");
3ce5e9
+		}
3ce5e9
 		if (kvtop(NULL, mi->spec_addr, &paddr, 0)) {
3ce5e9
 			mi->flags = orig_flags | VMLIST_VERIFY;
3ce5e9
 			dump_vmlist(mi);
3ce5e9
-- 
3ce5e9
2.37.1
3ce5e9