Skip to content

Commit a55128d

Browse files
Dave Martinkees
authored andcommitted
binfmt_elf: Warn on missing or suspicious regset note names
Now that all regset definitions declare an explicit note name, warn if the note name is missing when generating a core dump. Simplify the fallback to always guess "LINUX", which is appropriate for all Linux-specific notes (i.e., all newly added notes, for a long time now). The one standard exception (PR_FPREG) will no longer have an "unexpected" note name overridden, but a warning will still be emitted. Also warn if the specified note name doesn't match the legacy pattern -- but don't bother to override the name in this case. This warning can be removed in future if new note types emerge that require a specific note name that is not "LINUX". No functional change, beyond the extra noise in dmesg and not overriding an unexpected note name for PR_FPREG any more. Now that all upstream arches are ported to use USER_REGSET_NOTE_TYPE(), new regsets created by copy-pasting existing code should end up correct by construction. Signed-off-by: Dave Martin <Dave.Martin@arm.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Kees Cook <kees@kernel.org> Cc: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Link: https://lore.kernel.org/r/20250701135616.29630-24-Dave.Martin@arm.com Signed-off-by: Kees Cook <kees@kernel.org>
1 parent cb32fb7 commit a55128d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

fs/binfmt_elf.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,8 +1750,13 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
17501750
if (is_fpreg)
17511751
SET_PR_FPVALID(&t->prstatus);
17521752

1753-
if (!note_name)
1754-
note_name = is_fpreg ? NN_PRFPREG : "LINUX";
1753+
/* There should be a note name, but if not, guess: */
1754+
if (WARN_ON_ONCE(!note_name))
1755+
note_name = "LINUX";
1756+
else
1757+
/* Warn on non-legacy-compatible names, for now. */
1758+
WARN_ON_ONCE(strcmp(note_name,
1759+
is_fpreg ? "CORE" : "LINUX"));
17551760

17561761
__fill_note(&t->notes[note_iter], note_name, note_type,
17571762
ret, data);

0 commit comments

Comments
 (0)