From patchwork Mon Apr 19 15:01:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 12212039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36E7FC433ED for ; Mon, 19 Apr 2021 15:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 127F161029 for ; Mon, 19 Apr 2021 15:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240660AbhDSPCa (ORCPT ); Mon, 19 Apr 2021 11:02:30 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56640 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239586AbhDSPC3 (ORCPT ); Mon, 19 Apr 2021 11:02:29 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13JEY350063432 for ; Mon, 19 Apr 2021 11:02:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=VUOGGhhTvxxg5pW0BbgZgrUZRYXuFgYJYDI+OeysVIA=; b=s50mzSQU/v+LiwdCKaOqk6Dq13v2dTWwrKSmxYJO5PYcpg5Q7digA01GWUL9BqrsJkRk U8+OkzRaKhE59kyLDQaXJMMrLIFzbUpzo9v/gOFNpG9RGaAPQCs6XRZMimtMGU4mOX6P ErlpLxQ48VBwe5gr3EfvAL+AgyZsFEY07cRkT1waTMcnlG/DURHGOlsx2ebxoLIpfe4g ypotq/KJB5L/12lGHP0GznCsj9Quu2orDuk3U09DjSJfxhJpzU92mj7hBfypt5bOqFUE OPTIir2617uQyhNDRQyi049wkG8JPYCorpoFxZLasgF57akL92VrIYbaefaiEfbuZJJu wg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 380d6uv8fb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Apr 2021 11:01:59 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13JEZK7P068416 for ; Mon, 19 Apr 2021 11:01:59 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 380d6uv8et-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 11:01:59 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13JErcIW021478; Mon, 19 Apr 2021 15:01:57 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma01dal.us.ibm.com with ESMTP id 37yqa9qe4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 15:01:57 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13JF1uxH17170798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Apr 2021 15:01:56 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14E96136063; Mon, 19 Apr 2021 15:01:56 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE57D13604F; Mon, 19 Apr 2021 15:01:55 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.155]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 19 Apr 2021 15:01:55 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, Stefan Berger Subject: [PATCH 1/6] libimaevm: Properly check for error returned by EVP_DigestUpdate Date: Mon, 19 Apr 2021 11:01:46 -0400 Message-Id: <20210419150151.236409-2-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419150151.236409-1-stefanb@linux.ibm.com> References: <20210419150151.236409-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 54AwuZEWPbZtyxJGUvrFDxab3qevbUTJ X-Proofpoint-ORIG-GUID: 5VWCVD7XwZOZhHEz5435zFNmsck4Wfjs X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-19_10:2021-04-19,2021-04-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104190100 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org The error checking in add_dir_hash was wrong. EVP_DigestUpdate returns 1 on success and 0 on error, so we cannot just accumulate it using or'ing. From the man page: EVP_DigestInit_ex(), EVP_DigestUpdate(), EVP_DigestFinal_ex() Returns 1 for success and 0 for failure. Signed-off-by: Stefan Berger --- src/libimaevm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libimaevm.c b/src/libimaevm.c index fa6c278..d8fc0d4 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -179,7 +179,6 @@ out: static int add_dir_hash(const char *file, EVP_MD_CTX *ctx) { - int err; struct dirent *de; DIR *dir; unsigned long long ino, off; @@ -198,11 +197,10 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx) type = de->d_type; log_debug("entry: %s, ino: %llu, type: %u, off: %llu, reclen: %hu\n", de->d_name, ino, type, off, de->d_reclen); - err = EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name)); - /*err |= EVP_DigestUpdate(ctx, &off, sizeof(off));*/ - err |= EVP_DigestUpdate(ctx, &ino, sizeof(ino)); - err |= EVP_DigestUpdate(ctx, &type, sizeof(type)); - if (!err) { + if (EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name)) != 1 || + /* EVP_DigestUpdate(ctx, &off, sizeof(off)) != 1 || */ + EVP_DigestUpdate(ctx, &ino, sizeof(ino)) != 1|| + EVP_DigestUpdate(ctx, &type, sizeof(type)) != 1) { log_err("EVP_DigestUpdate() failed\n"); output_openssl_errors(); result = 1; From patchwork Mon Apr 19 15:01:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 12212037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC2EBC43460 for ; Mon, 19 Apr 2021 15:02:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CFAC61029 for ; Mon, 19 Apr 2021 15:02:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239911AbhDSPC3 (ORCPT ); Mon, 19 Apr 2021 11:02:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:31978 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239230AbhDSPC3 (ORCPT ); Mon, 19 Apr 2021 11:02:29 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13JEXZmY163643 for ; Mon, 19 Apr 2021 11:01:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=2VLJSDyPAGX/jbPSN1FNZhhmYmigpmOhT9Djs6/uCQc=; b=W+6mPWX0+EUjFB5Cp0tmgDYfmZdYKvauK4m+hNYTp8Ga2Id56gBVaWNn/hNkEwVbp7er ODXNUJBEdm/oA68XNm13AlHfY+J1O0JgzYq288DvuOj5GK1N377FoNsifo53suu+Ibqa rfx/vder6sMPMYaTqwjZTAL64soYp3FtOYPt88MTMy/8oKyTr9G+ALyA5IF1L54+wDEr Y57EjZyZzCUOFJ8ZLZTPNLE/lx0w0/T2VFw3AEfeFEMgwlInl26m61mAH0g0x9vWoaub 3MU6H+gkEBH6YiNnnqBCLZghCKjk7L0pyA9y4lsv6aFgmCOipKF2F5K17nk/KqZ09QBO Tw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 380cmkmhuu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Apr 2021 11:01:59 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13JEXaVX163743 for ; Mon, 19 Apr 2021 11:01:59 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 380cmkmhuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 11:01:59 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13JEqhD8013458; Mon, 19 Apr 2021 15:01:58 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02dal.us.ibm.com with ESMTP id 37yqa9ycwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 15:01:58 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13JF1ubs20447736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Apr 2021 15:01:56 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FD12136063; Mon, 19 Apr 2021 15:01:56 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C0D713605D; Mon, 19 Apr 2021 15:01:56 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.155]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 19 Apr 2021 15:01:56 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, Stefan Berger Subject: [PATCH 2/6] libimaevm: Remove unused off variable Date: Mon, 19 Apr 2021 11:01:47 -0400 Message-Id: <20210419150151.236409-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419150151.236409-1-stefanb@linux.ibm.com> References: <20210419150151.236409-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VN5AXCrJj51LDKSzjwx5Ck-41EicSp2s X-Proofpoint-ORIG-GUID: v_BVtKr1JaO3_F7oNFUrfbmpAFj9ZeV1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-19_10:2021-04-19,2021-04-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104190100 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org The 'off' variable was unused in add_dir_hash(), so remove it. Signed-off-by: Stefan Berger --- src/libimaevm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libimaevm.c b/src/libimaevm.c index d8fc0d4..0137884 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -181,7 +181,7 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx) { struct dirent *de; DIR *dir; - unsigned long long ino, off; + unsigned long long ino; unsigned int type; int result = 0; @@ -193,12 +193,10 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx) while ((de = readdir(dir))) { ino = de->d_ino; - off = de->d_off; type = de->d_type; - log_debug("entry: %s, ino: %llu, type: %u, off: %llu, reclen: %hu\n", - de->d_name, ino, type, off, de->d_reclen); + log_debug("entry: %s, ino: %llu, type: %u, reclen: %hu\n", + de->d_name, ino, type, de->d_reclen); if (EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name)) != 1 || - /* EVP_DigestUpdate(ctx, &off, sizeof(off)) != 1 || */ EVP_DigestUpdate(ctx, &ino, sizeof(ino)) != 1|| EVP_DigestUpdate(ctx, &type, sizeof(type)) != 1) { log_err("EVP_DigestUpdate() failed\n"); From patchwork Mon Apr 19 15:01:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 12212041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED663C43461 for ; Mon, 19 Apr 2021 15:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D012C6101C for ; Mon, 19 Apr 2021 15:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239586AbhDSPCa (ORCPT ); Mon, 19 Apr 2021 11:02:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:20630 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239230AbhDSPCa (ORCPT ); Mon, 19 Apr 2021 11:02:30 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13JEXaLH031502 for ; Mon, 19 Apr 2021 11:02:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=56W0iEdGubB1+U29sYehFG0HtKMZrA9aSiTRV+T4vVg=; b=bYTgXYf52FkLSQT3fdvik1n86bbAJkMewyvW67M/M5nn+S4gSNuYFt9s+J/wFZveOADY TQ2eBamMSPU8KJK2fCemD4ImQxYHeEi5Ro5MimchU3vJzxp6X4Dn79qyF0/x/f9ttl8E /Hf8PQfBCeIZmXv3mxuoy+gVoezykybpg2BOJoxPnK3g5OYtvJw80t7EIHLEO4gwpFw3 ZG8ozVkSHTTavzkeMmwpKAmsyIBcWY7oS4yZfu5RqJfpXozMFQlM3NX4FsXU7Oycu1u/ UErGUlNJjg7nAnEdgk12+g5iL8r/E9IMLZInkbWEllH9e73PxuEUCh4YFSk/61sgSMiI nw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 380cwxv9yu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Apr 2021 11:01:59 -0400 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13JEXeLC032097 for ; Mon, 19 Apr 2021 11:01:59 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 380cwxv9xr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 11:01:59 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13JEqgJd014062; Mon, 19 Apr 2021 15:01:58 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma05wdc.us.ibm.com with ESMTP id 37yqa8tr55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 15:01:58 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13JF1vWL21758428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Apr 2021 15:01:57 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B214136051; Mon, 19 Apr 2021 15:01:57 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB457136055; Mon, 19 Apr 2021 15:01:56 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.155]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 19 Apr 2021 15:01:56 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, Stefan Berger Subject: [PATCH 3/6] libimaevm: Rename variable returned from readlink to len Date: Mon, 19 Apr 2021 11:01:48 -0400 Message-Id: <20210419150151.236409-4-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419150151.236409-1-stefanb@linux.ibm.com> References: <20210419150151.236409-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: e_TsLhLG3rHxPmLX-fRjd1oZJUwXq5f6 X-Proofpoint-GUID: e_yB8I6lqTBOenZnZOAbYLRyn-oDys2D X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-19_10:2021-04-19,2021-04-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104190100 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org The variable returned from readlink is a length indicator of the number of bytes placed into a buffer, not only an error. Leave a note in the code that a zero-length link is also treated as an error, besdies the usual -1. Signed-off-by: Stefan Berger --- src/libimaevm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libimaevm.c b/src/libimaevm.c index 0137884..9a6739b 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -213,15 +213,16 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx) static int add_link_hash(const char *path, EVP_MD_CTX *ctx) { - int err; + int len; char buf[1024]; - err = readlink(path, buf, sizeof(buf)); - if (err <= 0) + len = readlink(path, buf, sizeof(buf)); + /* 0-length links are also an error */ + if (len <= 0) return -1; - log_info("link: %s -> %.*s\n", path, err, buf); - return !EVP_DigestUpdate(ctx, buf, err); + log_info("link: %s -> %.*s\n", path, len, buf); + return !EVP_DigestUpdate(ctx, buf, len); } static int add_dev_hash(struct stat *st, EVP_MD_CTX *ctx) From patchwork Mon Apr 19 15:01:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 12212045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01BD9C433B4 for ; Mon, 19 Apr 2021 15:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBDEA613B8 for ; Mon, 19 Apr 2021 15:02:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238859AbhDSPCi (ORCPT ); Mon, 19 Apr 2021 11:02:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:10361 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239385AbhDSPCg (ORCPT ); Mon, 19 Apr 2021 11:02:36 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13JEXc3d031709 for ; Mon, 19 Apr 2021 11:02:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=PocZSNSrd5aC5XSaQGO6Ljd88Qn0lMq94yGVHaL4PjA=; b=oPHaYGvu5+7cg1hmvX0+S4gK02T4kcA5IwaWvI7uDY1av2dacp9xeHGPGvBeEfwgfBlt q30Ls7FZUUW8V8bgVAT0650YZ26Ux29GROlS9h4f6U3z72PnZ9fhOqjnjcxFoxdhU8Sl snBLpdP5cgIa/8+XkfYuQjuvJ04K616eKbRjcMn9FWqLRZ13sm8AFx496A5IEh56Y+QC iujpslsBv3MTbeAIJ1ufeI4TPhS7sDsI3KtPyAvxSCLZBS/4LkgtDKPH9TQCrJlypAGG HZ8eVU4JUSAw0soZY5i0tJDekB4vgMmD4o3WXpQ2HZD1wOfsSyoIkuWb3pvpEKPw4RfA wA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 380cwxva0p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Apr 2021 11:02:01 -0400 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13JEY5WL034801 for ; Mon, 19 Apr 2021 11:02:00 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 380cwxv9yv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 11:02:00 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13JErNJC028269; Mon, 19 Apr 2021 15:01:59 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03dal.us.ibm.com with ESMTP id 37yqa9yc4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 15:01:59 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13JF1v2Q26083820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Apr 2021 15:01:57 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB366136051; Mon, 19 Apr 2021 15:01:57 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47032136053; Mon, 19 Apr 2021 15:01:57 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.155]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 19 Apr 2021 15:01:57 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, Stefan Berger Subject: [PATCH 4/6] libimaevm: Rename variable from cr to newline Date: Mon, 19 Apr 2021 11:01:49 -0400 Message-Id: <20210419150151.236409-5-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419150151.236409-1-stefanb@linux.ibm.com> References: <20210419150151.236409-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: F9R1zyoYe9fLCGL5eI_09xOjtErrSVUo X-Proofpoint-GUID: O_Xd-7HvcdHRPyTR_y_tjbK84w5lYKIK X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-19_10:2021-04-19,2021-04-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104190100 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Rename function variable from cr (carriage return, '\r') to newline, because this is what it is. Signed-off-by: Stefan Berger --- src/libimaevm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libimaevm.c b/src/libimaevm.c index 9a6739b..b40b6d8 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -90,14 +90,14 @@ struct libimaevm_params imaevm_params = { static void __attribute__ ((constructor)) libinit(void); -void imaevm_do_hexdump(FILE *fp, const void *ptr, int len, bool cr) +void imaevm_do_hexdump(FILE *fp, const void *ptr, int len, bool newline) { int i; uint8_t *data = (uint8_t *) ptr; for (i = 0; i < len; i++) fprintf(fp, "%02x", data[i]); - if (cr) + if (newline) fprintf(fp, "\n"); } From patchwork Mon Apr 19 15:01:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 12212043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 066A1C43462 for ; Mon, 19 Apr 2021 15:02:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC44F61370 for ; Mon, 19 Apr 2021 15:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239230AbhDSPCc (ORCPT ); Mon, 19 Apr 2021 11:02:32 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:12372 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239385AbhDSPCb (ORCPT ); Mon, 19 Apr 2021 11:02:31 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13JEbX9u095722 for ; Mon, 19 Apr 2021 11:02:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=4tLRYv8G0ECMUArMDgFj4UGE0/zVEBdwm9ey4Qpd/yU=; b=goc1c3XNmWqM30hP4toSaP8wIWup2zpJR/nY9iRf7lR7pgIaPnpF9Sc5v4CY8p1vZEUK gxMgxTjcyEo+rIpr1IMKZZeE0EgUp6r2Kny/3+/3YITUETubRk2n3BoXem0eRCmEtPEL 1ee77hTfNl/3emjP8cl74I5uUkR+geeJwVPnL4o+p/Vnh3Lgm4oC3I32HJmI6NuRDxwR /ueMRq1HaLVVvdcFH3RuLpAHLKPpG8RIGAQcPE2p89Zq/KzR1WEkajrHrZk9Bu2vTdnE QRHmcP9aR4yHgbb1ZWKbZ4dUATIBXJOdlawUWg4xmcN/dsgmIyO2WF0yanJxj/mUry2H iQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 381bevhcc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Apr 2021 11:02:01 -0400 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13JEfitM122536 for ; Mon, 19 Apr 2021 11:02:01 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 381bevhcbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 11:02:01 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13JErVRp022784; Mon, 19 Apr 2021 15:02:00 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01wdc.us.ibm.com with ESMTP id 37yqa8js8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 15:02:00 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13JF1w0F63374012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Apr 2021 15:01:58 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36A18136051; Mon, 19 Apr 2021 15:01:58 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6B71136055; Mon, 19 Apr 2021 15:01:57 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.155]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 19 Apr 2021 15:01:57 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, Stefan Berger Subject: [PATCH 5/6] libimaevm: Report unsupported filetype using log_err Date: Mon, 19 Apr 2021 11:01:50 -0400 Message-Id: <20210419150151.236409-6-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419150151.236409-1-stefanb@linux.ibm.com> References: <20210419150151.236409-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bacz---jjVLPV-oLppagE9rYwcp7GGu2 X-Proofpoint-GUID: qDp4kywR2pOjcoeyRTAslIHDQ1ZHcU0V X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-19_10:2021-04-19,2021-04-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 adultscore=0 suspectscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104190100 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org There's no errno set at this point so that using log_errno would display something useful. Instead use log_error(). Signed-off-by: Stefan Berger --- src/libimaevm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libimaevm.c b/src/libimaevm.c index b40b6d8..06f1063 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -286,7 +286,7 @@ int ima_calc_hash(const char *file, uint8_t *hash) err = add_dev_hash(&st, pctx); break; default: - log_errno("Unsupported file type"); + log_err("Unsupported file type (0x%x)", st.st_mode & S_IFMT); err = -1; goto err; } From patchwork Mon Apr 19 15:01:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 12212047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7E58C433B4 for ; Mon, 19 Apr 2021 15:02:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A27546127C for ; Mon, 19 Apr 2021 15:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239385AbhDSPCw (ORCPT ); Mon, 19 Apr 2021 11:02:52 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:4319 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239093AbhDSPCw (ORCPT ); Mon, 19 Apr 2021 11:02:52 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13JEX87v108261 for ; Mon, 19 Apr 2021 11:02:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=WWyEfL1pkUewMfAZssJxuGavAYFKzB5IbQ1lXIRSmsY=; b=PlvTjvRX3uuSFIbM7347uOBmk+DEQhSN6xlidLsYOTU5iFSVbVMp54ScH21MkwcSDhFg ByUBa2xHMy8Be+LStyOcjBDBL6wghD91JMn1WeoXvI3iDb44Lm7dF1Kq3NdUbJmR1EVu CrT0vMJYb9MvqaG6Jb0H/yL8U8PqFFUqFGz6mR0jy13rih/KJM7lpVkx+/2O8KmzyZrQ HOUnjCb3GLJVar3I9wdR5b39Q1fcrPFjzkFfEThpVUHH4FN5Uf/lEhoG6PG/5+TXQGv2 Maq0462mgI4qzE8XQZVbVPItr6ngI1k0ZC0BLZh7ohoDD2N1S/UrpPt++AUkcGpxoXV8 DQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 380d7dm133-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Apr 2021 11:02:01 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13JEX9xr108463 for ; Mon, 19 Apr 2021 11:02:01 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 380d7dm129-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 11:02:01 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13JEqfqf013437; Mon, 19 Apr 2021 15:02:00 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma02dal.us.ibm.com with ESMTP id 37yqa9ycx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Apr 2021 15:02:00 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13JF1wLS63636036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Apr 2021 15:01:58 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5D21136061; Mon, 19 Apr 2021 15:01:58 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 520C2136053; Mon, 19 Apr 2021 15:01:58 +0000 (GMT) Received: from localhost.localdomain (unknown [9.47.158.155]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 19 Apr 2021 15:01:58 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, Stefan Berger Subject: [PATCH 6/6] libimaevm: Use function parameter algo for name of hash Date: Mon, 19 Apr 2021 11:01:51 -0400 Message-Id: <20210419150151.236409-7-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419150151.236409-1-stefanb@linux.ibm.com> References: <20210419150151.236409-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 8J9oE0bAmjK4upi0uV9m8XrTs-J6x8bK X-Proofpoint-GUID: 2VHFTbQQupV0oXpclr9ZF0tSGZOai2ep X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-19_10:2021-04-19,2021-04-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104190100 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Instead of using the global variable imaevm_params.hash_algo as the hash algo to use, use the algo parameter passed into the function. Existing code in this function already uses 'algo' for writing the has into the header: hdr->hash_algo = imaevm_get_hash_algo(algo); Signed-off-by: Stefan Berger --- src/libimaevm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libimaevm.c b/src/libimaevm.c index 06f1063..2856270 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -913,7 +913,7 @@ static int sign_hash_v2(const char *algo, const unsigned char *hash, return -1; } - log_info("hash(%s): ", imaevm_params.hash_algo); + log_info("hash(%s): ", algo); log_dump(hash, size); pkey = read_priv_pkey(keyfile, imaevm_params.keypass); @@ -939,7 +939,7 @@ static int sign_hash_v2(const char *algo, const unsigned char *hash, if (!EVP_PKEY_sign_init(ctx)) goto err; st = "EVP_get_digestbyname"; - if (!(md = EVP_get_digestbyname(imaevm_params.hash_algo))) + if (!(md = EVP_get_digestbyname(algo))) goto err; st = "EVP_PKEY_CTX_set_signature_md"; if (!EVP_PKEY_CTX_set_signature_md(ctx, md))