summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorSvetlana Parfenova <svetlana.parfenova@syntacore.com>2025-09-01 16:53:50 +0300
committerKees Cook <kees@kernel.org>2025-09-04 06:49:32 +0300
commit8c94db0ae97c72c253a615f990bd466b456e94f6 (patch)
tree6314c271d881ad51b48e1169de596a74bd9d64e1 /include/linux
parenta728ce8ffbd27954fdb2826dcc15a6576e574b83 (diff)
downloadlinux-8c94db0ae97c72c253a615f990bd466b456e94f6.tar.xz
binfmt_elf: preserve original ELF e_flags for core dumps
Some architectures, such as RISC-V, use the ELF e_flags field to encode ABI-specific information (e.g., ISA extensions, fpu support). Debuggers like GDB rely on these flags in core dumps to correctly interpret optional register sets. If the flags are missing or incorrect, GDB may warn and ignore valid data, for example: warning: Unexpected size of section '.reg2/213' in core file. This can prevent access to fpu or other architecture-specific registers even when they were dumped. Save the e_flags field during ELF binary loading (in load_elf_binary()) into the mm_struct, and later retrieve it during core dump generation (in fill_note_info()). Kconfig option CONFIG_ARCH_HAS_ELF_CORE_EFLAGS is introduced for architectures that require this behaviour. Signed-off-by: Svetlana Parfenova <svetlana.parfenova@syntacore.com> Link: https://lore.kernel.org/r/20250901135350.619485-1-svetlana.parfenova@syntacore.com Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/mm_types.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 08bc2442db93..04a2857f12f2 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -1102,6 +1102,11 @@ struct mm_struct {
unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
+#ifdef CONFIG_ARCH_HAS_ELF_CORE_EFLAGS
+ /* the ABI-related flags from the ELF header. Used for core dump */
+ unsigned long saved_e_flags;
+#endif
+
struct percpu_counter rss_stat[NR_MM_COUNTERS];
struct linux_binfmt *binfmt;