From: Li Wang <li.wang@linux.dev>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v5] coredump01: New core_pattern specifiers test
Date: Fri, 4 Sep 2026 14:52:36 +0800 [thread overview]
Message-ID: <appqtLIfarlxCyER@linux.dev> (raw)
In-Reply-To: <6a9a6469.3d30ac2e.110181.4b84@mx.google.com>
> > Generally this checks is really nice, but it'd be better to
> > add more checks for the core dump file?
> >
> > e.g. file size > 0, ELF magic valid, and type == ET_CORE.
>
> this is already done, but we can introduce ELF type check (read below).
+1
> > +static int verify_core_dump(const char *path, long long expected_size)
> > +{
> > + int fd;
> > + struct stat st;
> > + unsigned char magic[SELFMAG];
> > + Elf64_Ehdr ehdr;
>
> Ehdr is not portable on 32 bit systems breaking our testing, so I
> wouldn't use it in this case. We need Elf32_Half which is in both
> 32bit and 64bit.
+1
> > +
> > + fd = SAFE_OPEN(path, O_RDONLY, 0);
> > + SAFE_READ(0, fd, magic, SELFMAG);
> > + SAFE_CLOSE(fd);
> > +
> > + TST_EXP_EXPR(!memcmp(magic, ELFMAG, 4),
> > + "core file has valid ELF magic");
> > +
> > + fd = SAFE_OPEN(path, O_RDONLY, 0);
> > + SAFE_READ(0, fd, &ehdr, sizeof(ehdr));
> > + SAFE_READ(0, fd, &ehdr, sizeof(ehdr));
>
> double read? I guess it's an error
Oh sorry, that's a duplicate from the vim y&p.
> I will send a new version with some of the proposed checks
Thanks!
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2026-09-04 6:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 7:21 [LTP] [PATCH v5] coredump01: New core_pattern specifiers test Andrea Cervesato
2026-09-03 12:01 ` [LTP] " linuxtestproject.agent
2026-09-04 3:43 ` [LTP] [PATCH v5] " Li Wang
2026-09-04 6:25 ` Andrea Cervesato via ltp
2026-09-04 6:52 ` Li Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=appqtLIfarlxCyER@linux.dev \
--to=li.wang@linux.dev \
--cc=andrea.cervesato@suse.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox