crash-utility / crash

Linux kernel crash utility
https://crash-utility.github.io
819 stars 271 forks source link

Should `name` be printed as `%ld` rather than `%s`? #126

Closed MatiasVara closed 1 year ago

MatiasVara commented 1 year ago

Hello,

I am triggering a segmentation fault at https://github.com/crash-utility/crash/blob/3ed9ec5c8d09cffac9772abbf54214125ade9127/memory.c#L6602 when trying to print name. The value of this variable is 0xffffffff918c5748 which is not in crash's memory-space. When using gdb, I got:

Thread 1 "crash" hit Breakpoint 1, page_flags_init_from_pageflag_names () at memory.c:6615
6615                            error(INFO, "failed to read pageflag_names entry (i: %d  name: \"%s\"  mask: %ld)\n",
(gdb) print name
$1 = (void *) 0xffffffff918c5748
(gdb) x 0xffffffff918c5748
0xffffffff918c5748:     Cannot access memory at address 0xffffffff918c5748

The pageflag_names is essentially an array of char*. I was wondering if it is correct to try to print the content of those pointers when read_string has failed.

Thanks.

k-hagio commented 1 year ago

Should name be printed as %ld rather than %s?

Yes, I agree. It should not be dereferenced when the read_string() has failed.

Would you post a patch with the messages you saw to the crash mailing list [1]? It would be helpful.

[1] https://github.com/crash-utility/crash/wiki

MatiasVara commented 1 year ago

Yes, I would. Thanks.

k-hagio commented 1 year ago

Closing with https://github.com/crash-utility/crash/commit/21139d9456ee41ffc8cec804dc530d6934ddac89. Thanks.