From aa9cd1f14904558c76021cb662eba9fda45aec9d Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 28 Jul 2025 15:09:54 +0800 Subject: [PATCH] Sync to upstream commit 2c69f93e59c6 Release: crash-9.0.0-3 Resolves: RHEL-102021 Signed-off-by: Lianbo Jiang --- ...nwanted-warning-message-for-bt-T-cmd.patch | 53 ++++++++++ ...-requirements-for-building-on-Fedora.patch | 51 ++++++++++ ...sion-for-eppic-extension-on-gdb-16.2.patch | 98 +++++++++++++++++++ ...lization-failure-on-LoongArch-with-r.patch | 42 ++++++++ ...EBUG-lookup-by-GDB-inside-the-vmcore.patch | 93 ++++++++++++++++++ crash.spec | 19 +++- 6 files changed, 355 insertions(+), 1 deletion(-) create mode 100644 0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch create mode 100644 0002-doc-Update-requirements-for-building-on-Fedora.patch create mode 100644 0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch create mode 100644 0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch create mode 100644 0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch diff --git a/0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch b/0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch new file mode 100644 index 0000000..adaa340 --- /dev/null +++ b/0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch @@ -0,0 +1,53 @@ +From 145cc6a75f24dfce2e644b620b3afb6de04cadfd Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Wed, 9 Jul 2025 17:41:12 +1200 +Subject: [PATCH 1/5] x86_64: filter unwanted warning message for "bt -T" cmd + +After patch "x86_64: Add gdb multi-stack unwind support" applied, a +warning message is observed for "bt -T" cmd: + + crash> bt -T + bt: seek error: kernel virtual address: fffffffffffffffb type: "gdb_readmem_callback" + [ffffbaebc60d6fa8] srso_return_thunk at ffffffff82246fa5 + ... + +The root cause is, "bt -T" will set BT_TEXT_SYMBOLS_ALL for bt->flags, +and eip is set to be 0 in kernel.c:back_trace(). Later in +x86_64_low_budget_back_trace_cmd(), eip - 5, or 0xfffffffffffffffb is +used for address disassembly by gdb "x/1i 0x%lx". This address is invalid so +the warning message is output. + +In fact, multi-stack unwind isn't designed for "bt -T" and eip = 0 case. +To avoid the warning message, let's simply bypass the "bt -T" case for +x86_64. Other archs(arm64/ppc64) aren't affected by the issue because +the gdb "x/1i 0x%lx" are not applied on those archs. + +After apply the patch: + + crash> bt -T + [ffffbaebc60d6fa8] srso_return_thunk at ffffffff82246fa5 + ... + +Signed-off-by: Tao Liu +Signed-off-by: Lianbo Jiang +--- + x86_64.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/x86_64.c b/x86_64.c +index cfefe3f80c4f..d7da536d20d8 100644 +--- a/x86_64.c ++++ b/x86_64.c +@@ -3636,7 +3636,8 @@ x86_64_low_budget_back_trace_cmd(struct bt_info *bt_in) + level++; + } + +- if (is_task_active(bt->task) && bt->flags & BT_DUMPFILE_SEARCH) { ++ if (is_task_active(bt->task) && bt->flags & BT_DUMPFILE_SEARCH && ++ !(bt->flags & BT_TEXT_SYMBOLS_ALL)) { + if (!extra_stacks_regs[extra_stacks_idx]) { + extra_stacks_regs[extra_stacks_idx] = + (struct user_regs_bitmap_struct *) +-- +2.50.0 + diff --git a/0002-doc-Update-requirements-for-building-on-Fedora.patch b/0002-doc-Update-requirements-for-building-on-Fedora.patch new file mode 100644 index 0000000..462343e --- /dev/null +++ b/0002-doc-Update-requirements-for-building-on-Fedora.patch @@ -0,0 +1,51 @@ +From 6167a55b227db61eb52c2a4f96f44fc559a8b1d0 Mon Sep 17 00:00:00 2001 +From: Charles Haithcock +Date: Fri, 18 Jul 2025 16:14:25 -0600 +Subject: [PATCH 2/5] doc: Update requirements for building on Fedora + +Attempting to build on Fedora fails with the following error; + +$ make +TARGET: RISCV64 + CRASH: 9.0.0++ + GDB: 16.2 + +Saving 'gdb-16.2.tar.gz' +[...] +checking for the correct version of gmp.h... no +configure: error: Building GDB requires GMP 4.2+, and MPFR 3.1.0+. +Try the --with-gmp and/or --with-mpfr options to specify +their locations. If you obtained GMP and/or MPFR from a vendor +distribution package, make sure that you have installed both the libraries +and the header files. They may be located in separate packages. +make[2]: *** No targets specified and no makefile found. Stop. + +crash build failed + +make[1]: *** [Makefile:316: gdb_merge] Error 1 +make: *** [Makefile:307: all] Error 2 + +Installing gmp-devel and mpfr-devel fixed this, so this patch updates the +requirements for building on Fedora. + +Signed-off-by: Lianbo Jiang +--- + README | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/README b/README +index 2e34fbb15f1a..f9824c7240bf 100644 +--- a/README ++++ b/README +@@ -73,7 +73,7 @@ + that is created in the top-level kernel build directory must be saved. + + o Requirements for building: +- Fedora: make gcc gcc-c++ ncurses-devel zlib-devel lzo-devel snappy-devel bison wget patch texinfo libzstd-devel ++ Fedora: make gcc gcc-c++ ncurses-devel zlib-devel lzo-devel snappy-devel bison wget patch texinfo libzstd-devel gmp-devel mpfr-devel + Ubuntu/Debian: make gcc g++ libncurses-dev zlib1g-dev liblzo2-dev libsnappy-dev bison wget patch texinfo libzstd-dev + Arch Linux: make gcc ncurses zlib lzo snappy bison wget patch texinfo zstd + openSUSE: make gcc gcc-c++ ncurses-devel zlib-devel lzo-devel snappy-devel bison wget patch texinfo libzstd-devel +-- +2.50.0 + diff --git a/0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch b/0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch new file mode 100644 index 0000000..2fb513b --- /dev/null +++ b/0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch @@ -0,0 +1,98 @@ +From 6642b2729067399696f8f24f29267b3483d895c6 Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Tue, 8 Jul 2025 13:26:38 +1200 +Subject: [PATCH 3/5] gdb: Fix a regression for eppic extension on gdb-16.2 + +There is a regression found when testing eppic extension on gdb-16.2 +crash: + + crash> cgroup + /root/.eppic/cgroup.c : line 99 : Error: undefined variable 'cgroup_roots' + +The root cause is when doing gdb upgrading, the replacement of +gdb_get_datatype() is incorrect: + +The original gdb-10.2 version: + + long value = SYMBOL_VALUE(expr->elts[2].symbol); + +The incorrect gdb-16.2 replacement: + + long value = value_as_long(expr->evaluate()); + +According to gdb/tracepoint.c, the correct gdb-16.2 replacement should be: + + symbol *sym; + expr::var_value_operation *vvop + = (gdb::checked_static_cast + (exp->op.get ())); + sym = vvop->get_symbol (); + long value = sym->value_longest (); + +Otherwise, the value_as_long() will throw an exception when trying to +convert a struct into long, such as "cgroup_roots". The reason why this +issue only observed on crash extensions, is the faulty code block +triggered with "req->tcb", which is a callback for gdb_interface(), and +the callback is used by eppic extension, but the normal crash internal calls +hardly use it. + +After: + crash> cgroup + 0:/user.slice/user-1000.slice/session-2.scope + +Signed-off-by: Tao Liu +Signed-off-by: Lianbo Jiang +--- + gdb-16.2.patch | 32 +++++++++++++++++++++++++++++++- + 1 file changed, 31 insertions(+), 1 deletion(-) + +diff --git a/gdb-16.2.patch b/gdb-16.2.patch +index 151e4e2039d9..9d056580b2f7 100644 +--- a/gdb-16.2.patch ++++ b/gdb-16.2.patch +@@ -9,7 +9,8 @@ + # to all subsequent patch applications. + + tar xvzmf gdb-16.2.tar.gz \ +- gdb-16.2/gdb/symfile.c ++ gdb-16.2/gdb/symfile.c \ ++ gdb-16.2/gdb/symtab.c + + exit 0 + +@@ -1952,3 +1953,32 @@ exit 0 + } + + /* Remember the bfd indexes for the .text, .data, .bss and ++--- gdb-16.2/gdb/symtab.c.orig +++++ gdb-16.2/gdb/symtab.c ++@@ -7690,7 +7690,11 @@ ++ console("expr->first_opcode(): OP_VAR_VALUE\n"); ++ type = expr->evaluate_type()->type(); ++ if (req->tcb) { ++- long value = value_as_long(expr->evaluate()); +++ expr::var_value_operation *vvop +++ = (gdb::checked_static_cast +++ (expr->op.get ())); +++ sym = vvop->get_symbol (); +++ long value = sym->value_longest (); ++ /* callback with symbol value */ ++ req->typecode = TYPE_CODE(type); ++ req->tcb(EOP_VALUE, req, &value, 0, 0, 0); ++@@ -7701,8 +7705,12 @@ ++ req->length = type->length(); ++ } ++ if (TYPE_CODE(type) == TYPE_CODE_ENUM) { +++ expr::var_value_operation *vvop +++ = (gdb::checked_static_cast +++ (expr->op.get ())); +++ sym = vvop->get_symbol (); ++ req->typecode = TYPE_CODE(type); ++- req->value = value_as_long(expr->evaluate()); +++ req->value = sym->value_longest (); ++ req->tagname = (char *)TYPE_TAG_NAME(type); ++ if (!req->tagname) { ++ val = expr->evaluate_type(); +-- +2.50.0 + diff --git a/0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch b/0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch new file mode 100644 index 0000000..6d8da1a --- /dev/null +++ b/0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch @@ -0,0 +1,42 @@ +From 31a69d378efb4319a5b9ef8cf3d7a93030f5c863 Mon Sep 17 00:00:00 2001 +From: Ming Wang +Date: Mon, 9 Jun 2025 11:03:02 +0800 +Subject: [PATCH 4/5] Fix crash initialization failure on LoongArch with recent + GDB versions + +The crash tool failed to initialize on LoongArch64 when using +GDB 16.2 (and likely other recent GDB versions that have enhanced +LoongArch support) due to the error: +"fatal error: buffer size is not enough to fit register value". + +This occurs in supply_registers() because GDB now correctly +reports the size of LoongArch LASX (256-bit) vector registers +(xr0-xr31) as 32 bytes. The `regval` buffer in `crash_target.c` +was previously fixed at 16 bytes. + +This patch increases the `regval` buffer size to 32 bytes to +accommodate the largest LoongArch registers reported by GDB. +This allows crash to initialize successfully. + +Signed-off-by: Ming Wang +Signed-off-by: Lianbo Jiang +--- + crash_target.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/crash_target.c b/crash_target.c +index ad1480c9188f..49c6e88c5140 100644 +--- a/crash_target.c ++++ b/crash_target.c +@@ -80,7 +80,7 @@ public: + + static void supply_registers(struct regcache *regcache, int regno) + { +- gdb_byte regval[16]; ++ gdb_byte regval[32]; + struct gdbarch *arch = regcache->arch (); + const char *regname = gdbarch_register_name(arch, regno); + int regsize = register_size(arch, regno); +-- +2.50.0 + diff --git a/0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch b/0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch new file mode 100644 index 0000000..c8c3cc0 --- /dev/null +++ b/0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch @@ -0,0 +1,93 @@ +From 2c69f93e59c6b2efac5bae9f7891dbe1e0094fdd Mon Sep 17 00:00:00 2001 +From: Shivang Upadhyay +Date: Mon, 21 Jul 2025 13:47:33 +0530 +Subject: [PATCH 5/5] gdb: Disable DT_DEBUG lookup by GDB inside the vmcore + +Crash with GDB 16.2, the following warnings are printed: + +crash> +crash: page excluded: kernel virtual address: c0000000022d6098 type: "gdb_readmem_callback" +crash: page excluded: kernel virtual address: c0000000022d6098 type: "gdb_readmem_callback" + +This occurs because the elf_locate_base function in GDB 16.2 +attempts to read the address of the dynamic linker runtime +structure, which is present in the .dynamic section of the +executable. However, this section may be excluded from the +dump by makedumpfile. + +The repeated calls to elf_locate_base were introduced by gdb +commit [1] aebb370 ("gdb, solib-svr4: support namespaces in +DSO iteration") via svr4_iterate_over_objfiles_in_search_order. + +To check whether the kernel includes DT_DEBUG information, +prints were added inside crash::xfer_partial, which is +called through elf_locate_base when reading from vmcore. +Even when running crash on /proc/kcore, all output data was +zero. This confirms that DT_DEBUG information is never +present in the kernel image. + +`mod -S` continues to function correctly after the following +patch: + +... +crash> mod -S +Enable debuginfod for this session? (y or [n]) + MODULE NAME TEXT_BASE SIZE OBJECT FILE +c0080000004a0300 dm_log c008000000480000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/md/dm-log.ko +c0080000006d1100 sd_mod c008000000580000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/scsi/sd_mod.ko +c0080000005c0080 dm_region_hash c0080000005a0000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/md/dm-region-hash.ko +c008000000770700 sg c008000000620000 262144 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/scsi/sg.ko +c008000000660500 dm_mirror c008000000640000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/md/dm-mirror.ko +... + +Commit e906eaca2b1a ("Fix the issue of "page excluded" +messages flooding") attempted fix this by suppressing these +warnings for regular users, but the warnings still appear +when crash is started in debug mode. + +To fix this, remove the DT_DEBUG read call, from the +elf_locate_base function in GDB that tries to read the +.dynamic section, as this information is not useful for +debugging kernel images in either dump or live kernel +scenarios. + +[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aebb370 + +Cc: Tao liu +Cc: Lianbo Jiang +Cc: Sourabh Jain +Signed-off-by: shivang.upadhyay +Signed-off-by: Lianbo Jiang +--- + gdb-16.2.patch | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/gdb-16.2.patch b/gdb-16.2.patch +index 9d056580b2f7..6767bf7d7bf0 100644 +--- a/gdb-16.2.patch ++++ b/gdb-16.2.patch +@@ -1982,3 +1982,21 @@ exit 0 + req->tagname = (char *)TYPE_TAG_NAME(type); + if (!req->tagname) { + val = expr->evaluate_type(); ++--- gdb-16.2/gdb/solib-svr4.c.orig +++++ gdb-16.2/gdb/solib-svr4.c ++@@ -741,13 +741,13 @@ ++ return 0; ++ return extract_typed_address (pbuf, ptr_type); ++ } ++- +++#ifndef CRASH_MERGE ++ /* Find DT_DEBUG. */ ++ if (gdb_bfd_scan_elf_dyntag (DT_DEBUG, current_program_space->exec_bfd (), ++ &dyn_ptr, NULL) ++ || scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL)) ++ return dyn_ptr; ++- +++#endif ++ /* This may be a static executable. Look for the symbol ++ conventionally named _r_debug, as a last resort. */ ++ bound_minimal_symbol msymbol +-- +2.50.0 + diff --git a/crash.spec b/crash.spec index 948f96a..06e9132 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: 9.0.0 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3 Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz Source1: http://ftp.gnu.org/gnu/gdb/gdb-16.2.tar.gz @@ -28,6 +28,11 @@ Patch7: 0006-arm64-Add-gdb-multi-stack-unwind-support.patch Patch8: 0007-ppc64-Add-gdb-multi-stack-unwind-support.patch Patch9: 0008-Fix-the-issue-of-page-excluded-messages-flooding.patch Patch10: 0009-Fix-kmem-p-option-on-Linux-6.16-rc1-and-later-kernel.patch +Patch11: 0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch +Patch12: 0002-doc-Update-requirements-for-building-on-Fedora.patch +Patch13: 0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch +Patch14: 0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch +Patch15: 0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch %description The core analysis suite is a self-contained tool that can be used to @@ -58,6 +63,11 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %patch -P 8 -p1 %patch -P 9 -p1 %patch -P 10 -p1 +%patch -P 11 -p1 +%patch -P 12 -p1 +%patch -P 13 -p1 +%patch -P 14 -p1 +%patch -P 15 -p1 %build @@ -83,6 +93,13 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Mon Jul 28 2025 Lianbo Jiang - 9.0.0-3 +- x86_64: filter unwanted warning message for "bt -T" cmd +- doc: Update requirements for building on Fedora +- gdb: Fix a regression for eppic extension on gdb-16.2 +- Fix crash initialization failure on LoongArch with recent GDB versions +- gdb: Disable DT_DEBUG lookup by GDB inside the vmcore + * Tue Jul 01 2025 Lianbo Jiang - 9.0.0-2 - vmware_guestdump: Version 7 support - Fix incorrect task state during exit