]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crash: Use note name macros
authorAkihiko Odaki <akihiko.odaki@daynix.com>
Wed, 15 Jan 2025 05:48:01 +0000 (14:48 +0900)
committerKees Cook <kees@kernel.org>
Tue, 11 Feb 2025 00:56:58 +0000 (16:56 -0800)
Use note name macros to match with the userspace's expectation.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Link: https://lore.kernel.org/r/20250115-elf-v5-4-0f9e55bbb2fc@daynix.com
Signed-off-by: Kees Cook <kees@kernel.org>
fs/proc/kcore.c
include/linux/vmcore_info.h
kernel/crash_core.c

index 1cb33771bf9fcbbea273522fee5fe6361a794993..728630b10fdffd28d95318b74352e0319fb71724 100644 (file)
@@ -34,8 +34,6 @@
 #include <asm/sections.h>
 #include "internal.h"
 
-#define CORE_STR "CORE"
-
 #ifndef ELF_CORE_EFLAGS
 #define ELF_CORE_EFLAGS        0
 #endif
@@ -122,7 +120,9 @@ static void update_kcore_size(void)
 
        kcore_phdrs_len = kcore_nphdr * sizeof(struct elf_phdr);
        kcore_notes_len = (4 * sizeof(struct elf_note) +
-                          3 * ALIGN(sizeof(CORE_STR), 4) +
+                          ALIGN(sizeof(NN_PRSTATUS), 4) +
+                          ALIGN(sizeof(NN_PRPSINFO), 4) +
+                          ALIGN(sizeof(NN_TASKSTRUCT), 4) +
                           VMCOREINFO_NOTE_NAME_BYTES +
                           ALIGN(sizeof(struct elf_prstatus), 4) +
                           ALIGN(sizeof(struct elf_prpsinfo), 4) +
@@ -443,11 +443,11 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter)
                        goto out;
                }
 
-               append_kcore_note(notes, &i, CORE_STR, NT_PRSTATUS, &prstatus,
+               append_kcore_note(notes, &i, NN_PRSTATUS, NT_PRSTATUS, &prstatus,
                                  sizeof(prstatus));
-               append_kcore_note(notes, &i, CORE_STR, NT_PRPSINFO, &prpsinfo,
+               append_kcore_note(notes, &i, NN_PRPSINFO, NT_PRPSINFO, &prpsinfo,
                                  sizeof(prpsinfo));
-               append_kcore_note(notes, &i, CORE_STR, NT_TASKSTRUCT, current,
+               append_kcore_note(notes, &i, NN_TASKSTRUCT, NT_TASKSTRUCT, current,
                                  arch_task_struct_size);
                /*
                 * vmcoreinfo_size is mostly constant after init time, but it
index e1dec1a6a749dcdfb7079735cbec64364cc9aee9..1672801fd98c0d50b3abfd5acfaaf763ff80531d 100644 (file)
@@ -8,7 +8,7 @@
 
 #define CRASH_CORE_NOTE_NAME      "CORE"
 #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
-#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4)
+#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(NN_PRSTATUS), 4)
 #define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
 
 /*
index 078fe5bc5a747da858cf0e83a78a1ab60b640852..335b8425dd4b9e19c999aa08b61d27621b4132fa 100644 (file)
@@ -436,7 +436,7 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
        memset(&prstatus, 0, sizeof(prstatus));
        prstatus.common.pr_pid = current->pid;
        elf_core_copy_regs(&prstatus.pr_reg, regs);
-       buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS,
+       buf = append_elf_note(buf, NN_PRSTATUS, NT_PRSTATUS,
                              &prstatus, sizeof(prstatus));
        final_note(buf);
 }