Skip to content

Commit 0de47f2

Browse files
akihikodakikees
authored andcommitted
crash: Use note name macros
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki <[email protected]> Acked-by: Baoquan He <[email protected]> Reviewed-by: Dave Martin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 609c8b3 commit 0de47f2

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

fs/proc/kcore.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#include <asm/sections.h>
3535
#include "internal.h"
3636

37-
#define CORE_STR "CORE"
38-
3937
#ifndef ELF_CORE_EFLAGS
4038
#define ELF_CORE_EFLAGS 0
4139
#endif
@@ -122,7 +120,9 @@ static void update_kcore_size(void)
122120

123121
kcore_phdrs_len = kcore_nphdr * sizeof(struct elf_phdr);
124122
kcore_notes_len = (4 * sizeof(struct elf_note) +
125-
3 * ALIGN(sizeof(CORE_STR), 4) +
123+
ALIGN(sizeof(NN_PRSTATUS), 4) +
124+
ALIGN(sizeof(NN_PRPSINFO), 4) +
125+
ALIGN(sizeof(NN_TASKSTRUCT), 4) +
126126
VMCOREINFO_NOTE_NAME_BYTES +
127127
ALIGN(sizeof(struct elf_prstatus), 4) +
128128
ALIGN(sizeof(struct elf_prpsinfo), 4) +
@@ -443,11 +443,11 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter)
443443
goto out;
444444
}
445445

446-
append_kcore_note(notes, &i, CORE_STR, NT_PRSTATUS, &prstatus,
446+
append_kcore_note(notes, &i, NN_PRSTATUS, NT_PRSTATUS, &prstatus,
447447
sizeof(prstatus));
448-
append_kcore_note(notes, &i, CORE_STR, NT_PRPSINFO, &prpsinfo,
448+
append_kcore_note(notes, &i, NN_PRPSINFO, NT_PRPSINFO, &prpsinfo,
449449
sizeof(prpsinfo));
450-
append_kcore_note(notes, &i, CORE_STR, NT_TASKSTRUCT, current,
450+
append_kcore_note(notes, &i, NN_TASKSTRUCT, NT_TASKSTRUCT, current,
451451
arch_task_struct_size);
452452
/*
453453
* vmcoreinfo_size is mostly constant after init time, but it

include/linux/vmcore_info.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#define CRASH_CORE_NOTE_NAME "CORE"
1010
#define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
11-
#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4)
11+
#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(NN_PRSTATUS), 4)
1212
#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
1313

1414
/*

kernel/crash_core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
436436
memset(&prstatus, 0, sizeof(prstatus));
437437
prstatus.common.pr_pid = current->pid;
438438
elf_core_copy_regs(&prstatus.pr_reg, regs);
439-
buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS,
439+
buf = append_elf_note(buf, NN_PRSTATUS, NT_PRSTATUS,
440440
&prstatus, sizeof(prstatus));
441441
final_note(buf);
442442
}

0 commit comments

Comments
 (0)