public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Luca Boccassi <luca.boccassi@gmail.com>
To: Mark Wielaard <mark@klomp.org>
Cc: elfutils-devel@sourceware.org
Subject: Re: [PATCH] libebl: recognize FDO Packaging Metadata ELF note
Date: Sun, 21 Nov 2021 19:54:43 +0000	[thread overview]
Message-ID: <42a41aba1c60b0b4569405035bb342faabc819dd.camel@gmail.com> (raw)
In-Reply-To: <YZp0yM8tAABK5pvv@wildebeest.org>

[-- Attachment #1: Type: text/plain, Size: 3791 bytes --]

On Sun, 2021-11-21 at 17:33 +0100, Mark Wielaard wrote:
> Hi Luca,
> 
> On Fri, Nov 19, 2021 at 12:31:27AM +0000, luca.boccassi--- via
> Elfutils-devel wrote:
> > From: Luca Boccassi <bluca@debian.org>
> > 
> > As defined on: https://systemd.io/COREDUMP_PACKAGE_METADATA/
> > this note will be used starting from Fedora 36. Allow
> > readelf --notes to pretty print it:
> > 
> > Note section [ 3] '.note.package' of 76 bytes at offset 0x2e8:
> >   Owner          Data size  Type
> >   FDO                   57  FDO_PACKAGING_METADATA
> >     Packaging Metadata: {"type":"deb","name":"fsverity-
> > utils","version":"1.3-1"}
> 
> Very nice. Thanks,
> 
> > diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
> > index 36efe275..1f8bcccf 100644
> > --- a/libebl/eblobjnote.c
> > +++ b/libebl/eblobjnote.c
> > @@ -288,6 +288,9 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const
> > char *name, uint32_t type,
> >        if (descsz == 0 && type == NT_VERSION)
> >         return;
> >  
> > +      if (strcmp ("FDO", name) == 0 && type ==
> > FDO_PACKAGING_METADATA && descsz > 0)
> > +       printf("    Packaging Metadata: %.*s\n", (int) descsz, desc);
> > +
> 
> We might want to check that the desc is '\0' terminated (although I
> see we also don't do that in other cases, like
> NT_GNU_GOLD_VERSION. But it might be good as a robustness check.

No problem, added in v2.

> > diff --git a/libelf/elf.h b/libelf/elf.h
> > index 8e3e618f..633f9f67 100644
> > --- a/libelf/elf.h
> > +++ b/libelf/elf.h
> > @@ -1297,6 +1297,9 @@ typedef struct
> >  /* Program property.  */
> >  #define NT_GNU_PROPERTY_TYPE_0 5
> >  
> > +/* Packaging metadata as defined on
> > https://systemd.io/COREDUMP_PACKAGE_METADATA/ */
> > +#define FDO_PACKAGING_METADATA 0xcafe1a7e
> > +
> >  /* Note section name of program property.   */
> >  #define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
> 
> Would you mind posting the elf.h patch to glibc-alpha@sourceware.org.
> We normally sync elf.h with the glibc one. It will also make sure
> other users of elf.h also get the new constants.

Sure, done:

https://sourceware.org/pipermail/libc-alpha/2021-November/133330.html

> As a followup I wouldn't mind a minimal testcase.
> Especially if it contains a debuginfod url.
> 
> We would have to think how to integrate that with libdw
> dwfl_build_id_find_elf and dwfl_standard_find_debuginfo which use
> debuginfod_find from the debuginfod-client library.
> 
> Since the payload of the FDO_PACKAGING_METADATA note are not simply
> key/values, but encoded in json, so we will need to add or depend on a
> json parser. Any recommendations? It seems a simple enough format to
> just write our own (especially if we can simply skip everything except
> top-level key/value strings to find the debuginfod-url).
> 
> Thanks,
> 
> Mark

Popular C parsers that I know of are json-c and jannson:

https://github.com/json-c/json-c/wiki
https://digip.org/jansson/

json-c seems to be available in slightly more places:

https://repology.org/project/json-c/versions
https://repology.org/project/jansson/versions

Rolling your own full parser can always end up being tricky and a lot
of work, especially for limited usage with no particular requirements.
You need to ensure you've got good fuzzing, etc. If using one of the
above is optional and tied to the debuginfod feature being enabled,
there shouldn't be issues with bootstrapping.
A simple search for the "debugInfoUrl" string, using whatever string is
quoted next as the url would be much simpler of course, if that's all
you need. Up to you of course.

-- 
Kind regards,
Luca Boccassi

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-11-21 19:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19  0:31 luca.boccassi
2021-11-21 16:33 ` Mark Wielaard
2021-11-21 19:54   ` Luca Boccassi [this message]
2021-11-21 19:43 ` [PATCH v2] " luca.boccassi
2021-11-25 17:02   ` Luca Boccassi
2021-11-30 11:25     ` Mark Wielaard
2021-11-30 12:37       ` Luca Boccassi
2021-11-30 16:23       ` Frank Ch. Eigler
2021-11-30 16:49         ` Florian Weimer
2021-11-30 20:04           ` Mark Wielaard
2021-12-02 15:16           ` Frank Ch. Eigler
2021-12-02 15:44             ` Florian Weimer
2021-12-05 17:36       ` Mark Wielaard
2022-03-24 23:14         ` Mark Wielaard
2022-03-24 23:14           ` [PATCH 1/3] libelf: Sync elf.h from glibc Mark Wielaard
2022-03-24 23:14           ` [PATCH 2/3] libebl: recognize FDO Packaging Metadata ELF note Mark Wielaard
2022-03-24 23:14           ` [PATCH 3/3] elflint: Recognize NT_FDO_PACKAGING_METADATA Mark Wielaard
2022-03-25 11:17           ` [PATCH v2] libebl: recognize FDO Packaging Metadata ELF note Luca Boccassi
2022-03-25 13:39             ` Mark Wielaard
2022-03-25 13:52               ` Luca Boccassi
2022-03-25 14:47                 ` Mark Wielaard
2022-03-25 14:55                   ` Luca Boccassi
2022-03-26 16:33                     ` Mark Wielaard
2022-03-26 16:57                       ` Luca Boccassi
2022-03-26 18:19                         ` Luca Boccassi
2022-03-28  9:57                           ` Mark Wielaard
2022-03-28 10:41                             ` Luca Boccassi

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=42a41aba1c60b0b4569405035bb342faabc819dd.camel@gmail.com \
    --to=luca.boccassi@gmail.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=mark@klomp.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).