Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4126957pxb; Fri, 11 Feb 2022 16:32:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxxyWG9pNNjg9qLiiqEsrCRnW7iDX5NJuPpPxrMztUtRDOt5GHZqf6QRyN4VuLwFR4XNur X-Received: by 2002:a17:902:c951:: with SMTP id i17mr3859667pla.26.1644625962866; Fri, 11 Feb 2022 16:32:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644625962; cv=none; d=google.com; s=arc-20160816; b=q8ff5yAEqDX6fmgGYHnVjza3BKoSyHo1B/UjHuzdbpbHfa4wTPN5qqO9lYQ93vdId5 ufNGtElNQVUc8oQq55UyUGTJY2uQKZb9UH+54P/9ECTKj4m2N6Jm7o3M2uxSR+v4vOOf mJeDWiGf4Jnrbks2uQLCogX6UTqeWidixJNaBrjflhJ/y2I9kDRCtgWuHuwPT32y1ZS+ qTR6F5K1XIIvYwX+pPkSc1FiSNDtIvPXj3VAtpfZ8U5BG8D4ht67idzGxSqLgSHH/guS sXXbjItFhjSZRPNMRTaSjWyJ8LUG9TDZ0KjzWRPqz3nq4oISp2Vq+fDOyukGLdbX4TNJ ZIyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WzdZMG/whTUs+Pg2BPbKBbWbH/Bgl2PhL0oTxCv4vhY=; b=zg+HL8jNOR5ifs5OIZWZYxEEoNl2LjB8TqqulJSiIjd+M96BTXj1Rv3pL+9tX7/IcJ 7NBncL0yDaj95cpuKAv2xlb0j96fFSZPnkVQycQP3xga/TG6FaCKsRi8PLbmlRl0rdwj qQ+UMal8uyX2N3mq876SBCIgVenL1DFXQBIfEDmwch6paw1Fhoisv9iXg7phTG9NB7wH oXptS4ivVb4ALxwsrz2jd4QAWH+j8fFV8LJB3BLeBXjmh91R3AllfZ03ynle2FcBMUOP SflJ+vVCezNAExikR+5EdnxLDCuQwdW4z/9XNGlzKVdSShgLxdfv1pKyD8vdamUwE/oQ QcXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=j1S8hKtc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu13si299835pjb.172.2022.02.11.16.32.27; Fri, 11 Feb 2022 16:32:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=j1S8hKtc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353840AbiBKVnq (ORCPT + 99 others); Fri, 11 Feb 2022 16:43:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353817AbiBKVnl (ORCPT ); Fri, 11 Feb 2022 16:43:41 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD595C6A; Fri, 11 Feb 2022 13:43:38 -0800 (PST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21BKvctB008037; Fri, 11 Feb 2022 21:43:36 GMT 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=WzdZMG/whTUs+Pg2BPbKBbWbH/Bgl2PhL0oTxCv4vhY=; b=j1S8hKtcFnMPvphtQYooMWyEhV0UD79TG3zihlQ657DGS5ucKhnXV0JJ/044038mRQ6q u+KKZi/c83zM+/eV6bG88EhAFc9by22lWtysVbis+BAfY1athBi1xhqcHAzvwz2Jjig4 9JN96C8n1HuhQhC0eMbwbozThC65arKHRPCf8sOOVltNZsp0R0ta/meAieDOG9inlKrp kltVgH6PUuzzA7INSn9Vs4K4/F15SCd+a+mgVdmN11P0/iFqbC/jqNe6JZ3o88oyvjdp 5iv+eCcbVScv3LGPPcH0+v1AGuK696pU4rdwHj0fh2O+NGftT55qhnk+z9+58aZcsKio Fw== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e5y9yrpmt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Feb 2022 21:43:36 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21BLYAiX005339; Fri, 11 Feb 2022 21:43:34 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06ams.nl.ibm.com with ESMTP id 3e1ggkw71v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Feb 2022 21:43:34 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21BLhQVj41419008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Feb 2022 21:43:26 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 595A052063; Fri, 11 Feb 2022 21:43:26 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com.com (unknown [9.65.69.128]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3C00D52051; Fri, 11 Feb 2022 21:43:25 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , Eric Biggers , Stefan Berger , linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/8] ima: define a new template field 'd-type' and a new template 'ima-ngv2' Date: Fri, 11 Feb 2022 16:43:06 -0500 Message-Id: <20220211214310.119257-5-zohar@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220211214310.119257-1-zohar@linux.ibm.com> References: <20220211214310.119257-1-zohar@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: bv5CSTVcyW8Ge5R9LKFPi7WcfO_CN7GU X-Proofpoint-ORIG-GUID: bv5CSTVcyW8Ge5R9LKFPi7WcfO_CN7GU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-11_05,2022-02-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 phishscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202110108 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to differentiate between regular IMA file hashes and fs-verity's file digests, define a new template field named 'd-type'. Define a new template named 'ima-ngv2', which includes the new 'd-type' field. Signed-off-by: Mimi Zohar --- security/integrity/ima/ima_template.c | 3 +++ security/integrity/ima/ima_template_lib.c | 13 +++++++++++++ security/integrity/ima/ima_template_lib.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c index db1ad6d7a57f..b321342e5bee 100644 --- a/security/integrity/ima/ima_template.c +++ b/security/integrity/ima/ima_template.c @@ -19,6 +19,7 @@ enum header_fields { HDR_PCR, HDR_DIGEST, HDR_TEMPLATE_NAME, static struct ima_template_desc builtin_templates[] = { {.name = IMA_TEMPLATE_IMA_NAME, .fmt = IMA_TEMPLATE_IMA_FMT}, {.name = "ima-ng", .fmt = "d-ng|n-ng"}, + {.name = "ima-ngv2", .fmt = "d-ng|n-ng|d-type"}, {.name = "ima-sig", .fmt = "d-ng|n-ng|sig"}, {.name = "ima-buf", .fmt = "d-ng|n-ng|buf"}, {.name = "ima-modsig", .fmt = "d-ng|n-ng|sig|d-modsig|modsig"}, @@ -40,6 +41,8 @@ static const struct ima_template_field supported_fields[] = { .field_show = ima_show_template_digest_ng}, {.field_id = "n-ng", .field_init = ima_eventname_ng_init, .field_show = ima_show_template_string}, + {.field_id = "d-type", .field_init = ima_eventdigest_type_init, + .field_show = ima_show_template_string}, {.field_id = "sig", .field_init = ima_eventsig_init, .field_show = ima_show_template_sig}, {.field_id = "buf", .field_init = ima_eventbuf_init, diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c index 7155d17a3b75..a213579e825e 100644 --- a/security/integrity/ima/ima_template_lib.c +++ b/security/integrity/ima/ima_template_lib.c @@ -383,6 +383,19 @@ int ima_eventdigest_ng_init(struct ima_event_data *event_data, hash_algo, field_data); } +/* + * This function writes the digest type of an event. + */ +int ima_eventdigest_type_init(struct ima_event_data *event_data, + struct ima_field_data *field_data) +{ + static const char * const digest_type[] = {"ima"}; + + return ima_write_template_field_data(digest_type[0], + strlen(digest_type[0]), + DATA_FMT_STRING, field_data); +} + /* * This function writes the digest of the file which is expected to match the * digest contained in the file's appended signature. diff --git a/security/integrity/ima/ima_template_lib.h b/security/integrity/ima/ima_template_lib.h index c71f1de95753..539a5e354925 100644 --- a/security/integrity/ima/ima_template_lib.h +++ b/security/integrity/ima/ima_template_lib.h @@ -38,6 +38,8 @@ int ima_eventname_init(struct ima_event_data *event_data, struct ima_field_data *field_data); int ima_eventdigest_ng_init(struct ima_event_data *event_data, struct ima_field_data *field_data); +int ima_eventdigest_type_init(struct ima_event_data *event_data, + struct ima_field_data *field_data); int ima_eventdigest_modsig_init(struct ima_event_data *event_data, struct ima_field_data *field_data); int ima_eventname_ng_init(struct ima_event_data *event_data, -- 2.27.0