diff --git a/0001-x86_64-VC-exception-stack-support.patch b/0001-x86_64-VC-exception-stack-support.patch new file mode 100644 index 0000000..18a9858 --- /dev/null +++ b/0001-x86_64-VC-exception-stack-support.patch @@ -0,0 +1,157 @@ +From 9c881ab372010b46655dfed0a3c5cd78b3ff8fa0 Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Mon, 30 Nov 2020 09:48:29 -0800 +Subject: [PATCH 01/13] x86_64: VC exception stack support + +Linux 5.10 has introduced SEV-ES support. New (5th) exception +stack was added: 'VC_stack'. + +'struct exception_stacks' cannot be used to obtain the size +of VC stack, as the size of VC stack is zero there. Try +another structure 'struct cea_exception_stacks' first as it +represents actual CPU entry area with valid stack sizes and +guard pages. + +Handled the case if VC stack is not mapped (present). +It happens when SEV-ES is not active or not supported. + +Signed-off-by: Alexey Makhalov +Signed-off-by: Lianbo Jiang +--- + defs.h | 1 + + x86_64.c | 48 ++++++++++++++++++++++++++++++++++++------------ + 2 files changed, 37 insertions(+), 12 deletions(-) + +diff --git a/defs.h b/defs.h +index e1a18e9d0b4d..e468b1d99fcf 100644 +--- a/defs.h ++++ b/defs.h +@@ -5938,6 +5938,7 @@ struct x86_64_pt_regs_offsets { + struct x86_64_stkinfo { + ulong ebase[NR_CPUS][MAX_EXCEPTION_STACKS]; + int esize[MAX_EXCEPTION_STACKS]; ++ char available[NR_CPUS][MAX_EXCEPTION_STACKS]; + ulong ibase[NR_CPUS]; + int isize; + int NMI_stack_index; +diff --git a/x86_64.c b/x86_64.c +index 939c8a9fddd4..23a40a04bbc4 100644 +--- a/x86_64.c ++++ b/x86_64.c +@@ -1369,6 +1369,7 @@ x86_64_ist_init(void) + ulong init_tss; + struct machine_specific *ms; + struct syment *boot_sp, *tss_sp, *ist_sp; ++ char *exc_stack_struct_name = NULL; + + ms = machdep->machspec; + if (!(tss_sp = per_cpu_symbol_search("per_cpu__init_tss"))) { +@@ -1444,25 +1445,40 @@ x86_64_ist_init(void) + return; + } + +- if (MEMBER_EXISTS("exception_stacks", "NMI_stack")) { ++ if (MEMBER_EXISTS("cea_exception_stacks", "NMI_stack")) { ++ /* The effective cpu entry area mapping with guard pages. */ ++ exc_stack_struct_name = "cea_exception_stacks"; ++ } else if (MEMBER_EXISTS("exception_stacks", "NMI_stack")) { ++ /* The exception stacks' physical storage. No guard pages and no VC stack. */ ++ exc_stack_struct_name = "exception_stacks"; ++ } ++ if (exc_stack_struct_name) { + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { + if (STREQ(ms->stkinfo.exception_stacks[i], "DEBUG")) +- ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "DB_stack"); ++ ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "DB_stack"); + else if (STREQ(ms->stkinfo.exception_stacks[i], "NMI")) +- ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "NMI_stack"); ++ ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "NMI_stack"); + else if (STREQ(ms->stkinfo.exception_stacks[i], "DOUBLEFAULT")) +- ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "DF_stack"); ++ ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "DF_stack"); + else if (STREQ(ms->stkinfo.exception_stacks[i], "MCE")) +- ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "MCE_stack"); ++ ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "MCE_stack"); ++ else if (STREQ(ms->stkinfo.exception_stacks[i], "VC")) ++ ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "VC_stack"); + } + /* +- * Adjust the top-of-stack addresses down to the base stack address. ++ * Adjust the top-of-stack addresses down to the base stack address ++ * and set stack page availabilituy flag. + */ + for (c = 0; c < kt->cpus; c++) { + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { +- if (ms->stkinfo.ebase[c][i] == 0) +- continue; +- ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i]; ++ if (ms->stkinfo.ebase[c][i]) ++ ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i]; ++ ++ ms->stkinfo.available[c][i] = TRUE; ++ /* VC stack can be unmapped if SEV-ES is disabled or not supported. */ ++ if (STREQ(ms->stkinfo.exception_stacks[i], "VC") && ++ !accessible(ms->stkinfo.ebase[c][i])) ++ ms->stkinfo.available[c][i] = FALSE; + } + } + +@@ -1487,6 +1503,7 @@ x86_64_ist_init(void) + else + ms->stkinfo.esize[i] = esize; + ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i]; ++ ms->stkinfo.available[c][i] = TRUE; + } + } + +@@ -2842,7 +2859,8 @@ x86_64_eframe_search(struct bt_info *bt) + !(NUM_IN_BITMAP(bt->cpumask, c))) + continue; + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { +- if (ms->stkinfo.ebase[c][i] == 0) ++ if (ms->stkinfo.ebase[c][i] == 0 || ++ !ms->stkinfo.available[c][i]) + break; + bt->hp->esp = ms->stkinfo.ebase[c][i]; + fprintf(fp, "CPU %d %s EXCEPTION STACK:", +@@ -3288,7 +3306,8 @@ x86_64_in_exception_stack(struct bt_info *bt, int *estack_index) + + for (c = 0; !estack && (c < kt->cpus); c++) { + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { +- if (ms->stkinfo.ebase[c][i] == 0) ++ if (ms->stkinfo.ebase[c][i] == 0 || ++ !ms->stkinfo.available[c][i]) + break; + if ((rsp >= ms->stkinfo.ebase[c][i]) && + (rsp < (ms->stkinfo.ebase[c][i] + +@@ -5097,7 +5116,7 @@ skip_stage: + ms->stkinfo.esize[estack]; + console("x86_64_get_dumpfile_stack_frame: searching %s estack at %lx\n", + ms->stkinfo.exception_stacks[estack], bt->stackbase); +- if (!(bt->stackbase)) ++ if (!(bt->stackbase && ms->stkinfo.available[bt->tc->processor][estack])) + goto skip_stage; + bt->stackbuf = ms->irqstack; + alter_stackbuf(bt); +@@ -5380,6 +5399,8 @@ x86_64_exception_stacks_init(void) + ms->stkinfo.exception_stacks[ist-1] = "DOUBLEFAULT"; + if (strstr(buf, "machine")) + ms->stkinfo.exception_stacks[ist-1] = "MCE"; ++ if (strstr(buf, "vmm")) ++ ms->stkinfo.exception_stacks[ist-1] = "VC"; + } + } + +@@ -5737,6 +5758,9 @@ x86_64_display_machine_stats(void) + fprintf(fp, "%22s: %016lx", + buf, machdep->machspec->stkinfo.ebase[c][i]); + ++ if (!machdep->machspec->stkinfo.available[c][i]) ++ fprintf(fp, " [unavailable]"); ++ + if (hide_offline_cpu(c)) + fprintf(fp, " [OFFLINE]\n"); + else +-- +2.17.1 + diff --git a/0002-netdump-fix-regression-for-raw-RAM-dumpfiles.patch b/0002-netdump-fix-regression-for-raw-RAM-dumpfiles.patch new file mode 100644 index 0000000..cb0679a --- /dev/null +++ b/0002-netdump-fix-regression-for-raw-RAM-dumpfiles.patch @@ -0,0 +1,66 @@ +From 31ca172357c4d3520caf29b9efb5e6ccd622aae9 Mon Sep 17 00:00:00 2001 +From: Qianli Zhao +Date: Mon, 30 Nov 2020 17:17:32 +0800 +Subject: [PATCH 02/13] netdump: fix regression for raw RAM dumpfiles + +Commit f42db6a33f0e ("Support core files with "unusual" layout") +increased the minimal file size from MIN_NETDUMP_ELF_HEADER_SIZE to +SAFE_NETDUMP_ELF_HEADER_SIZE which can lead to crash rejecting +raw RAM dumpfiles. Without the patch, the crash fails to start +a session with the error message: + + /var/tmp/ramdump_elf_XXXXXX: ELF header read: No such file or directory + crash: malformed ELF file: /var/tmp/ramdump_elf_XXXXXX + +Fix that by erroring out only if we get less than +MIN_NETDUMP_ELF_HEADER_SIZE bytes. + +Signed-off-by: Qianli Zhao +Acked-and-tested-by: Mathias Krause +Signed-off-by: Lianbo Jiang +--- + netdump.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/netdump.c b/netdump.c +index c76d9dd1a1e5..ca9b459fc57b 100644 +--- a/netdump.c ++++ b/netdump.c +@@ -119,7 +119,8 @@ is_netdump(char *file, ulong source_query) + Elf64_Phdr *load64; + char *eheader, *sect0; + char buf[BUFSIZE]; +- size_t size, len, tot; ++ ssize_t size; ++ size_t len, tot; + Elf32_Off offset32; + Elf64_Off offset64; + ulong format; +@@ -134,7 +135,7 @@ is_netdump(char *file, ulong source_query) + + size = SAFE_NETDUMP_ELF_HEADER_SIZE; + if ((eheader = (char *)malloc(size)) == NULL) { +- fprintf(stderr, "cannot malloc minimum ELF header buffer\n"); ++ fprintf(stderr, "cannot malloc ELF header buffer\n"); + clean_exit(1); + } + +@@ -142,10 +143,14 @@ is_netdump(char *file, ulong source_query) + if (!read_flattened_format(fd, 0, eheader, size)) + goto bailout; + } else { +- if (read(fd, eheader, size) != size) { ++ size = read(fd, eheader, size); ++ if (size < 0) { + sprintf(buf, "%s: ELF header read", file); + perror(buf); + goto bailout; ++ } else if (size < MIN_NETDUMP_ELF_HEADER_SIZE) { ++ fprintf(stderr, "%s: file too small!\n", file); ++ goto bailout; + } + } + +-- +2.17.1 + diff --git a/0003-arm64-update-mapping-symbol-filter-in-arm64_verify_s.patch b/0003-arm64-update-mapping-symbol-filter-in-arm64_verify_s.patch new file mode 100644 index 0000000..82d2806 --- /dev/null +++ b/0003-arm64-update-mapping-symbol-filter-in-arm64_verify_s.patch @@ -0,0 +1,43 @@ +From 9080711bd1c0645c272e74c25724ad2969d64674 Mon Sep 17 00:00:00 2001 +From: Qianli Zhao +Date: Thu, 26 Nov 2020 12:49:36 +0800 +Subject: [PATCH 03/13] arm64: update mapping symbol filter in + arm64_verify_symbol + +Update mapping symbol filter in arm64_verify_symbol() to support the +long form of mapping symbols, e.g. "$x." described on [1]. +Without the patch, the "dis" command cannot completely parse out the +disassembly of a function that has mapping symbols in the long form +and misses the tail part of the function. + +[1] Morello Supplement to ELF for the Arm 64-bit Architecture + https://developer.arm.com/documentation/102072/ + +Signed-off-by: Qianli Zhao +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + arm64.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/arm64.c b/arm64.c +index fdf77bd5e0c1..37aed07edf1d 100644 +--- a/arm64.c ++++ b/arm64.c +@@ -510,9 +510,11 @@ arm64_verify_symbol(const char *name, ulong value, char type) + ((type == 'a') || (type == 'n') || (type == 'N') || (type == 'U'))) + return FALSE; + +- if (STREQ(name, "$d") || STREQ(name, "$x")) ++ if (STREQ(name, "$d") || STRNEQ(name, "$d.") || ++ STREQ(name, "$x") || STRNEQ(name, "$x.") || ++ STREQ(name, "$c") || STRNEQ(name, "$c.")) + return FALSE; +- ++ + if ((type == 'A') && STRNEQ(name, "__crc_")) + return FALSE; + +-- +2.17.1 + diff --git a/0004-extensions-eppic.mk-move-ping-check-to-recipe-script.patch b/0004-extensions-eppic.mk-move-ping-check-to-recipe-script.patch new file mode 100644 index 0000000..d3d5fbd --- /dev/null +++ b/0004-extensions-eppic.mk-move-ping-check-to-recipe-script.patch @@ -0,0 +1,43 @@ +From 324e5090aaac13a2896a2e22a287583ad8f00969 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Wed, 23 Dec 2020 16:38:41 +0900 +Subject: [PATCH 04/13] extensions/eppic.mk: move ping check to recipe script + +Without this patch, in an environment where ping to github.com does +not work, "make clean" at the top-level crash directory always takes +about 10 seconds unnecessarily. + + $ time make clean + ... + real 0m10.398s + +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + extensions/eppic.mk | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/extensions/eppic.mk b/extensions/eppic.mk +index c79170a596b7..bda69da6706f 100644 +--- a/extensions/eppic.mk ++++ b/extensions/eppic.mk +@@ -24,7 +24,6 @@ ifeq ($(TARGET), X86) + endif + + APPFILE=eppic/applications/crash/eppic.c +-GITHUB := $(shell ping -c 1 github.com | grep "1 received") + GIT := $(shell which git 2> /dev/null) + + all: +@@ -38,7 +37,7 @@ all: + if [ -n "$(EPPIC_GIT_URL)" ]; then \ + git clone "$(EPPIC_GIT_URL)" eppic; \ + else \ +- if [ -n "$(GITHUB)" ] ; then \ ++ if ping -c 1 -W 5 github.com >/dev/null ; then \ + git clone https://github.com/lucchouina/eppic.git eppic; \ + fi; \ + fi; \ +-- +2.17.1 + diff --git a/0005-Fix-segmentation-fault-when-ikconfig-passed-nonstand.patch b/0005-Fix-segmentation-fault-when-ikconfig-passed-nonstand.patch new file mode 100644 index 0000000..05ac465 --- /dev/null +++ b/0005-Fix-segmentation-fault-when-ikconfig-passed-nonstand.patch @@ -0,0 +1,65 @@ +From 5a0488049917ba2790d59108f3def16825528974 Mon Sep 17 00:00:00 2001 +From: Jackie Liu +Date: Tue, 5 Jan 2021 09:45:11 +0800 +Subject: [PATCH 05/13] Fix segmentation fault when ikconfig passed nonstandard + values + +Fix for a segmentation fault when analyzing arm64 kernels that are +configured with CONFIG_IKCONFIG and have a strange entry that does +not contain the delimiter "=", such as "CONFIG_SECU+[some hex data]". + +Without the patch, in the add_ikconfig_entry() function, strtok_r() +interprets it as consisting of a single token and the val variable +is set to NULL, and then strdup() crashes. + +Suggested-by: Kazuhito Hagio +Signed-off-by: Jackie Liu +Signed-off-by: Lianbo Jiang +--- + kernel.c | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/kernel.c b/kernel.c +index e722ff941527..272e0d8751cf 100644 +--- a/kernel.c ++++ b/kernel.c +@@ -10241,7 +10241,7 @@ static struct ikconfig_list { + char *val; + } *ikconfig_all; + +-static void add_ikconfig_entry(char *line, struct ikconfig_list *ent) ++static int add_ikconfig_entry(char *line, struct ikconfig_list *ent) + { + char *tokptr, *name, *val; + +@@ -10249,8 +10249,16 @@ static void add_ikconfig_entry(char *line, struct ikconfig_list *ent) + sscanf(name, "CONFIG_%s", name); + val = strtok_r(NULL, "", &tokptr); + ++ if (!val) { ++ if (CRASHDEBUG(2)) ++ error(WARNING, "invalid ikconfig entry: %s\n", line); ++ return FALSE; ++ } ++ + ent->name = strdup(name); + ent->val = strdup(val); ++ ++ return TRUE; + } + + static int setup_ikconfig(char *config) +@@ -10270,8 +10278,8 @@ static int setup_ikconfig(char *config) + ent++; + + if (STRNEQ(ent, "CONFIG_")) { +- add_ikconfig_entry(ent, +- &ikconfig_all[kt->ikconfig_ents++]); ++ if (add_ikconfig_entry(ent, &ikconfig_all[kt->ikconfig_ents])) ++ kt->ikconfig_ents++; + if (kt->ikconfig_ents == IKCONFIG_MAX) { + error(WARNING, "ikconfig overflow.\n"); + return 1; +-- +2.17.1 + diff --git a/0006-netdump-fix-illegal-read-from-already-freed-buffer.patch b/0006-netdump-fix-illegal-read-from-already-freed-buffer.patch new file mode 100644 index 0000000..d79dc21 --- /dev/null +++ b/0006-netdump-fix-illegal-read-from-already-freed-buffer.patch @@ -0,0 +1,56 @@ +From d066c93fefdd27dfc26012853d6a2ab5475bcf6b Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Thu, 31 Dec 2020 17:20:52 +0900 +Subject: [PATCH 06/13] netdump: fix illegal read from already freed buffer + +This issue was detected by valgrind as follows: + + ==1212== Invalid read of size 8 + ==1212== at 0x56C400: resize_elf_header (netdump.c:585) + ==1212== by 0x56C400: is_netdump (netdump.c:363) + ==1212== by 0x463571: main (main.c:561) + ==1212== Address 0x4e8ec10 is 32 bytes inside a block of size 304 free'd + ==1212== at 0x483BCE8: realloc (vg_replace_malloc.c:834) + ==1212== by 0x56C393: resize_elf_header (netdump.c:547) + ==1212== by 0x56C393: is_netdump (netdump.c:363) + ==1212== by 0x463571: main (main.c:561) + ==1212== Block was alloc'd at + ==1212== at 0x4839809: malloc (vg_replace_malloc.c:307) + ==1212== by 0x56C078: is_netdump (netdump.c:136) + ==1212== by 0x463571: main (main.c:561) + ==1212== + +The issue was introduced by the commit +f42db6a33f0e0652df7cce8506352745b4794287 (Support core files with +"unusual" layout). + +In resize_elf_header(), both elf32 and elf64 refer to the same address +as eheader, but when reallocating the address pointed at by eheader, +elf32 and elf64 are not updated, resulting in referring to the already +freed address. + +To fix this issue, let's update elf32 and elf64 at the realloc(). + +Signed-off-by: HATAYAMA Daisuke +Signed-off-by: Lianbo Jiang +--- + netdump.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/netdump.c b/netdump.c +index ca9b459fc57b..f2b336374e79 100644 +--- a/netdump.c ++++ b/netdump.c +@@ -555,6 +555,9 @@ resize_elf_header(int fd, char *file, char **eheader_ptr, char **sect0_ptr, + } else + *eheader_ptr = eheader; + ++ elf32 = (Elf32_Ehdr *)&eheader[0]; ++ elf64 = (Elf64_Ehdr *)&eheader[0]; ++ + if (FLAT_FORMAT()) { + if (!read_flattened_format(fd, 0, eheader, header_size)) + return 0; +-- +2.17.1 + diff --git a/0007-tools-fix-potential-source-and-destination-overlap-w.patch b/0007-tools-fix-potential-source-and-destination-overlap-w.patch new file mode 100644 index 0000000..fae6261 --- /dev/null +++ b/0007-tools-fix-potential-source-and-destination-overlap-w.patch @@ -0,0 +1,66 @@ +From 3972c86695954d446a6301282a21acc8e6967ea2 Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Thu, 31 Dec 2020 17:20:53 +0900 +Subject: [PATCH 07/13] tools: fix potential source and destination overlap + with strcpy() + +valgrind detects the following error: + + ==14603== Source and destination overlap in strcpy(0x1ffefffe42, 0x1ffefffe44) + ==14603== at 0x483CD70: strcpy (vg_replace_strmem.c:511) + ==14603== by 0x477813: pages_to_size (tools.c:6393) + ==14603== by 0x4F292E: display_sys_stats (kernel.c:5629) + ==14603== by 0x464BC7: main_loop (main.c:797) + ==14603== by 0x6BE352: captured_command_loop (main.c:258) + ==14603== by 0x6BC959: catch_errors (exceptions.c:557) + ==14603== by 0x6BF3D5: captured_main (main.c:1064) + ==14603== by 0x6BC959: catch_errors (exceptions.c:557) + ==14603== by 0x6BF686: gdb_main (main.c:1079) + ==14603== by 0x6BF686: gdb_main_entry (main.c:1099) + ==14603== by 0x46316F: main (main.c:708) + ==14603== + +pages_to_size() removes ".0 " if it is contained in the created string +by overwriting them using strcpy() with the following "MB\0" or +"GB\0". However, strcpy() doesn't accept such overlapping source and +destination and thus use of strcpy() in this case is illegal. + +Let's fix this by re-implementing the logic by memmove() where +destination and source strings may overlap. + +Signed-off-by: HATAYAMA Daisuke +Signed-off-by: Lianbo Jiang +--- + tools.c | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +diff --git a/tools.c b/tools.c +index 89352b1dc5f5..71bac6d0ee9a 100644 +--- a/tools.c ++++ b/tools.c +@@ -6371,7 +6371,7 @@ char * + pages_to_size(ulong pages, char *buf) + { + double total; +- char *p1, *p2; ++ char *p; + + if (pages == 0) { + sprintf(buf, "0"); +@@ -6387,11 +6387,8 @@ pages_to_size(ulong pages, char *buf) + else + sprintf(buf, "%ld KB", (ulong)(total/(double)KILOBYTES(1))); + +- if ((p1 = strstr(buf, ".0 "))) { +- p2 = p1 + 3; +- *p1++ = ' '; +- strcpy(p1, p2); +- } ++ if ((p = strstr(buf, ".0 "))) ++ memmove(p, p + 2, sizeof(" GB")); + + return buf; + } +-- +2.17.1 + diff --git a/0008-set-add-ability-to-un-set-scope.patch b/0008-set-add-ability-to-un-set-scope.patch new file mode 100644 index 0000000..8429bfe --- /dev/null +++ b/0008-set-add-ability-to-un-set-scope.patch @@ -0,0 +1,80 @@ +From e4c1617e17ebf2d4e20ba59041de1536ec193be3 Mon Sep 17 00:00:00 2001 +From: John Pittman +Date: Mon, 18 Jan 2021 09:43:27 -0500 +Subject: [PATCH 08/13] set: add ability to un-set scope + +Currently there is no way to un-set the scope without having to +exit and re-enter crash. The ability to un-set can come in very +useful when running automated pykdump scripts and needing scope to +be cleared between script runs. Add the ability by allowing +vaddr 0 to be passed through gdb_set_crash_scope() and +gdb_command_funnel(), taking advantage of the !req->addr check in +gdb_set_crash_block(), enabling 'set scope 0' as a viable command. + +Signed-off-by: John Pittman +Signed-off-by: Lianbo Jiang +--- + gdb_interface.c | 30 ++++++++++++++++-------------- + help.c | 2 +- + 2 files changed, 17 insertions(+), 15 deletions(-) + +diff --git a/gdb_interface.c b/gdb_interface.c +index 562d2ace59da..f4f4dd3993db 100644 +--- a/gdb_interface.c ++++ b/gdb_interface.c +@@ -1012,23 +1012,25 @@ gdb_set_crash_scope(ulong vaddr, char *arg) + char name[BUFSIZE]; + struct load_module *lm; + +- if (!is_kernel_text(vaddr)) { +- error(INFO, "invalid text address: %s\n", arg); +- return FALSE; +- } ++ if (vaddr) { ++ if (!is_kernel_text(vaddr)) { ++ error(INFO, "invalid text address: %s\n", arg); ++ return FALSE; ++ } + +- if (module_symbol(vaddr, NULL, &lm, name, 0)) { +- if (!(lm->mod_flags & MOD_LOAD_SYMS)) { +- error(INFO, "attempting to find/load \"%s\" module debuginfo\n", +- lm->mod_name); +- if (!load_module_symbols_helper(lm->mod_name)) { +- error(INFO, "cannot find/load \"%s\" module debuginfo\n", ++ if (module_symbol(vaddr, NULL, &lm, name, 0)) { ++ if (!(lm->mod_flags & MOD_LOAD_SYMS)) { ++ error(INFO, "attempting to find/load \"%s\" module debuginfo\n", + lm->mod_name); +- return FALSE; ++ if (!load_module_symbols_helper(lm->mod_name)) { ++ error(INFO, "cannot find/load \"%s\" module debuginfo\n", ++ lm->mod_name); ++ return FALSE; ++ } + } +- } +- } else if (kt->flags2 & KASLR) +- vaddr -= (kt->relocate * -1); ++ } else if (kt->flags2 & KASLR) ++ vaddr -= (kt->relocate * -1); ++ } + + req->command = GNU_SET_CRASH_BLOCK; + req->addr = vaddr; +diff --git a/help.c b/help.c +index d3427a36829f..7c9455f87758 100644 +--- a/help.c ++++ b/help.c +@@ -1088,7 +1088,7 @@ char *help_set[] = { + " of data structures; the \"text-addr\" argument", + " must be a kernel or module text address, which", + " may be expressed symbolically or as a hexadecimal", +-" value.", ++" value; set scope 0 to un-set.", + " offline show | hide show or hide command output that is associated", + " with offline cpus.", + " redzone on | off if on, CONFIG_SLUB object addresses displayed by", +-- +2.17.1 + diff --git a/0009-Fix-sys-t-mod-S-after-mod-t-when-crash-runs-with-s-o.patch b/0009-Fix-sys-t-mod-S-after-mod-t-when-crash-runs-with-s-o.patch new file mode 100644 index 0000000..8c098dc --- /dev/null +++ b/0009-Fix-sys-t-mod-S-after-mod-t-when-crash-runs-with-s-o.patch @@ -0,0 +1,41 @@ +From 1be446cb5fbc442103dbb54279f3cc3a61b4c0ff Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Wed, 20 Jan 2021 15:16:24 +0900 +Subject: [PATCH 09/13] Fix "sys [-t]|mod -S" after "mod -t" when crash runs + with -s option + +When crash runs with -s option, SIZE(taint_flag) and OFFSET(tnt_false) +are not set during initialization. If the "mod -t" option is executed, +it sets the former but does not set the latter. After that, the "sys" +command uses OFFSET(tnt_false) without setting it, because it checks +only whether SIZE(taint_flag) is set. + +Without the patch, the "sys [-t]" and "mod -S" options after "mod -t" +option fail with the error message: + + sys: invalid structure member offset: tnt_false + FILE: kernel.c LINE: 11203 FUNCTION: show_kernel_taints_v4_10() + +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + kernel.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kernel.c b/kernel.c +index 272e0d8751cf..5fcd86575be5 100644 +--- a/kernel.c ++++ b/kernel.c +@@ -11160,7 +11160,8 @@ show_kernel_taints_v4_10(char *buf, int verbose) + ulong tainted_mask, *tainted_mask_ptr; + struct syment *sp; + +- if (!VALID_STRUCT(taint_flag)) { ++ if (!(VALID_STRUCT(taint_flag) && ++ VALID_MEMBER(tnt_true) && VALID_MEMBER(tnt_false))) { + STRUCT_SIZE_INIT(taint_flag, "taint_flag"); + MEMBER_OFFSET_INIT(tnt_true, "taint_flag", "true"); + MEMBER_OFFSET_INIT(tnt_false, "taint_flag", "false"); +-- +2.17.1 + diff --git a/0010-Fix-dev-d-option-on-Linux-5.11-rc1-and-later-kernels.patch b/0010-Fix-dev-d-option-on-Linux-5.11-rc1-and-later-kernels.patch new file mode 100644 index 0000000..656727f --- /dev/null +++ b/0010-Fix-dev-d-option-on-Linux-5.11-rc1-and-later-kernels.patch @@ -0,0 +1,110 @@ +From b922a2c8aeecfe8b1033ba419b475dfd4e51ef16 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 19 Jan 2021 15:03:39 +0900 +Subject: [PATCH 10/13] Fix "dev -d" option on Linux 5.11-rc1 and later kernels + +Fix the "dev -d" option on Linux 5.11-rc1 and later kernels that +contains commit 0d02129e76edf91cf04fabf1efbc3a9a1f1d729a +("block: merge struct block_device and struct hd_struct"). +Without the patch, the option fails with the error message +"dev: invalid structure member offset: hd_struct_dev". + +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + defs.h | 2 ++ + dev.c | 29 +++++++++++++++++++++++++---- + symbols.c | 4 ++++ + 3 files changed, 31 insertions(+), 4 deletions(-) + +diff --git a/defs.h b/defs.h +index e468b1d99fcf..ffbe73bfb508 100644 +--- a/defs.h ++++ b/defs.h +@@ -2128,6 +2128,8 @@ struct offset_table { /* stash of commonly-used offsets */ + long prb_data_ring_size_bits; + long prb_data_ring_data; + long atomic_long_t_counter; ++ long block_device_bd_device; ++ long block_device_bd_stats; + }; + + struct size_table { /* stash of commonly-used sizes */ +diff --git a/dev.c b/dev.c +index 56e84ab9007c..effe789f38d8 100644 +--- a/dev.c ++++ b/dev.c +@@ -4067,13 +4067,22 @@ get_gendisk_5(unsigned long entry) + { + unsigned long device_address; + unsigned long device_private_address; ++ unsigned long gendisk; + + device_private_address = entry - OFFSET(device_private_knode_class); + readmem(device_private_address + OFFSET(device_private_device), + KVADDR, &device_address, sizeof(device_address), + "device_private.device", FAULT_ON_ERROR); + +- return device_address - OFFSET(hd_struct_dev) - OFFSET(gendisk_part0); ++ if (VALID_MEMBER(hd_struct_dev)) ++ return device_address - OFFSET(hd_struct_dev) - OFFSET(gendisk_part0); ++ ++ /* kernel version >= 5.11 */ ++ readmem(device_address - OFFSET(block_device_bd_device) + ++ OFFSET(block_device_bd_disk), KVADDR, &gendisk, ++ sizeof(ulong), "block_device.bd_disk", FAULT_ON_ERROR); ++ ++ return gendisk; + } + + /* 2.6.24 < kernel version <= 2.6.27 */ +@@ -4290,9 +4299,19 @@ get_diskio_1(unsigned long rq, unsigned long gendisk, struct diskio *io) + io->read = count[0]; + io->write = count[1]; + } else { +- readmem(gendisk + OFFSET(gendisk_part0) + +- OFFSET(hd_struct_dkstats), KVADDR, &dkstats, +- sizeof(ulong), "gendisk.part0.dkstats", FAULT_ON_ERROR); ++ if (VALID_MEMBER(hd_struct_dkstats)) ++ readmem(gendisk + OFFSET(gendisk_part0) + ++ OFFSET(hd_struct_dkstats), KVADDR, &dkstats, ++ sizeof(ulong), "gendisk.part0.dkstats", FAULT_ON_ERROR); ++ else { /* kernel version >= 5.11 */ ++ ulong block_device; ++ readmem(gendisk + OFFSET(gendisk_part0), KVADDR, &block_device, ++ sizeof(ulong), "gendisk.part0", FAULT_ON_ERROR); ++ readmem(block_device + OFFSET(block_device_bd_stats), KVADDR, ++ &dkstats, sizeof(ulong), "block_device.bd_stats", ++ FAULT_ON_ERROR); ++ } ++ + get_one_diskio_from_dkstats(dkstats, io_counts); + + io->read = io_counts[0]; +@@ -4549,6 +4568,8 @@ void diskio_init(void) + MEMBER_OFFSET_INIT(gendisk_queue, "gendisk", "queue"); + MEMBER_OFFSET_INIT(hd_struct_dev, "hd_struct", "__dev"); + MEMBER_OFFSET_INIT(hd_struct_dkstats, "hd_struct", "dkstats"); ++ MEMBER_OFFSET_INIT(block_device_bd_device, "block_device", "bd_device"); ++ MEMBER_OFFSET_INIT(block_device_bd_stats, "block_device", "bd_stats"); + MEMBER_OFFSET_INIT(klist_k_list, "klist", "k_list"); + MEMBER_OFFSET_INIT(klist_node_n_klist, "klist_node", "n_klist"); + MEMBER_OFFSET_INIT(klist_node_n_node, "klist_node", "n_node"); +diff --git a/symbols.c b/symbols.c +index a51078d58e6b..ed5f731fa1b3 100644 +--- a/symbols.c ++++ b/symbols.c +@@ -9291,6 +9291,10 @@ dump_offset_table(char *spec, ulong makestruct) + OFFSET(block_device_bd_list)); + fprintf(fp, " block_device_bd_disk: %ld\n", + OFFSET(block_device_bd_disk)); ++ fprintf(fp, " block_device_bd_device: %ld\n", ++ OFFSET(block_device_bd_device)); ++ fprintf(fp, " block_device_bd_stats: %ld\n", ++ OFFSET(block_device_bd_stats)); + fprintf(fp, " address_space_nrpages: %ld\n", + OFFSET(address_space_nrpages)); + fprintf(fp, " address_space_page_tree: %ld\n", +-- +2.17.1 + diff --git a/0011-Fix-kmem-v-option-on-Linux-5.11-rc1-and-later-kernel.patch b/0011-Fix-kmem-v-option-on-Linux-5.11-rc1-and-later-kernel.patch new file mode 100644 index 0000000..97c0409 --- /dev/null +++ b/0011-Fix-kmem-v-option-on-Linux-5.11-rc1-and-later-kernel.patch @@ -0,0 +1,34 @@ +From 7bda96c431321de1b0fe2b88ccb388ec4b0293dd Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 19 Jan 2021 18:42:54 +0900 +Subject: [PATCH 11/13] Fix "kmem -v" option on Linux 5.11-rc1 and later + kernels + +Fix the "kmem -v" option on Linux 5.11-rc1 and later kernels +that contains commit 96e2db456135db0cf2476b6890f1e8b2fdcf21eb +("mm/vmalloc: rework the drain logic"). Without the patch, +the option will display nothing or fail with the error message +"kmem: invalid kernel virtual address:
type: "vmlist addr". + +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + memory.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/memory.c b/memory.c +index 0848097eb4f5..33b0ca7af977 100644 +--- a/memory.c ++++ b/memory.c +@@ -403,8 +403,6 @@ vm_init(void) + VALID_MEMBER(vmap_area_va_end) && + VALID_MEMBER(vmap_area_list) && + VALID_MEMBER(vmap_area_vm) && +- (VALID_MEMBER(vmap_area_flags) || +- (OFFSET(vmap_area_vm) == MEMBER_OFFSET("vmap_area", "purge_list"))) && + kernel_symbol_exists("vmap_area_list")) + vt->flags |= USE_VMAP_AREA; + +-- +2.17.1 + diff --git a/0012-mod-Show-the-base-address-of-module.patch b/0012-mod-Show-the-base-address-of-module.patch new file mode 100644 index 0000000..992397e --- /dev/null +++ b/0012-mod-Show-the-base-address-of-module.patch @@ -0,0 +1,220 @@ +From 33c322e9295b0453db4152d0f7c962ced2944c78 Mon Sep 17 00:00:00 2001 +From: Yunfeng Ye +Date: Tue, 19 Jan 2021 10:02:17 +0800 +Subject: [PATCH 12/13] mod: Show the base address of module + +Currently the "mod" command shows the address of the module struct, +it is inconvenient to know the address range of the module, so extend +to show the base adddress. + +[ kh: added help page update ] + +Signed-off-by: Yunfeng Ye +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + help.c | 126 +++++++++++++++++++------------------------------------ + kernel.c | 7 +++- + 2 files changed, 48 insertions(+), 85 deletions(-) + +diff --git a/help.c b/help.c +index 7c9455f87758..587c7173f495 100644 +--- a/help.c ++++ b/help.c +@@ -5547,9 +5547,9 @@ char *help_mod[] = { + "module information and loading of symbols and debugging data", + "-s module [objfile] | -d module | -S [directory] [-D|-t|-r|-R|-o|-g]", + " With no arguments, this command displays basic information of the currently", +-" installed modules, consisting of the module address, name, size, the", +-" object file name (if known), and whether the module was compiled with", +-" CONFIG_KALLSYMS.", ++" installed modules, consisting of the module address, name, base address,", ++" size, the object file name (if known), and whether the module was compiled", ++" with CONFIG_KALLSYMS.", + " ", + " The arguments are concerned with with the loading or deleting of symbolic", + " and debugging data from a module's object file. A modules's object file", +@@ -5634,106 +5634,64 @@ char *help_mod[] = { + "\nEXAMPLES", + " Display the currently-installed modules:\n", + " %s> mod", +-" MODULE NAME SIZE OBJECT FILE", +-" c8019000 soundcore 2788 (not loaded)", +-" c801b000 soundlow 336 (not loaded)", +-" c801d000 sound 59864 (not loaded)", +-" c802d000 ad1848 15728 (not loaded)", +-" c8032000 uart401 6000 (not loaded)", +-" c8035000 cs4232 2472 (not loaded)", +-" c8043000 opl3 11048 (not loaded)", +-" c8047000 3c59x 18152 (not loaded)", +-" c804d000 sunrpc 53796 (not loaded)", +-" c805c000 lockd 31528 (not loaded)", +-" c8065000 nfsd 151896 (not loaded)", +-" c8092000 nfs 29752 (not loaded)", ++" MODULE NAME BASE SIZE OBJECT FILE", ++" f7e44c20 dm_mod f7e34000 88568 (not loaded)", ++" f7e5a8a0 dm_log f7e59000 8354 (not loaded)", ++" f7e66420 dm_region_hash f7e65000 9708 (not loaded)", ++" f7e76b60 dm_mirror f7e74000 12609 (not loaded)", ++" f7e8b8e0 ata_piix f7e87000 20637 (not loaded)", ++" ...", + " ", + " Display the currently-installed modules on a system where all modules were", + " compiled with CONFIG_KALLSYMS:", + " ", + " %s> mod", +-" MODULE NAME SIZE OBJECT FILE", +-" e080d000 jbd 57016 (not loaded) [CONFIG_KALLSYMS]", +-" e081e000 ext3 92360 (not loaded) [CONFIG_KALLSYMS]", +-" e0838000 usbcore 83168 (not loaded) [CONFIG_KALLSYMS]", +-" e0850000 usb-uhci 27532 (not loaded) [CONFIG_KALLSYMS]", +-" e085a000 ehci-hcd 20904 (not loaded) [CONFIG_KALLSYMS]", +-" e0865000 input 6208 (not loaded) [CONFIG_KALLSYMS]", +-" e086a000 hid 22404 (not loaded) [CONFIG_KALLSYMS]", +-" e0873000 mousedev 5688 (not loaded) [CONFIG_KALLSYMS]", +-" e0878000 keybdev 2976 (not loaded) [CONFIG_KALLSYMS]", +-" e08fd000 cdrom 34144 (not loaded) [CONFIG_KALLSYMS]", +-" e0909000 ide-cd 35776 (not loaded) [CONFIG_KALLSYMS]", +-" e0915000 scsi_mod 117928 (not loaded) [CONFIG_KALLSYMS]", +-" e0935000 ide-scsi 12752 (not loaded) [CONFIG_KALLSYMS]", +-" e093c000 microcode 5248 (not loaded) [CONFIG_KALLSYMS]", +-" e0943000 sr_mod 18136 (not loaded) [CONFIG_KALLSYMS]", +-" e0956000 floppy 59056 (not loaded) [CONFIG_KALLSYMS]", +-" e0966000 sg 38060 (not loaded) [CONFIG_KALLSYMS]", +-" e0971000 ip_tables 16544 (not loaded) [CONFIG_KALLSYMS]", +-" e097d000 iptable_filter 2412 (not loaded) [CONFIG_KALLSYMS]", +-" e097f000 e1000 76096 (not loaded) [CONFIG_KALLSYMS]", +-" e09ba000 autofs 13780 (not loaded) [CONFIG_KALLSYMS]", +-" e09c1000 parport 39072 (not loaded) [CONFIG_KALLSYMS]", +-" e09ce000 lp 9220 (not loaded) [CONFIG_KALLSYMS]", +-" e09d4000 parport_pc 19204 (not loaded) [CONFIG_KALLSYMS]", +-" e09e2000 agpgart 59128 (not loaded) [CONFIG_KALLSYMS]", +-" e0a1a000 radeon 117156 (not loaded) [CONFIG_KALLSYMS]", +-" e2dc7000 sunrpc 91996 (not loaded) [CONFIG_KALLSYMS]", +-" e2de1000 lockd 60624 (not loaded) [CONFIG_KALLSYMS]", +-" e2df3000 nfs 96880 (not loaded) [CONFIG_KALLSYMS]", ++" MODULE NAME BASE SIZE OBJECT FILE", ++" f7e44c20 dm_mod f7e34000 88568 (not loaded) [CONFIG_KALLSYMS]", ++" f7e5a8a0 dm_log f7e59000 8354 (not loaded) [CONFIG_KALLSYMS]", ++" f7e66420 dm_region_hash f7e65000 9708 (not loaded) [CONFIG_KALLSYMS]", ++" f7e76b60 dm_mirror f7e74000 12609 (not loaded) [CONFIG_KALLSYMS]", ++" f7e8b8e0 ata_piix f7e87000 20637 (not loaded) [CONFIG_KALLSYMS]", ++" ...", + " ", + " Load the symbolic and debugging data of all modules:\n", + " %s> mod -S", +-" MODULE NAME SIZE OBJECT FILE", +-" c8019000 soundcore 2788 /lib/modules/2.2.5-15/misc/soundcore.o", +-" c801b000 soundlow 336 /lib/modules/2.2.5-15/misc/soundlow.o", +-" c801d000 sound 59864 /lib/modules/2.2.5-15/misc/sound.o", +-" c802d000 ad1848 15728 /lib/modules/2.2.5-15/misc/ad1848.o", +-" c8032000 uart401 6000 /lib/modules/2.2.5-15/misc/uart401.o", +-" c8035000 cs4232 2472 /lib/modules/2.2.5-15/misc/cs4232.o", +-" c8043000 opl3 11048 /lib/modules/2.2.5-15/misc/opl3.o", +-" c8047000 3c59x 18152 /lib/modules/2.2.5-15/net/3c59x.o", +-" c804d000 sunrpc 53796 /lib/modules/2.2.5-15/misc/sunrpc.o", +-" c805c000 lockd 31528 /lib/modules/2.2.5-15/fs/lockd.o", +-" c8065000 nfsd 151896 /lib/modules/2.2.5-15/fs/nfsd.o", +-" c8092000 nfs 29752 /lib/modules/2.2.5-15/fs/nfs.o", ++" MODULE NAME BASE SIZE OBJECT FILE", ++" f7e44c20 dm_mod f7e34000 88568 /lib/modules/2.6.32/kernel/drivers/md/dm-mod.ko", ++" f7e5a8a0 dm_log f7e59000 8354 /lib/modules/2.6.32/kernel/drivers/md/dm-log.ko", ++" f7e66420 dm_region_hash f7e65000 9708 /lib/modules/2.6.32/kernel/drivers/md/dm-region-hash.ko", ++" f7e76b60 dm_mirror f7e74000 12609 /lib/modules/2.6.32/kernel/drivers/md/dm-mirror.ko", ++" f7e8b8e0 ata_piix f7e87000 20637 /lib/modules/2.6.32/kernel/drivers/ata/ata_piix.ko", ++" ...", + " ", +-" Load the symbolic and debugging data of the soundcore module from its", ++" Load the symbolic and debugging data of the dm_mod module from its", + " known location:", + " ", +-" %s> mod -s soundcore", +-" MODULE NAME SIZE OBJECT FILE", +-" c8019000 soundcore 2788 /lib/modules/2.2.5-15/misc/soundcore.o", ++" %s> mod -s dm_mod", ++" MODULE NAME BASE SIZE OBJECT FILE", ++" f7e44c20 dm_mod f7e34000 88568 /lib/modules/2.6.32/kernel/drivers/md/dm-mod.ko", + " ", +-" Delete the current symbolic and debugging data of the soundcore module, ", ++" Delete the current symbolic and debugging data of the dm_mod module,", + " and then re-load it from a specified object file:", + " ", +-" %s> mod -d soundcore", +-" %s> mod -s soundcore /tmp/soundcore.o", +-" MODULE NAME SIZE OBJECT FILE", +-" c8019000 soundcore 2788 /tmp/soundcore.o", ++" %s> mod -d dm_mod", ++" %s> mod -s dm_mod /tmp/dm_mod.ko", ++" MODULE NAME BASE SIZE OBJECT FILE", ++" f7e44c20 dm_mod f7e34000 88568 /tmp/dm-mod.ko", + " ", + " After installing a new kernel module on a live system, reinitialize the", + " installed module list:\n", +-" %s> !insmod mdacon", ++" %s> !modprobe soundcore", + " %s> mod", + " mod: NOTE: modules have changed on this system -- reinitializing", +-" MODULE NAME SIZE OBJECT FILE", +-" c8019000 soundcore 2788 (not loaded)", +-" c801b000 soundlow 336 (not loaded)", +-" c801d000 sound 59864 (not loaded)", +-" c802d000 ad1848 15728 (not loaded)", +-" c8032000 uart401 6000 (not loaded)", +-" c8035000 cs4232 2472 (not loaded)", +-" c8043000 opl3 11048 (not loaded)", +-" c8047000 3c59x 18152 (not loaded)", +-" c804d000 sunrpc 53796 (not loaded)", +-" c805c000 lockd 31528 (not loaded)", +-" c8065000 nfs 29752 (not loaded)", +-" c806e000 autofs 9316 (not loaded)", +-" c8072000 nfsd 151896 (not loaded)", +-" c80a1000 mdacon 3556 (not loaded)", ++" MODULE NAME BASE SIZE OBJECT FILE", ++" f7e44c20 dm_mod f7e34000 88568 (not loaded)", ++" f7e5a8a0 dm_log f7e59000 8354 (not loaded)", ++" f7e62e40 soundcore f7e62000 6390 (not loaded)", ++" f7e66420 dm_region_hash f7e65000 9708 (not loaded)", ++" f7e76b60 dm_mirror f7e74000 12609 (not loaded)", ++" f7e8b8e0 ata_piix f7e87000 20637 (not loaded)", ++" ...", + " ", + " Display modules that are \"tainted\", where in this case", + " where they are proprietary and unsigned:", +diff --git a/kernel.c b/kernel.c +index 5fcd86575be5..ac765e302639 100644 +--- a/kernel.c ++++ b/kernel.c +@@ -4473,6 +4473,7 @@ do_module_cmd(ulong flag, char *modref, ulong address, + char buf1[BUFSIZE]; + char buf2[BUFSIZE]; + char buf3[BUFSIZE]; ++ char buf4[BUFSIZE]; + + if (NO_MODULES()) + return; +@@ -4494,10 +4495,12 @@ do_module_cmd(ulong flag, char *modref, ulong address, + } + + if (flag == LIST_MODULE_HDR) { +- fprintf(fp, "%s %s %s OBJECT FILE\n", ++ fprintf(fp, "%s %s %s %s OBJECT FILE\n", + mkstring(buf1, VADDR_PRLEN, CENTER|LJUST, + "MODULE"), + mkstring(buf2, maxnamelen, LJUST, "NAME"), ++ mkstring(buf4, VADDR_PRLEN, CENTER|LJUST, ++ "BASE"), + mkstring(buf3, maxsizelen, RJUST, "SIZE")); + } + +@@ -4509,6 +4512,8 @@ do_module_cmd(ulong flag, char *modref, ulong address, + LONG_HEX|RJUST, MKSTR(lm->module_struct))); + fprintf(fp, "%s ", mkstring(buf2, maxnamelen, + LJUST, lm->mod_name)); ++ fprintf(fp, "%s ", mkstring(buf4, VADDR_PRLEN, ++ LONG_HEX|RJUST, MKSTR(lm->mod_base))); + fprintf(fp, "%s ", mkstring(buf3, maxsizelen, + RJUST|LONG_DEC, MKSTR(lm->mod_size))); + // fprintf(fp, "%6ld ", lm->mod_size); +-- +2.17.1 + diff --git a/0013-xen-increase-__PHYSICAL_MASK_SHIFT_XEN-to-52.patch b/0013-xen-increase-__PHYSICAL_MASK_SHIFT_XEN-to-52.patch new file mode 100644 index 0000000..0aab22c --- /dev/null +++ b/0013-xen-increase-__PHYSICAL_MASK_SHIFT_XEN-to-52.patch @@ -0,0 +1,43 @@ +From fdb41f0b6fa42a692e5fa39da3801f6ca18e8a6b Mon Sep 17 00:00:00 2001 +From: Jiri Bohac +Date: Mon, 25 Jan 2021 22:44:50 +0100 +Subject: [PATCH 13/13] xen: increase __PHYSICAL_MASK_SHIFT_XEN to 52 + +The current value of __PHYSICAL_MASK_SHIFT_XEN in crash (40) is +smaller than the kernel (52) since kernel commit 6f0e8bf167 (xen: +support 52 bit physical addresses in pv guests). + +This can cause x86_64_pud_offset() to lose the most significant +bits of pgd_pte, leading to a failed xen_m2p() translation, +resulting in crash failing with an error message like this: + crash: read error: physical address: ffffffffffffffff type: "pud page" + +Both Intel and AMD documentation mandate that unused physical +address bits must be 0, so there is no need to explicitly mask them +out with a mask narrower than the architecture limit of 52. This +is also confirmed by this kernel commit: b83ce5ee91. + +Increase the value of __PHYSICAL_MASK_SHIFT_XEN to 52. + +Signed-off-by: Jiri Bohac +Signed-off-by: Lianbo Jiang +--- + defs.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/defs.h b/defs.h +index ffbe73bfb508..35cdac20420c 100644 +--- a/defs.h ++++ b/defs.h +@@ -3585,7 +3585,7 @@ struct arm64_stackframe { + * PHYSICAL_PAGE_MASK changed (enlarged) between 2.4 and 2.6, so + * for safety, use the 2.6 values to generate it. + */ +-#define __PHYSICAL_MASK_SHIFT_XEN 40 ++#define __PHYSICAL_MASK_SHIFT_XEN 52 + #define __PHYSICAL_MASK_SHIFT_2_6 46 + #define __PHYSICAL_MASK_SHIFT_5LEVEL 52 + #define __PHYSICAL_MASK_SHIFT (machdep->machspec->physical_mask_shift) +-- +2.17.1 + diff --git a/crash.spec b/crash.spec index 6379923..8252b7b 100644 --- a/crash.spec +++ b/crash.spec @@ -4,7 +4,7 @@ Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash Version: 7.2.9 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv3 Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz Source1: http://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.gz @@ -21,6 +21,19 @@ Patch0: lzo_snappy.patch Patch1: use_system_readline_v3.patch Patch2: printk-add-support-for-lockless-ringbuffer.patch Patch3: printk-use-committed-finalized-state-values.patch +Patch4: 0001-x86_64-VC-exception-stack-support.patch +Patch5: 0002-netdump-fix-regression-for-raw-RAM-dumpfiles.patch +Patch6: 0003-arm64-update-mapping-symbol-filter-in-arm64_verify_s.patch +Patch7: 0004-extensions-eppic.mk-move-ping-check-to-recipe-script.patch +Patch8: 0005-Fix-segmentation-fault-when-ikconfig-passed-nonstand.patch +Patch9: 0006-netdump-fix-illegal-read-from-already-freed-buffer.patch +Patch10: 0007-tools-fix-potential-source-and-destination-overlap-w.patch +Patch11: 0008-set-add-ability-to-un-set-scope.patch +Patch12: 0009-Fix-sys-t-mod-S-after-mod-t-when-crash-runs-with-s-o.patch +Patch13: 0010-Fix-dev-d-option-on-Linux-5.11-rc1-and-later-kernels.patch +Patch14: 0011-Fix-kmem-v-option-on-Linux-5.11-rc1-and-later-kernel.patch +Patch15: 0012-mod-Show-the-base-address-of-module.patch +Patch16: 0013-xen-increase-__PHYSICAL_MASK_SHIFT_XEN-to-52.patch %description The core analysis suite is a self-contained tool that can be used to @@ -44,6 +57,19 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %patch1 -p1 -b use_system_readline_v3.patch %patch2 -p1 -b printk-add-support-for-lockless-ringbuffer.patch %patch3 -p1 -b printk-use-committed-finalized-state-values.patch +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 %build # This package has an internal copy of GDB which has broken configure code for @@ -75,6 +101,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Fri Feb 05 2021 Lianbo Jiang - 7.2.9-4 +- Update to the latest upstream: commit + * Tue Jan 26 2021 Fedora Release Engineering - 7.2.9-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild