mbox series

[v3,0/2] fix reading ESP during coredump

Message ID cover.1735805772.git.namcao@linutronix.de (mailing list archive)
Headers show
Series fix reading ESP during coredump | expand

Message

Nam Cao Jan. 2, 2025, 8:22 a.m. UTC
Hi,

In /proc/PID/stat, there is the kstkesp field which is the stack pointer of
a thread. While the thread is active, this field reads zero. But during a
coredump, it should have a valid value.

However, at the moment, kstkesp is zero even during coredump.

The first commit fixes this problem, and the second commit adds a selftest
to detect if this problem appears again in the future.

v2..v3 https://lore.kernel.org/lkml/cover.1735550994.git.namcao@linutronix.de/
  - Move stackdump file to local directory [Kees]
  - Always cleanup the stackdump file after the test [Kees]
  - Remove unused empty function

v1..v2 https://lore.kernel.org/lkml/cover.1730883229.git.namcao@linutronix.de/
  - Change the fix patch to use PF_POSTCOREDUMP [Oleg]

Nam Cao (2):
  fs/proc: do_task_stat: Fix ESP not readable during coredump
  selftests: coredump: Add stackdump test

 fs/proc/array.c                               |   2 +-
 tools/testing/selftests/coredump/Makefile     |   7 +
 tools/testing/selftests/coredump/README.rst   |  50 ++++++
 tools/testing/selftests/coredump/stackdump    |  14 ++
 .../selftests/coredump/stackdump_test.c       | 151 ++++++++++++++++++
 5 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/coredump/Makefile
 create mode 100644 tools/testing/selftests/coredump/README.rst
 create mode 100755 tools/testing/selftests/coredump/stackdump
 create mode 100644 tools/testing/selftests/coredump/stackdump_test.c

Comments

Christian Brauner Jan. 4, 2025, 8:57 a.m. UTC | #1
On Thu, 02 Jan 2025 09:22:55 +0100, Nam Cao wrote:
> In /proc/PID/stat, there is the kstkesp field which is the stack pointer of
> a thread. While the thread is active, this field reads zero. But during a
> coredump, it should have a valid value.
> 
> However, at the moment, kstkesp is zero even during coredump.
> 
> The first commit fixes this problem, and the second commit adds a selftest
> to detect if this problem appears again in the future.
> 
> [...]

Applied to the vfs-6.14.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.14.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.14.misc

[1/2] fs/proc: do_task_stat: Fix ESP not readable during coredump
      https://git.kernel.org/vfs/vfs/c/e37bea052952
[2/2] selftests: coredump: Add stackdump test
      https://git.kernel.org/vfs/vfs/c/49db83214002