[LTP] [PATCH v10 3/3] coredump02: Verify ELF structure and notes
Andrea Cervesato
andrea.cervesato@suse.com
Thu Sep 10 13:14:36 CEST 2026
Hi Cyril,
> 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.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
More information about the ltp
mailing list