Hi lianbo,

Thanks for the fix, LGTM, ack.

Thanks,
Tao Liu

On Fri, Sep 5, 2025 at 3:52 PM Lianbo Jiang <[email protected]> wrote:
>
> I did some tests on the vmcore with Rust enabled, and found that
> the "dis -s" command may cause a segfault:
>
>   crash> dis -s _RNvCscb18lrEyTSA_10rust_panic10area_in_hp
>   Enable debuginfod for this session? (y or [n])
>   FILE: rust_panic.rs
>   LINE: 22
>
>   Segmentation fault         (core dumped) ./crash 
> /home/lijiang/src/rust/6.16.3-vmcore-rust/vmlinux 
> /home/lijiang/src/rust/6.16.3-vmcore-rust/vmcore
>
> gdb calltrace:
>   (gdb) bt
>   #0  decimal (s=0x0, count=count@entry=0) at tools.c:1113
>   #1  0x00000000008eea96 in list_source_code (req=0x1081860 <shared_bufs>, 
> count_entered=0) at kernel.c:1578
>   #2  cmd_dis () at kernel.c:2052
>   #3  0x000000000086b468 in exec_command () at main.c:893
>   #4  0x000000000086b6aa in main_loop () at main.c:840
>   #5  0x00000000006b950c in captured_main (data=data@entry=0x7ffe049a3bd0) at 
> main.c:1374
>   #6  gdb_main (args=args@entry=0x7ffe049a3c10) at main.c:1407
>   #7  0x00000000006b9579 in gdb_main_entry (argc=2, 
> argv=argv@entry=0x7ffe049a3db8) at main.c:1434
>   #8  0x000000000090529e in gdb_main_loop (argc=<optimized out>, 
> argc@entry=3, argv=argv@entry=0x7ffe049a3db8)
>       at gdb_interface.c:81
>   #9  0x0000000000438344 in main (argc=3, argv=0x7ffe049a3db8) at main.c:721
>   (gdb)
>
> This is because the decimal() tried to dereference a NULL pointer in the
> list_source_code() path, when the source code is not available. Given
> that, let's add a check to fix such cases.
>
> With the patch:
>   crash> dis -s _RNvCscb18lrEyTSA_10rust_panic10area_in_hp
>   Enable debuginfod for this session? (y or [n])
>   FILE: rust_panic.rs
>   LINE: 22
>
>   dis: _RNvCscb18lrEyTSA_10rust_panic10area_in_hp: source code is not 
> available
>
>   crash>
>
> Signed-off-by: Lianbo Jiang <[email protected]>
> ---
>  tools.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools.c b/tools.c
> index c9305bef7c9c..a9ad18d520d9 100644
> --- a/tools.c
> +++ b/tools.c
> @@ -1110,7 +1110,7 @@ decimal(char *s, int count)
>         } else
>                 cnt = count;
>
> -       for (p = &s[0], digits = 0; *p; p++) {
> +       for (p = &s[0], digits = 0; p && *p; p++) {
>                 switch(*p)
>                 {
>                     case '0':
> --
> 2.50.1
>
--
Crash-utility mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

Reply via email to