From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 982D43858D3C for ; Sun, 21 Nov 2021 19:54:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 982D43858D3C Received: by mail-wr1-x42c.google.com with SMTP id s13so28710325wrb.3 for ; Sun, 21 Nov 2021 11:54:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version; bh=8b7xCZij3Ckjzdf/miNf+nQWma4VTcjPAS2KEcLJmng=; b=mc8Ok+paSDU+hxNfNCP9gRHp5KIwOXG3g4rq+CiZI/lGGo0Bpx6DTg68sEpeapFd1z kaqL9l0j3zmujiK2SELBJsH4IcjLCbuEHdwtLdvr/TW455Bm0DfiUEOOCWSyX+9/ZYLr gVooQUNds/bCa1sKqpiKJlgVx3xfB6GAnCVH6ZIOCgWbS9OyjCekagiS3iegoykvUExW cfZcAFww0JTDATm7YWscsitqLWBY6iTbd2XsUQWDyFIZlcGnm+svYLz1zM5fjj7QcBMd KzKhO+uFj+S1Ytr1Jn8uQVXWMppeG3AtrRPxPU9rGpEW0h0ywbG8jIellqsABWJ+29JM b0pw== X-Gm-Message-State: AOAM533jrz7dMNP1gNN544KuCffWoEg9mpwxrANFyJRAax0jemdba8Y/ TJBwqJrdbHYsLXajQV2qKSYJqxVYyj4= X-Google-Smtp-Source: ABdhPJwmPMqY9M+OZmtDhYqt7X9fx53Lx6Qn4Q00IUfIs9RbO9VzETcKskC9o4jl9l2ZdzZtrTGGeg== X-Received: by 2002:adf:dec9:: with SMTP id i9mr31048870wrn.18.1637524485551; Sun, 21 Nov 2021 11:54:45 -0800 (PST) Received: from ?IPv6:2a01:4b00:f41a:3600:df86:cebc:8870:2184? ([2a01:4b00:f41a:3600:df86:cebc:8870:2184]) by smtp.googlemail.com with ESMTPSA id be3sm19185345wmb.1.2021.11.21.11.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 11:54:44 -0800 (PST) Message-ID: <42a41aba1c60b0b4569405035bb342faabc819dd.camel@gmail.com> Subject: Re: [PATCH] libebl: recognize FDO Packaging Metadata ELF note From: Luca Boccassi To: Mark Wielaard Cc: elfutils-devel@sourceware.org Date: Sun, 21 Nov 2021 19:54:43 +0000 In-Reply-To: References: <20211119003127.466778-1-luca.boccassi@gmail.com> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-YuSVPJz/87tShLlLQIEp" User-Agent: Evolution 3.42.1-1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Nov 2021 19:54:48 -0000 --=-YuSVPJz/87tShLlLQIEp Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2021-11-21 at 17:33 +0100, Mark Wielaard wrote: > Hi Luca, >=20 > On Fri, Nov 19, 2021 at 12:31:27AM +0000, luca.boccassi--- via > Elfutils-devel wrote: > > From: Luca Boccassi > >=20 > > 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: > >=20 > > Note section [ 3] '.note.package' of 76 bytes at offset 0x2e8: > > =C2=A0 Owner=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Data= size=C2=A0 Type > > =C2=A0 FDO=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 57=C2=A0 FDO_PACKAGING_MET= ADATA > > =C2=A0=C2=A0=C2=A0 Packaging Metadata: {"type":"deb","name":"fsverity- > > utils","version":"1.3-1"} >=20 > Very nice. Thanks, >=20 > > 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, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (descsz =3D=3D 0 && type =3D=3D= NT_VERSION) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return; > > =C2=A0 > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (strcmp ("FDO", name) =3D=3D 0 && ty= pe =3D=3D > > FDO_PACKAGING_METADATA && descsz > 0) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0printf("=C2=A0=C2=A0=C2=A0 P= ackaging Metadata: %.*s\n", (int) descsz, desc); > > + >=20 > 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 > > =C2=A0/* Program property.=C2=A0 */ > > =C2=A0#define NT_GNU_PROPERTY_TYPE_0 5 > > =C2=A0 > > +/* Packaging metadata as defined on > > https://systemd.io/COREDUMP_PACKAGE_METADATA/=C2=A0*/ > > +#define FDO_PACKAGING_METADATA 0xcafe1a7e > > + > > =C2=A0/* Note section name of program property.=C2=A0=C2=A0 */ > > =C2=A0#define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property" >=20 > 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. >=20 > 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. >=20 > 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). >=20 > Thanks, >=20 > 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. --=20 Kind regards, Luca Boccassi --=-YuSVPJz/87tShLlLQIEp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEE6g0RLAGYhL9yp9G8SylmgFB4UWIFAmGapAMACgkQSylmgFB4 UWKgAAf+PItdYQKlKqA5GZjg7OMqv9VoWkDx5H+v8PWu/BUSNfv5Oz9JBwrkqYRx 9cLdM380k1eD0D1qKl9tKieGHSgex2IFy85Eykqy1b31oruDOmKJAY2d4ZQzON31 iAab+ficdoG7v/gwPd2nab5ppK6XKJH61wc6YYO8n7iXZRgR0FPCFUGBOpfvp6gR X+SkSB/8uUVtw3crhAih8u3l1fc2/TDRwS5g4pPqUwqB0X4M1INZl4hsYuAbIIrk 9nQ3QfC3bBfWY84ptu+fBQw2QZVqsyzUgakMOTBsb16rYAbyBvt73bkv/80SNK89 +wEzRglgGYcPTasunr3MOnaeB3rHZg== =UoPS -----END PGP SIGNATURE----- --=-YuSVPJz/87tShLlLQIEp--