Skip to content

binfmt_elf,arch/*: Use elf.h for coredump note names

Dave Martin linux-arch linux-arm-kernel linux-csky linux-hexagon linux-m68k linux-mips linux-parisc linux-riscv linux-s390 linux-sh linux-snps-arc linux-um linuxppc-dev lkml loongarch openrisc sparclinux 1 version Applied

Status from this message: Applied to for-next/execve, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest23 patches 11 repliesApplied 1/23

Patches in v1 Applied · 1/23

#Subject and filesSizeRepliesApplied
1/23regset: Fix kerneldoc for struct regset_get() in user_regsetinclude/linux/regset.h+1 -10 replies
2/23regset: Add explicit core note name in struct user_regsetfs/binfmt_elf.c include/linux/regset.h+16 -21 reply
3/23binfmt_elf: Dump non-arch notes with strictly matching name and typefs/binfmt_elf.c fs/binfmt_elf_fdpic.c+23 -210 replies
4/23ARC: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/arc/kernel/ptrace.c+2 -20 replies
5/23ARM: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/arm/kernel/ptrace.c+3 -30 replies
6/23arm64: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/arm64/kernel/ptrace.c+26 -260 replies
7/23csky: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/csky/kernel/ptrace.c+2 -20 replies
8/23hexagon: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/hexagon/kernel/ptrace.c+1 -10 replies
9/23LoongArch: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/loongarch/kernel/ptrace.c+8 -80 replies
10/23m68k: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/m68k/kernel/ptrace.c+2 -22 replies
11/23MIPS: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/mips/kernel/ptrace.c+10 -100 replies
12/23nios2: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/nios2/kernel/ptrace.c+1 -10 replies
13/23openrisc: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/openrisc/kernel/ptrace.c+2 -20 replies
14/23parisc: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/parisc/kernel/ptrace.c+4 -40 replies
15/23powerpc/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/powerpc/kernel/ptrace/ptrace-view.c+37 -370 replies
16/23riscv: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/riscv/kernel/ptrace.c+6 -60 repliesApplied
17/23s390/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/s390/kernel/ptrace.c+21 -211 reply
18/23sh: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/sh/kernel/ptrace_32.c+2 -20 replies
19/23sparc: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/sparc/kernel/ptrace_32.c arch/sparc/kernel/ptrace_64.c+6 -60 replies
20/23x86/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/x86/kernel/ptrace.c+11 -110 replies
21/23um: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/x86/um/ptrace.c+5 -52 replies
22/23xtensa: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note namesarch/xtensa/kernel/ptrace.c+2 -20 replies
23/23binfmt_elf: Warn on missing or suspicious regset note namesfs/binfmt_elf.c+7 -22 replies

Reviews trailers per patch

4 of 23 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJohannes BergGeert UytterhoevenAkihiko OdakiAlexander Gordeev
SeriesR-b
1/23
2/23A-b
3/23
4/23
5/23
6/23
7/23
8/23
9/23
10/23R-b A-b
11/23
12/23
13/23
14/23
15/23
16/23
17/23A-b
18/23
19/23
20/23
21/23A-b T-b
22/23
23/23

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/23] binfmt_elf,arch/*: Use elf.h for coredump note names

This series aims to clean up an aspect of coredump generation:

ELF coredumps contain a set of notes describing the state of machine registers and other information about the dumped process.

Notes are identified by a numeric identifier n_type and a "name" string, although this terminology is somewhat misleading. Officially, the "name" of a note is really an "originator" or namespace identifier that indicates how to interpret n_type [1], although in practice it is often used more loosely.

Either way, each kind of note needs _both_ a specific "name" string and a specific n_type to identify it robustly.

To centralise this knowledge in one place and avoid the need for ad-hoc code to guess the correct name for a given note, commit 7da8e4ad4df0 ("elf: Define note name macros") [2] added an explicit NN_<foo> #define in elf.h to give the name corresponding to each named note type NT_<foo>.

Now that the note name for each note is specified explicitly, the remaining guesswork for determining the note name for common and arch-specific regsets in ELF core dumps can be eliminated.

This series aims to do just that:

* Patch 2 adds a user_regset field to specify the note name, and a helper macro to populate it correctly alongside the note type.

* Patch 3 ports away the ad-hoc note names in the common coredump code.

* Patches 4-22 make the arch-specific changes. (This is pretty mechanical for most arches.)

* The final patch adds a WARN() when no note name is specified, and simplifies the fallback guess. This should only be applied when all arches have ported across.

See the individual patches for details.

Testing:

* x86, arm64: Booted in a VM and triggered a core dump with no WARN(), and verified that the dumped notes are the same.

* arm: Build-tested only (for now).

* Other arches: not tested yet

Any help with testing is appreciated. If the following generates the same notes (as dumped by readelf -n core) and doesn't trigger a WARN, then we are probably good.

$ sleep 60 &
$ kill -QUIT $!

(Register content might differ between runs, but it should be safe to ignore that -- this series only deals with the note names and types.)

Cheers
---Dave

[1] System V Application Binary Interface, Edition 4.1, Section 5 (Program Loading and Dynamic Linking) -> "Note Section"

https://refspecs.linuxfoundation.org/elf/gabi41.pdf

[2] elf: Define note name macros

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/uapi/linux/elf.h?id=7da8e4ad4df0dd12f37357af62ce1b63e75ae2e6

Dave Martin (23):
regset: Fix kerneldoc for struct regset_get() in user_regset
regset: Add explicit core note name in struct user_regset
binfmt_elf: Dump non-arch notes with strictly matching name and type
ARC: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
ARM: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
arm64: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
csky: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
hexagon: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
LoongArch: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
m68k: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
MIPS: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
nios2: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
openrisc: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
parisc: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
powerpc/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
riscv: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
s390/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
sh: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
sparc: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
x86/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
um: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
xtensa: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note
names
binfmt_elf: Warn on missing or suspicious regset note names

 arch/arc/kernel/ptrace.c                 |  4 +-
 arch/arm/kernel/ptrace.c                 |  6 +-
 arch/arm64/kernel/ptrace.c               | 52 ++++++++---------
 arch/csky/kernel/ptrace.c                |  4 +-
 arch/hexagon/kernel/ptrace.c             |  2 +-
 arch/loongarch/kernel/ptrace.c           | 16 ++---
 arch/m68k/kernel/ptrace.c                |  4 +-
 arch/mips/kernel/ptrace.c                | 20 +++----
 arch/nios2/kernel/ptrace.c               |  2 +-
 arch/openrisc/kernel/ptrace.c            |  4 +-
 arch/parisc/kernel/ptrace.c              |  8 +--
 arch/powerpc/kernel/ptrace/ptrace-view.c | 74 ++++++++++++------------
 arch/riscv/kernel/ptrace.c               | 12 ++--
 arch/s390/kernel/ptrace.c                | 42 +++++++-------
 arch/sh/kernel/ptrace_32.c               |  4 +-
 arch/sparc/kernel/ptrace_32.c            |  4 +-
 arch/sparc/kernel/ptrace_64.c            |  8 +--
 arch/x86/kernel/ptrace.c                 | 22 +++----
 arch/x86/um/ptrace.c                     | 10 ++--
 arch/xtensa/kernel/ptrace.c              |  4 +-
 fs/binfmt_elf.c                          | 36 +++++++-----
 fs/binfmt_elf_fdpic.c                    | 17 +++---
 include/linux/regset.h                   | 12 +++-
 23 files changed, 194 insertions(+), 173 deletions(-)

base-commit: 86731a2a651e58953fc949573895f2fa6d456841

Signature · 1 line
2.34.1