From 6f75945b1aafbe35b67499ded94012f8019499d8 Mon Sep 17 00:00:00 2001 From: Chaitanya Rahalkar Date: Sun, 30 Mar 2025 20:57:42 -0600 Subject: [PATCH 1/2] Enhance CI script to check for core file generation and improve logging in corefile extraction process. --- .github/workflows/ci.yml | 16 +++++++++++++++- pwnlib/elf/corefile.py | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffb3b337e..a5bb92d80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,21 @@ jobs: ulimit -c unlimited cat /proc/sys/kernel/core_pattern cat /proc/sys/kernel/core_uses_pid - ( cd $(mktemp -d); sh -c 'kill -11 $$' || true; ls -la ./*core* /var/crash/*.crash /var/lib/apport/coredump/core*) || true + # Create a temporary directory for the test + TEST_DIR=$(mktemp -d) + cd $TEST_DIR + + # Run a command that will generate a segfault + sh -c 'kill -11 $$' || true + + # Check for core files in various locations + echo "Looking for core files in various locations:" + if ls -la ./*core* /var/crash/*.crash /var/lib/apport/coredump/core* 2>/dev/null; then + echo "SUCCESS: Core file found" + else + echo "ERROR: No core file found" + exit 1 + fi - name: Set up SSH run: | diff --git a/pwnlib/elf/corefile.py b/pwnlib/elf/corefile.py index 1d88ef10c..494afb743 100644 --- a/pwnlib/elf/corefile.py +++ b/pwnlib/elf/corefile.py @@ -1351,6 +1351,7 @@ def systemd_coredump_corefile(self): """ filename = "core.%s.%i.coredumpctl" % (self.basename, self.pid) try: + log.debug("Attempting to extract core dump with coredumpctl for PID %d" % self.pid) subprocess.check_call( [ "coredumpctl", @@ -1363,9 +1364,12 @@ def systemd_coredump_corefile(self): stderr=subprocess.STDOUT, shell=False, ) + log.debug("Successfully extracted core dump to %s" % filename) return filename except subprocess.CalledProcessError as e: log.debug("coredumpctl failed with status: %d" % e.returncode) + except Exception as e: + log.debug("coredumpctl failed with exception: %s" % e) def native_corefile(self): """Find the corefile for a native crash. From 2f3790ff35c0495179c1ec59f7984c0866eca934 Mon Sep 17 00:00:00 2001 From: Chaitanya Rahalkar Date: Sun, 30 Mar 2025 21:01:16 -0600 Subject: [PATCH 2/2] Update CHANGELOG.md to include recent improvements and features in release notes. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a6ea423..d69c0acf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,8 @@ The table below shows which release corresponds to each branch, and what date th - [#2504][2504] doc: add example case for `tuple` (host, port pair) in `gdb.attach` - [#2546][2546] ssh: Allow passing disabled_algorithms keyword argument from ssh to paramiko - [#2538][2538] Add `ssh -L` / `ssh.connect_remote()` workaround when `AllowTcpForwarding` is disabled +- [#2571][2571] Improve CI test for core file generation to fail if no core file is found +- [#2571][2571] Add better logging for systemd-coredump extraction in CorefileFinder [2551]: https://github.com/Gallopsled/pwntools/pull/2551 [2519]: https://github.com/Gallopsled/pwntools/pull/2519 @@ -104,6 +106,7 @@ The table below shows which release corresponds to each branch, and what date th [2504]: https://github.com/Gallopsled/pwntools/pull/2504 [2546]: https://github.com/Gallopsled/pwntools/pull/2546 [2538]: https://github.com/Gallopsled/pwntools/pull/2538 +[2571]: https://github.com/Gallopsled/pwntools/pull/2571 ## 4.15.0 (`beta`)