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

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