Re: [PATCH] Fix kmem failing to print task context when address is vmalloced stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022/08/24 13:08, Tao Liu wrote:
> When kernel enabled CONFIG_VMAP_STACK, stack can be allocated to
> vmalloced area. Currently crash didn't handle the case, as a result,
> kmem will not print the task context as expected. This patch fix the
> bug by checking if the address is a vmalloced stack first.

Good catch, again.  Thank you for the patch.

> 
> Before:
>      crash> kmem ffffb7efce9bbe28
>         VMAP_AREA         VM_STRUCT                 ADDRESS RANGE                SIZE
>      ffff94eb9102c640  ffff94eb9102b140  ffffb7efce9b8000 - ffffb7efce9bd000    20480
> 
> 	  PAGE         PHYSICAL      MAPPING       INDEX CNT FLAGS
>      ffffdd28220dc000 1883700000                0        0  1 50000000000000
> 
> After:
>      crash> kmem ffffb7efce9bbe28
> 	PID: 847
>      COMMAND: "khungtaskd"
>         TASK: ffff94f8038f4000  [THREAD_INFO: ffff94f8038f4000]
> 	CPU: 72
>        STATE: TASK_RUNNING (PANIC)
> 
> 	  PAGE         PHYSICAL      MAPPING       INDEX CNT FLAGS
>      ffffdd28220dc000 1883700000                0        0  1 50000000000000

I feel like it might be better to print the VMAP_AREA info too
even if it's an address of process's stack.  For example,

crash> kmem ffff9b6dc017ff50
     PID: 1
COMMAND: "systemd"
    TASK: ffff8f96c159c8c0  [THREAD_INFO: ffff8f96c159c8c0]
     CPU: 6
   STATE: TASK_INTERRUPTIBLE

    VMAP_AREA         VM_STRUCT                 ADDRESS RANGE                SIZE
ffff8f96c7c25080  ffff8f96c7d48dc0  ffff9b6dc017c000 - ffff9b6dc0181000    20480

       PAGE        PHYSICAL      MAPPING       INDEX CNT FLAGS
fffff043bb9910c0 ee6443000                0        0  1 17ffffc0000000


So, can we remove the "goto mem_map;" below ?

Thanks,
Kazu


> 
> Signed-off-by: Tao Liu <ltao@xxxxxxxxxx>
> ---
>   memory.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/memory.c b/memory.c
> index 7339f0c..7a1bf9c 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -13477,6 +13477,11 @@ kmem_search(struct meminfo *mi)
>   	 *  Check for a valid mapped address.
>   	 */
>   	if ((mi->memtype == KVADDR) && IS_VMALLOC_ADDR(mi->spec_addr)) {
> +		if ((task = stkptr_to_task(vaddr)) && (tc = task_to_context(task))) {
> +			show_context(tc);
> +			fprintf(fp, "\n");
> +			goto mem_map;
> +		}
>   		if (kvtop(NULL, mi->spec_addr, &paddr, 0)) {
>   			mi->flags = orig_flags | VMLIST_VERIFY;
>   			dump_vmlist(mi);
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux