Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp802655ybi; Wed, 19 Jun 2019 08:08:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlYIRKTlJoBCMHm88ZsdFCh07K+/F8F6gbp3dp06Sx3WWdlgtg8h+22P/ADSl8S5tJ1jiJ X-Received: by 2002:a17:902:2f84:: with SMTP id t4mr76581436plb.57.1560956892282; Wed, 19 Jun 2019 08:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560956892; cv=none; d=google.com; s=arc-20160816; b=rSzU0uClL04CwDyaVz304+hLpepDhmrsVlGvG8SJXQvhLFmV7ceLWLjYsXyvFMSLvc Nqghi/B535XpGG+Yp4EOnLDxpcDzFUNoH4w5LPXClMJCckh9S1iG+/u+1SmwlgFzteXz 9hxohm5cIvP/Vt2X2zo9TsHEzEPTA5yzayFq7QuQCC/wqt9zm969Z5QJlJi2YC3AZ+zb m4+c7+f2sKH4G6urDOCqvZ/ACC7CtAf6n3PCbLkVoJKdvM4ncdsuwVR1aVL4iVuqw+1H +YMVINUQzkIx2RgTRF/KsTYNRtLUz5cf74NPyIGC9Hvp3LJbCYBL3c0KTfE+mA+FrTLe d3QA== 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:references:in-reply-to:cc:to:from:subject; bh=u6aBlJoiCV3PNZvoiNInqDh1noV5cwjPXsm23uBXPnE=; b=SGcemZnk1hG5jmPC7DLHxG4mH0CO5xoQ8TkZJTXf5maUOcvfHjotpSbDhaD1XYM97x Dyh5kEYixc8oyxvcKGaKYT5wyvuuxwnu9rLN/pGDEiqJWoM2LF2KFJrRr28rreNMMAqP OwgobuM0Tg4p359v8Y1WEUNO+SXZ6ff3x8OfHYgAoJTWIy1oM5eTjnnDmppl6cfIQx0e J6eLinx/LG80+/o9D8mXpIQCcpNFFPxYYiCUxkA8yKB7aC1+xyPX7Uml/deRof2MZV/2 KJsY/E7Sqo20HTrzb4RpTAvauueDzR1N+RuIhcmyOYa/rHwmAu+ltaN5UUtcQ/ydODtc GWdQ== 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 y187si3325475pgd.113.2019.06.19.08.07.56; Wed, 19 Jun 2019 08:08:12 -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 S1730280AbfFSPHV (ORCPT + 99 others); Wed, 19 Jun 2019 11:07:21 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18182 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729642AbfFSPHU (ORCPT ); Wed, 19 Jun 2019 11:07:20 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5JF3EEF099408 for ; Wed, 19 Jun 2019 11:07:19 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2t7q1k9cya-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 19 Jun 2019 11:07:19 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Jun 2019 16:07:17 +0100 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 19 Jun 2019 16:07:15 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5JF7E0l34537948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2019 15:07:14 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 846BE52052; Wed, 19 Jun 2019 15:07:14 +0000 (GMT) Received: from dhcp-9-31-103-88.watson.ibm.com (unknown [9.31.103.88]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id E0C7E52050; Wed, 19 Jun 2019 15:07:13 +0000 (GMT) Subject: Re: [PATCH 2/3] IMA:Define a new template field buf From: Mimi Zohar To: Prakhar Srivastava , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Cc: roberto.sassu@huawei.com In-Reply-To: <20190617183507.14160-3-prsriva02@gmail.com> References: <20190617183507.14160-1-prsriva02@gmail.com> <20190617183507.14160-3-prsriva02@gmail.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 19 Jun 2019 09:54:26 -0400 Mime-Version: 1.0 X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19061915-0028-0000-0000-0000037BB7E0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19061915-0029-0000-0000-0000243BC627 Message-Id: <1560952466.3975.40.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-19_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1906190122 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-06-17 at 11:35 -0700, Prakhar Srivastava wrote: > A buffer(kexec boot command line arguments) measured into IMA > measuremnt list cannot be appraised, without already being > aware of the buffer contents. Since hashes are non-reversible, > raw buffer is needed for validation or regenerating hash for > appraisal/attestation. > > Add support to store/read the buffer contents in HEX. > The kexec cmdline hash is stored in the "d-ng" field of the > template data,it can be verified using > sudo cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements | > grep kexec-cmdline | cut -d' ' -f 6 | xxd -r -p | sha256sum > > - Add two new fields to ima_event_data to hold the buf and > buf_len [Suggested by Roberto] > - Add a new temaplte field 'buf' to be used to store/read > the buffer data.[Suggested by Mimi] > - Updated process_buffer_meaurement to add the buffer to > ima_event_data. process_buffer_measurement added in > "Define a new IMA hook to measure the boot command line > arguments" > - Add a new template policy name ima-buf to represent > 'd-ng|n-ng|buf' > > Signed-off-by: Prakhar Srivastava > Reviewed-by: Roberto Sassu > Reviewed-by: James Morris Thanks, looking much better. > > /* IMA template field data definition */ > diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c > index ea7d8cbf712f..83ca99d65e4b 100644 > --- a/security/integrity/ima/ima_api.c > +++ b/security/integrity/ima/ima_api.c > @@ -140,7 +140,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename, > struct ima_template_entry *entry; > struct inode *inode = file_inode(file); > struct ima_event_data event_data = {iint, file, filename, NULL, 0, > - cause}; > + cause, NULL, 0}; > int violation = 1; > int result; > > @@ -296,7 +296,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint, > struct inode *inode = file_inode(file); > struct ima_template_entry *entry; > struct ima_event_data event_data = {iint, file, filename, xattr_value, > - xattr_len, NULL}; > + xattr_len, NULL, NULL, 0}; > int violation = 0; > > if (iint->measured_pcrs & (0x1 << pcr)) > diff --git a/security/integrity/ima/ima_init.c b/security/integrity/ima/ima_init.c > index 993d0f1915ff..c8591406c0e2 100644 > --- a/security/integrity/ima/ima_init.c > +++ b/security/integrity/ima/ima_init.c > @@ -50,7 +50,7 @@ static int __init ima_add_boot_aggregate(void) > struct ima_template_entry *entry; > struct integrity_iint_cache tmp_iint, *iint = &tmp_iint; > struct ima_event_data event_data = {iint, NULL, boot_aggregate_name, > - NULL, 0, NULL}; > + NULL, 0, NULL, NULL, 0}; > int result = -ENOMEM; > int violation = 0; > struct { > These changes shouldn't be necessary.  Please rebase these patches on top of the latest next-queued-testing branch (git remote update).  "IMA: support for per policy rule template formats" is still changing.  Minor nit.  When re-posting the patches please update the patch titles so that there is a space between the subsystem name and the patch title (eg. "ima: define ..."). Mimi