diff --git a/gdb-rhbz2259850-list-period-crash-fix.patch b/gdb-rhbz2259850-list-period-crash-fix.patch new file mode 100644 index 0000000000000000000000000000000000000000..c3fba4af4b2f404375c165bf819523859e7754e8 --- /dev/null +++ b/gdb-rhbz2259850-list-period-crash-fix.patch @@ -0,0 +1,123 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Guinevere Larsen +Date: Mon, 22 Jan 2024 10:13:52 +0100 +Subject: gdb-rhbz2259850-list-period-crash-fix.patch + +;; Backport gdb: fix "list ." related crash + +When a user attempts to use the "list ." command with an inferior that +doesn't have debug symbols, GDB would crash. This was reported as PR +gdb/31256. + +The crash would happen when attempting to get the current +symtab_and_line +for the stop location, because the symtab would return a null pointer +and we'd attempt to dereference it to print the line. + +This commit fixes that by checking for an empty symtab and erroring out +of the function if it happens. + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31256 +Approved-By: Tom Tromey + +--- + gdb/cli/cli-cmds.c | 3 ++ + gdb/testsuite/gdb.base/list-nodebug.c | 24 +++++++++++++++ + gdb/testsuite/gdb.base/list-nodebug.exp | 40 +++++++++++++++++++++++++ + 3 files changed, 67 insertions(+) + create mode 100644 gdb/testsuite/gdb.base/list-nodebug.c + create mode 100644 gdb/testsuite/gdb.base/list-nodebug.exp + +diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c +index 8cadd63..ce0dc41 100644 +--- a/gdb/cli/cli-cmds.c ++++ b/gdb/cli/cli-cmds.c +@@ -1291,6 +1291,9 @@ list_command (const char *arg, int from_tty) + set_default_source_symtab_and_line (); + cursal = get_current_source_symtab_and_line (); + } ++ ++ if (cursal.symtab == nullptr) ++ error (_("No debug information available to print source lines.")); + list_around_line (arg, cursal); + /* Set the repeat args so just pressing "enter" after using "list ." + will print the following lines instead of the same lines again. */ +diff --git a/gdb/testsuite/gdb.base/list-nodebug.c b/gdb/testsuite/gdb.base/list-nodebug.c +new file mode 100644 +index 0000000..8df8f3f +--- /dev/null ++++ b/gdb/testsuite/gdb.base/list-nodebug.c +@@ -0,0 +1,24 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2024-2025 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++extern int foo (void); ++ ++int ++main (void) ++{ ++ return foo (); ++} +diff --git a/gdb/testsuite/gdb.base/list-nodebug.exp b/gdb/testsuite/gdb.base/list-nodebug.exp +new file mode 100644 +index 0000000..d92201b +--- /dev/null ++++ b/gdb/testsuite/gdb.base/list-nodebug.exp +@@ -0,0 +1,40 @@ ++# Copyright 2024-2025 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Test that using the command "list" in a file with no debug information ++# will not crash GDB and will give reasonable output. ++ ++standard_testfile .c -2.c ++ ++if { [prepare_for_testing_full "failed to prepare" \ ++ [list \ ++ $testfile {} \ ++ $srcfile {nodebug} \ ++ $srcfile2 {debug}]] } { ++ return -1 ++} ++ ++if {![runto_main]} { ++ untested "couldn't run to main" ++ return ++} ++ ++# Check that GDB doesn't crash when we use list . on an inferior with ++# no debug information ++gdb_test "list ." "Insufficient debug.*" "first 'list .'" ++# This should be called twice because the first list invocation since ++# printing a frame may take a different codepath, which wouldn't ++# trigger the crash. ++gdb_test "list ." "Insufficient debug.*" "second 'list .'" +-- +2.43.0 + diff --git a/gdb.spec b/gdb.spec index fc206eb8056ddd11d9d0a3f27b70e63489420d1a..2be066e10480c195b22e6872911b91681f6665fb 100644 --- a/gdb.spec +++ b/gdb.spec @@ -1,6 +1,6 @@ Name: gdb Version: 14.1 -Release: 5 +Release: 6 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL-1.3 Source: https://ftp.gnu.org/gnu/gdb/gdb-%{version}.tar.xz @@ -59,6 +59,7 @@ Patch46: gdb-rhbz2257562-cp-namespace-null-ptr-check.patch Patch47: gdb-ftbs-swapped-calloc-args.patch # Fedra patch end Patch48: Fix-CVE-2025-7546.patch +Patch49: gdb-rhbz2259850-list-period-crash-fix.patch Patch9000: 0001-set-entry-point-when-text-segment-is-missing.patch @@ -336,6 +337,9 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/gdb/python/gdb/command/backtrace.py %{_infodir}/ctf-spec.info* %changelog +* Mon Sep 08 2025 Deyuan Fan - 14.1-6 +- gdb: fix "list ." related crash + * Mon Jul 28 2025 zhangjian - 14.1-5 - Fix CVE-2025-7546