From patchwork Fri Jul 31 14:14:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 11695057 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F12BB913 for ; Fri, 31 Jul 2020 14:15:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2CF2206DA for ; Fri, 31 Jul 2020 14:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729000AbgGaOPE (ORCPT ); Fri, 31 Jul 2020 10:15:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:14860 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728752AbgGaOPD (ORCPT ); Fri, 31 Jul 2020 10:15:03 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VE21G4068130; Fri, 31 Jul 2020 10:14:58 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32mgkhqpx8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 10:14:58 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06VE2nI8071819; Fri, 31 Jul 2020 10:14:58 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 32mgkhqpwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 10:14:58 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06VE9rng013694; Fri, 31 Jul 2020 14:14:55 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04fra.de.ibm.com with ESMTP id 32gcpwcgmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:14:55 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06VEErhw11534754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 31 Jul 2020 14:14:53 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C94942047; Fri, 31 Jul 2020 14:14:53 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF3D942049; Fri, 31 Jul 2020 14:14:51 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com.com (unknown [9.160.38.42]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 31 Jul 2020 14:14:51 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , Petr Vorel , Vitaly Chikunov , Bruno Meneguele Subject: [ima-evm-utils: PATCH 1/3] Drop the ima_measurement "--verify" option Date: Fri, 31 Jul 2020 10:14:30 -0400 Message-Id: <20200731141432.668318-2-zohar@linux.ibm.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200731141432.668318-1-zohar@linux.ibm.com> References: <20200731141432.668318-1-zohar@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 clxscore=1015 malwarescore=0 suspectscore=1 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007310101 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org While walking the IMA measurement list re-calculating the PCRS, ima_measurement should always re-calculate the template data digest and verify it against the measurement list value. This patch removes the "--verify" option. On success, return 0. Suggested-by: Stephen Smalley Signed-off-by: Mimi Zohar Reviewed-by: Lakshmi Ramasubramanian --- README | 3 +-- src/evmctl.c | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/README b/README index 73b38a1f35ba..d8b8f404534b 100644 --- a/README +++ b/README @@ -31,7 +31,7 @@ COMMANDS ima_sign [--sigfile] [--key key] [--pass password] file ima_verify file ima_hash file - ima_measurement [--validate] [--verify] [--verify-sig [--key "key1, key2, ..."]] [--pcrs [hash-algorithm,]file [--pcrs hash-algorithm,file] ...] file + ima_measurement [--validate] [--verify-sig [--key "key1, key2, ..."]] [--pcrs [hash-algorithm,]file [--pcrs hash-algorithm,file] ...] file ima_fix [-t fdsxm] path sign_hash [--key key] [--pass password] hmac [--imahash | --imasig ] file @@ -61,7 +61,6 @@ OPTIONS --engine e preload OpenSSL engine e (such as: gost) --pcrs file containing TPM pcrs, one per hash-algorithm/bank --validate ignore ToMToU measurement violations - --verify verify the template data digest --verify-sig verify the file signature based on the file hash, both stored in the template data. -v increase verbosity level diff --git a/src/evmctl.c b/src/evmctl.c index 448e4a9c8d78..b4d2333fb880 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -1393,7 +1393,6 @@ struct template_entry { static uint8_t zero[MAX_DIGEST_SIZE]; static int validate = 0; -static int verify = 0; static int ima_verify_template_hash(struct template_entry *entry) { @@ -1945,7 +1944,7 @@ static int ima_measurement(const char *file) struct template_entry entry = { .template = 0 }; FILE *fp; - int verified_template_digest = 0; + int invalid_template_digest = 0; int err_padded = -1; int err = -1; @@ -2075,11 +2074,9 @@ static int ima_measurement(const char *file) pseudo_padded_banks); /* Recalculate and verify template data digest */ - if (verify) { - err = ima_verify_template_hash(&entry); - if (err) - verified_template_digest = 1; - } + err = ima_verify_template_hash(&entry); + if (err) + invalid_template_digest = 1; if (is_ima_template) ima_show(&entry); @@ -2116,7 +2113,7 @@ static int ima_measurement(const char *file) log_info("Failed to match per TPM bank or SHA1 padded TPM digest(s).\n"); } - if (verified_template_digest) { + if (invalid_template_digest) { log_info("Failed to verify template data digest.\n"); err = 1; } @@ -2486,7 +2483,7 @@ struct command cmds[] = { {"ima_verify", cmd_verify_ima, 0, "file", "Verify IMA signature (for debugging).\n"}, {"ima_setxattr", cmd_setxattr_ima, 0, "[--sigfile file]", "Set IMA signature from sigfile\n"}, {"ima_hash", cmd_hash_ima, 0, "file", "Make file content hash.\n"}, - {"ima_measurement", cmd_ima_measurement, 0, "[--validate] [--verify] [--verify-sig [--key key1, key2, ...]] [--pcrs [hash-algorithm,]file [--pcrs hash-algorithm,file] ...] file", "Verify measurement list (experimental).\n"}, + {"ima_measurement", cmd_ima_measurement, 0, "[--validate] [--verify-sig [--key key1, key2, ...]] [--pcrs [hash-algorithm,]file [--pcrs hash-algorithm,file] ...] file", "Verify measurement list (experimental).\n"}, {"ima_boot_aggregate", cmd_ima_bootaggr, 0, "[file]", "Calculate per TPM bank boot_aggregate digests\n"}, {"ima_fix", cmd_ima_fix, 0, "[-t fdsxm] path", "Recursively fix IMA/EVM xattrs in fix mode.\n"}, {"ima_clear", cmd_ima_clear, 0, "[-t fdsxm] path", "Recursively remove IMA/EVM xattrs.\n"}, @@ -2526,8 +2523,7 @@ static struct option opts[] = { {"engine", 1, 0, 139}, {"xattr-user", 0, 0, 140}, {"validate", 0, 0, 141}, - {"verify", 0, 0, 142}, - {"pcrs", 1, 0, 143}, + {"pcrs", 1, 0, 142}, {} }; @@ -2709,10 +2705,7 @@ int main(int argc, char *argv[]) case 141: /* --validate */ validate = 1; break; - case 142: /* --verify */ - verify = 1; - break; - case 143: + case 142: if (npcrfile >= MAX_PCRFILE) { log_err("too many --pcrfile options\n"); exit(1);