From patchwork Tue Dec 8 13:36:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 11958615 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,SPF_PASS,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 62D20C433FE for ; Tue, 8 Dec 2020 13:38:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BEA022242 for ; Tue, 8 Dec 2020 13:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbgLHNh7 (ORCPT ); Tue, 8 Dec 2020 08:37:59 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50496 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729020AbgLHNh6 (ORCPT ); Tue, 8 Dec 2020 08:37:58 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B8DWOUc096510; Tue, 8 Dec 2020 08:37:03 -0500 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; s=pp1; bh=y7Rn1mFTwjD/+UcqdZUlXv9sotblfSHf8xeTD1DjzjI=; b=Hb6cZuIsy6T7KmfIkrkXlaJQuBg89qEdHg7vNKiZqWyVlxvxmOqEG1qtljjfuRDtYTZz 7qxNRtKn2MWyyQTJ2euTX21BHHyvLGxjwhTyjEJpcuS7WSYXbrpdbk8J2pL8ClhbKPC0 MoXHEoXGiGAnct4QYI735WuN4ywrYQdIZBJyKXa2zWgNhPX/Toe/Do16VfY6iUZXe8gM W8F5CmEvcNicdj6LiSIVN1i+g43pd4JpGNIIGq8ocxyfaohcmv4L0tq9vUtPNLGM8uR8 KWTqbthetWtpTvQQFBRDzET0akxOBYky8VczvxALsg0WjWFIQngxdCqU1fmv3cR73Y6L UA== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 359qrpqhnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Dec 2020 08:37:03 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B8Db1Yx006716; Tue, 8 Dec 2020 13:37:01 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3583svkghm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Dec 2020 13:37:01 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B8DaxFJ63635728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Dec 2020 13:36:59 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC92C42045; Tue, 8 Dec 2020 13:36:58 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70D0442049; Tue, 8 Dec 2020 13:36:57 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com.com (unknown [9.65.221.14]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 8 Dec 2020 13:36:57 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , Vitaly Chikunov , Roberto Sassu Subject: [ima-evm-utils][PATCH 1/2] Add support for verifying portable EVM signatures Date: Tue, 8 Dec 2020 08:36:38 -0500 Message-Id: <20201208133639.538269-2-zohar@linux.ibm.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201208133639.538269-1-zohar@linux.ibm.com> References: <20201208133639.538269-1-zohar@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-08_09:2020-12-08,2020-12-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 suspectscore=1 clxscore=1015 priorityscore=1501 phishscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080080 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Commit 4928548d9d87 ("Add support for portable EVM format") added support for generating portable and immutable signatures. Support verifying them, using either the security.ima or the user.ima. Signed-off-by: Mimi Zohar --- src/evmctl.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/evmctl.c b/src/evmctl.c index 1815f55d73e0..4fd0ed86e281 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -404,6 +404,8 @@ static int calc_evm_hash(const char *file, unsigned char *hash) } for (xattrname = evm_config_xattrnames; *xattrname != NULL; xattrname++) { + int use_xattr_ima = 0; + if (!strcmp(*xattrname, XATTR_NAME_SELINUX) && selinux_str) { err = strlen(selinux_str) + 1; if (err > sizeof(xattr_value)) { @@ -420,6 +422,15 @@ static int calc_evm_hash(const char *file, unsigned char *hash) return -1; } hex2bin(xattr_value, ima_str, err); + } else if (!strcmp(*xattrname, XATTR_NAME_IMA) && evm_portable){ + err = lgetxattr(file, xattr_ima, xattr_value, + sizeof(xattr_value)); + if (err < 0) { + log_err("EVM portable sig: %s required\n", + xattr_ima); + return -1; + } + use_xattr_ima = 1; } else if (!strcmp(*xattrname, XATTR_NAME_CAPS) && (hmac_flags & HMAC_FLAG_CAPS_SET)) { if (!caps_str) continue; @@ -442,7 +453,8 @@ static int calc_evm_hash(const char *file, unsigned char *hash) } } /*log_debug("name: %s, value: %s, size: %d\n", *xattrname, xattr_value, err);*/ - log_info("name: %s, size: %d\n", *xattrname, err); + log_info("name: %s, size: %d\n", + use_xattr_ima ? xattr_ima : *xattrname, err); log_debug_dump(xattr_value, err); err = EVP_DigestUpdate(pctx, xattr_value, err); if (!err) { @@ -807,11 +819,20 @@ static int verify_evm(const char *file) return len; } - if (sig[0] != 0x03) { + if ((sig[0] != EVM_IMA_XATTR_DIGSIG) && + (sig[0] != EVM_XATTR_PORTABLE_DIGSIG)) { log_err("%s has no signature\n", xattr_evm); return -1; } + if (sig[0] == EVM_XATTR_PORTABLE_DIGSIG) { + if (sig[1] != DIGSIG_VERSION_2) { + log_err("Portable sig: invalid type\n"); + return -1; + } + evm_portable = true; + } + sig_hash_algo = imaevm_hash_algo_from_sig(sig + 1); if (sig_hash_algo < 0) { log_err("unknown hash algo: %s\n", file); From patchwork Tue Dec 8 13:36:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 11958617 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 F1A90C4361B for ; Tue, 8 Dec 2020 13:39:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB7D323AA9 for ; Tue, 8 Dec 2020 13:39:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbgLHNjd (ORCPT ); Tue, 8 Dec 2020 08:39:33 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:26604 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727322AbgLHNjd (ORCPT ); Tue, 8 Dec 2020 08:39:33 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B8DYPkv060586; Tue, 8 Dec 2020 08:38:20 -0500 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; s=pp1; bh=iW4WVj6XX1HS1UJ4/hk7vW6MfFQHuVHyoJwKWcsg/sg=; b=QurStv8qyA3Cn1HobAq0UCxrd7n4/C+oxy/F06bZ2GeXK52DzKW4X454YkjSbjZ7USrE /BmCmPSW6awo8FrBNPeuBEeOQIG/GzAfBjsokxDFrez6VgtMwBTQhgLgBSYb2Dnq3xpX KW18WD1lXf+eJBvX6rLoVyMUKKVwRMsaMgg+/2WAEL/pwuTTKi+tWm7za5ZSfZedO+05 /SXcrF977YEOQj0g6nZX/ZNV1BVgx9CvTYklvhA04dBJ/Mrh55BowQDPHicCAGKb1BUr 3ZJuGwpFlsDu99lViEgixvQx4Ny8qTOcaRmmSuhW95VOz/cs89k655tpodI1gqq4NqO+ Vg== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 35a61x871c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Dec 2020 08:38:19 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B8Dbt9E003471; Tue, 8 Dec 2020 13:38:17 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 3581u8naqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Dec 2020 13:38:17 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B8Db0Sv9110226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Dec 2020 13:37:00 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A5EF4203F; Tue, 8 Dec 2020 13:37:00 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65B5F42045; Tue, 8 Dec 2020 13:36:59 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com.com (unknown [9.65.221.14]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 8 Dec 2020 13:36:59 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , Vitaly Chikunov , Roberto Sassu Subject: [ima-evm-utils][PATCH 2/2] tests: add test to verify EVM portable and immutable signatures Date: Tue, 8 Dec 2020 08:36:39 -0500 Message-Id: <20201208133639.538269-3-zohar@linux.ibm.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201208133639.538269-1-zohar@linux.ibm.com> References: <20201208133639.538269-1-zohar@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-08_09:2020-12-08,2020-12-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxlogscore=946 impostorscore=0 spamscore=0 suspectscore=1 phishscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080084 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Now that evmctl supports verifying EVM portable and immutable signatures, add the test. Signed-off-by: Mimi Zohar --- tests/sign_verify.test | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/sign_verify.test b/tests/sign_verify.test index 288e1330184e..d1ae17b58aa1 100755 --- a/tests/sign_verify.test +++ b/tests/sign_verify.test @@ -328,9 +328,14 @@ try_different_sigs() { expect_fail check_verify TYPE=ima fi - # Test --portable - expect_pass check_sign OPTS="$OPTS --portable" PREFIX=0x05 - # Cannot be verified for now, until that support is added to evmctl + # Test --portable (only supported for V2 signatures) + if expect_pass check_sign OPTS="$OPTS --portable --imahash" PREFIX=0x05; then + if [[ "$OPTS" =~ --rsa ]]; then + expect_fail check_verify + else + expect_pass check_verify + fi + fi # Test -i (immutable) expect_pass check_sign OPTS="$OPTS -i" PREFIX=0x0303