Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2638152ybd; Thu, 27 Jun 2019 16:27:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+z9Yhv0YUhJdhvgAdY9MIbjxvGaPxK8EIsBHgDg6eT8FhsOnXaLMnqSi4Bg2pOjKNaJXY X-Received: by 2002:a65:51c6:: with SMTP id i6mr6181615pgq.275.1561678030801; Thu, 27 Jun 2019 16:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561678030; cv=none; d=google.com; s=arc-20160816; b=NXz7mrOcyQ+n2me7jY+J08pz/8wx5+GrCh+CIHxHDEuqbOYOA8IbiBAQjhL4ZLKvv5 eWCufLJgAmcfi3oYgTBJ7A0ngXEd6vd+ZjELsZechcTpbaH2y3HNAp2XxxhI+aA7Q9de tZK3PeUkvncf7YK0TQJyK2rLDicQYN4iRofC4+vw+z9ekAbhQma7PtSANUuI1iFG/2D9 lwXCSWw24hOpcdDzcmnvcfQQIyNiMaHPa8PC/srAgwektqmzJqwCGPEl/Ri+TQ9JzNJ6 jhkZ5kp5IwdLeU7q3hdVB48A6EbZufnNqx/9U2L3oTUVf32z35vmOumGqm5C0xeKw3Lp EQuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:date:subject:cc:to:from; bh=9nRQwCvOBasO9Y1b8eEGBl0RzcSIcX87PXV0PomNrj4=; b=PaWY3Rf0V0P2k9AR3qLqvFUDQS91RPyS3l0yljti5VMQWBVSFjE+3uGz3H2arFEXfL jY2dVASGahOcrMI7hy+IULZAMJJHiMOdgthF0AQORt8PfBTkOHF3A8rnZkUZ/uabHjjD fnIj+/0/2XlirAJCrVTrXQvgk7gkg4oDgRqfyiVNhvKM5rCd8tcWmJi4AHajAoHrw0aX o8z2UdWrR8171aKjznjoD4YCSC9T4ILtxrdRV+clm+JR9113ei49aMlH3SeJpSIfSGEz M+kVR2o5zNLX3MkVNWvb97Z8BVBK1gPU6J/gUXLMMUGCT4HBUUf918Zf6WzYXqVPwGqQ uYbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 95si346307ple.51.2019.06.27.16.26.55; Thu, 27 Jun 2019 16:27:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbfF0X0p (ORCPT + 99 others); Thu, 27 Jun 2019 19:26:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57784 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726574AbfF0X0o (ORCPT ); Thu, 27 Jun 2019 19:26:44 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5RNQcIV111569 for ; Thu, 27 Jun 2019 19:26:43 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2td695teb7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 27 Jun 2019 19:26:43 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Jun 2019 00:26:42 +0100 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 28 Jun 2019 00:26:39 +0100 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5RNQbRX59703622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jun 2019 23:26:38 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E22737805E; Thu, 27 Jun 2019 23:26:37 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89E317805C; Thu, 27 Jun 2019 23:26:36 +0000 (GMT) Received: from morokweng.localdomain.com (unknown [9.85.218.134]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 27 Jun 2019 23:26:36 +0000 (GMT) From: Thiago Jung Bauermann To: linux-integrity@vger.kernel.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Mimi Zohar , Thiago Jung Bauermann Subject: [PATCH] ima: Update MAX_TEMPLATE_NAME_LEN to fit largest reasonable definition Date: Thu, 27 Jun 2019 20:25:46 -0300 X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19062723-0012-0000-0000-00001749BB66 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011343; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01224213; UDB=6.00644313; IPR=6.01005401; MB=3.00027497; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-27 23:26:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19062723-0013-0000-0000-000057DBE90C Message-Id: <20190627232546.28746-1-bauerman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-27_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906270272 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org MAX_TEMPLATE_NAME_LEN is used when restoring measurements carried over from a kexec. It should be set to the length of a template containing all fields except for 'd' and 'n', which don't need to be accounted for since they shouldn't be defined in the same template description as 'd-ng' and 'n-ng'. That length is greater than the current 15, so update using a sizeof() to show where the number comes from and also can be visually shown to be correct. The sizeof() is calculated at compile time. Signed-off-by: Thiago Jung Bauermann --- security/integrity/ima/ima_template.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c index a01a17e5c581..7343e8e0ae2f 100644 --- a/security/integrity/ima/ima_template.c +++ b/security/integrity/ima/ima_template.c @@ -47,7 +47,13 @@ static const struct ima_template_field supported_fields[] = { {.field_id = "buf", .field_init = ima_eventbuf_init, .field_show = ima_show_template_buf}, }; -#define MAX_TEMPLATE_NAME_LEN 15 + +/* + * Used when restoring measurements carried over from a kexec. 'd' and 'n' don't + * need to be accounted for since they shouldn't be defined in the same template + * description as 'd-ng' and 'n-ng' respectively. + */ +#define MAX_TEMPLATE_NAME_LEN sizeof("d-ng|n-ng|sig|buf") static struct ima_template_desc *ima_template;