From patchwork Tue Apr 11 12:15:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yauheni Kaliuta X-Patchwork-Id: 9675045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5AF7D60381 for ; Tue, 11 Apr 2017 12:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5182928571 for ; Tue, 11 Apr 2017 12:12:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4504528582; Tue, 11 Apr 2017 12:12:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E13D328571 for ; Tue, 11 Apr 2017 12:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752467AbdDKMMq (ORCPT ); Tue, 11 Apr 2017 08:12:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42398 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752516AbdDKMMo (ORCPT ); Tue, 11 Apr 2017 08:12:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5CED2C001091; Tue, 11 Apr 2017 12:12:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5CED2C001091 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=yauheni.kaliuta@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5CED2C001091 Received: from astarta.redhat.com (ovpn-117-212.ams2.redhat.com [10.36.117.212]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FE8617164; Tue, 11 Apr 2017 12:12:43 +0000 (UTC) From: Yauheni Kaliuta To: linux-modules Cc: Lucas De Marchi , Mark van Dijk Subject: [PATCH 4/4] libkmod: modinfo: implement signature output Date: Tue, 11 Apr 2017 15:15:03 +0300 Message-Id: <20170411121503.26181-5-yauheni.kaliuta@redhat.com> In-Reply-To: <20170411121503.26181-1-yauheni.kaliuta@redhat.com> References: <20170411121503.26181-1-yauheni.kaliuta@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 11 Apr 2017 12:12:44 +0000 (UTC) Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Signature was ignored from the modinfo. Implement its parsing from the module data and add its output to the modinfo utility. Signed-off-by: Yauheni Kaliuta --- libkmod/libkmod-internal.h | 2 ++ libkmod/libkmod-module.c | 9 +++++++++ libkmod/libkmod-signature.c | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h index 4d9db6bc7845..346579c71aab 100644 --- a/libkmod/libkmod-internal.h +++ b/libkmod/libkmod-internal.h @@ -186,5 +186,7 @@ struct kmod_signature_info { const char *key_id; size_t key_id_len; const char *algo, *hash_algo, *id_type; + const char *sig; + size_t sig_len; }; bool kmod_module_signature_info(const struct kmod_file *file, struct kmod_signature_info *sig_info) _must_check_ __attribute__((nonnull(1, 2))); diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 9e155f080277..0a3ef11c860f 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -2344,6 +2344,15 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_ * Omit sig_info.algo for now, as these * are currently constant. */ + n = kmod_module_info_append_hex(list, "signature", + strlen("signature"), + sig_info.sig, + sig_info.sig_len); + + if (n == NULL) + goto list_error; + count++; + } ret = count; diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c index ef5fe6e7bb7f..1f3e26dea203 100644 --- a/libkmod/libkmod-signature.c +++ b/libkmod/libkmod-signature.c @@ -134,7 +134,11 @@ bool kmod_module_signature_info(const struct kmod_file *file, struct kmod_signat size < (int64_t)(modsig->signer_len + modsig->key_id_len + sig_len)) return false; - size -= modsig->key_id_len + sig_len; + size -= sig_len; + sig_info->sig = mem + size; + sig_info->sig_len = sig_len; + + size -= modsig->key_id_len; sig_info->key_id = mem + size; sig_info->key_id_len = modsig->key_id_len;