[LTP] [PATCH v10 3/3] coredump02: Verify ELF structure and notes
Cyril Hrubis
chrubis@suse.cz
Thu Sep 10 14:47:08 CEST 2026
Hi!
> > > +static void handle_note(uint32_t type, const void *desc, size_t descsz, pid_t pid)
> > > +{
> > > + if (type == NT_PRPSINFO && descsz >= sizeof(struct elf_prpsinfo)) {
> > > + struct elf_prpsinfo info;
> > > +
> > > + memcpy(&info, desc, sizeof(info));
> > > + TST_EXP_EQ_STR(info.pr_fname, "coredump02");
> >
> > I still do not see a reason why this can't be:
> >
> > struct elf_prpsinfo *info = desc;
> >
> > TST_EXP_EQ_STR(info->pr_name, "coredump02");
>
> because ELF notes in Linux are only 4-byte padded, desc pointers are not
> guaranteed to be 8-byte aligned. Casting desc to struct elf_prpsinfo *
> or struct elf_prstatus * creates a misaligned pointer, which is undefined
> behavior in C.
AFAIK the 4 byte padding may happen on x86_64 only for a historical
reasons and x86_64 is at the same time capable of handling unaligned
access. AArch64 should have 8 byte padding.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list