From patchwork Fri Nov 19 00:31:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lilydjwg--- via Elfutils-devel X-Patchwork-Id: 47914 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92E593857C43 for ; Fri, 19 Nov 2021 00:31:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92E593857C43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637281908; bh=cFLX7XQd6OYPMExQaauwj108qCdG/M55+g0BJ28LwGQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=TfvCDZ9k1lHHA8rkWDKM4Emf/mw2fZn+1iBwS+mo96chAkSa8d1uRUjkLmv3fnMfd Ek6r15uBH1eYXaN1/GNOn69x+368C5KfHHcqYsuDZMneP/BdZ4kLZxbvhpKT2w276Z FkPw3/v+XxdNfT3j+HcLiejnjYa0nMTDdf2ysGKU= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id D3A063858422 for ; Fri, 19 Nov 2021 00:31:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3A063858422 Received: by mail-ed1-x533.google.com with SMTP id t5so35260803edd.0 for ; Thu, 18 Nov 2021 16:31:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=cFLX7XQd6OYPMExQaauwj108qCdG/M55+g0BJ28LwGQ=; b=fw8/FviCpe6Uced33BQKPYymsivHpfvnU2QQXlM4bSoFrGPvgYEg1Xwp15S7YW6pO7 JrIfVaQeovmsKAxbNAq8MtVtzOfAjrkaNgNpr5Y0/exsFZgGLeCDJJwFfXgV4XPrtvya 46Mcvbft+xisVrgIrmShPZpIQxFVwcK9CDjYv5d+OEcZf8GIAoJZayG8SoLqUOe4hdBx ZYL8cIwEWvEAazV+5j1CguQfySCOLLQE9uha0pivLayRjl+irByz7/pdEOJwdkMc61I5 BEGxDTh1ig7H84/FGSUSoMJFJFnO6kmCWSPWkuliDNkol5PIShKnVRIQJeeOGt9XkmoI a0bA== X-Gm-Message-State: AOAM5301YEEPXNUQegDx9lr0AHdSCQT6WK/l3Z5TGXAFIUx2ZOkrz0VU 1C6f32IajXO0xf/bZCX0YNLgJE7jTCYKQQ== X-Google-Smtp-Source: ABdhPJyCHmgnUkoI/oAHIx2TEU0DCNv8L2FQzJ5v6N8/xq6nHX868GGAnYwZNSGVHj/HU0ZbdYIUBA== X-Received: by 2002:a50:e0c9:: with SMTP id j9mr18049462edl.336.1637281897613; Thu, 18 Nov 2021 16:31:37 -0800 (PST) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id h10sm636533edk.41.2021.11.18.16.31.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 16:31:37 -0800 (PST) To: elfutils-devel@sourceware.org Subject: [PATCH] libebl: recognize FDO Packaging Metadata ELF note Date: Fri, 19 Nov 2021 00:31:27 +0000 Message-Id: <20211119003127.466778-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, 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-Patchwork-Original-From: "luca.boccassi--- via Elfutils-devel" From: lilydjwg--- via Elfutils-devel Reply-To: luca.boccassi@gmail.com Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" From: Luca Boccassi 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"} Signed-off-by: Luca Boccassi --- libebl/eblobjnote.c | 3 +++ libebl/eblobjnotetypename.c | 3 +++ libelf/elf.h | 3 +++ 3 files changed, 9 insertions(+) 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); + /* Everything else should have the "GNU" owner name. */ if (strcmp ("GNU", name) != 0) return; diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c index 4662906d..863f20e4 100644 --- a/libebl/eblobjnotetypename.c +++ b/libebl/eblobjnotetypename.c @@ -101,6 +101,9 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type, return buf; } + if (strcmp (name, "FDO") == 0 && type == FDO_PACKAGING_METADATA) + return "FDO_PACKAGING_METADATA"; + if (strcmp (name, "GNU") != 0) { /* NT_VERSION is special, all data is in the name. */ 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"