Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6360777yba; Tue, 14 May 2019 06:24:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsoFwq+5Tm58xXRaKfq8EQ9SABQHRRwM4if56aw5AMlfq97At1OWQDqnYfP145XzhOEoQT X-Received: by 2002:a17:902:9a03:: with SMTP id v3mr39013208plp.27.1557840251149; Tue, 14 May 2019 06:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557840251; cv=none; d=google.com; s=arc-20160816; b=VSYhExvPAxZOFXQ7s0avcP914R4CUL1MzZSzuwn7E/eig6ifLxoA1HgNjiiKPQWQjL qAjKlMr4W01BE6bRouvsRoiszEqXUF4XnqnyYsRO2HX44oPfGfT6KBqH4z74o8XSxBJ1 e5R7ca3PkVsx2n1je741PjVs5Hq+3OxkYegaZSn+weCa3T32662dUMcb5JGxNUjX9aGD /0SkKRjP/s8lnZmUhP3NgHhoRd/th5/6DXctSFaXdD8qwB6iJ/iTZMD2sw3aV5GzGEUm PDWQjPB3gbekfuOcAZadAfIRPDYfuFQczMjKquUAFXftdczFVcQMFZeC2mUH/gV2FuFU aRkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=wWY6fQayNEQg2nYwxwDEIWjrNAp3u8GiX+5KyWfhkAg=; b=gjZEUkORSk1il7wBwFwSUJfclSxLkG7HGQ/Sx/zMzWJkfn8B8K5o9X2uZK6S51lTIn Quqo5I68VpTx8iXRb3LBi8nMO9xMPaTsTccRguKi0gMibxyqQnLuRkJTu7no+yiBd9nc FAiqoq6t4GVBmXHai2ha0oU15307/UH4JPBb9qPNMp6hjjXlDfKko63h1cyc+45kUYbq vzSzyfVajjvvx+oI5llUp/sBCN9+Fw+P8ASk+uLWRPYcNwMzOqBlwFLKchXUpTD3pJ2C apHo3bpAURLjRVHU+qMptpPWv215R+DR6NwEtZJGB2lT6sYDFUaZF1PCOroeJ3Ic3mIn ZcJg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h5si21737608pgg.526.2019.05.14.06.23.55; Tue, 14 May 2019 06:24:11 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726098AbfENNWq (ORCPT + 99 others); Tue, 14 May 2019 09:22:46 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:32938 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725854AbfENNWq (ORCPT ); Tue, 14 May 2019 09:22:46 -0400 Received: from LHREML711-CAH.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id DDD84239182CBA24B421; Tue, 14 May 2019 14:22:44 +0100 (IST) Received: from [10.220.96.108] (10.220.96.108) by smtpsuk.huawei.com (10.201.108.34) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 14 May 2019 14:22:39 +0100 Subject: Re: [PATCH 2/3 v5] add a new template field buf to contain the buffer To: prakhar srivastava CC: , , , Mimi Zohar , , , Prakhar Srivastava References: <20190510223744.10154-1-prsriva02@gmail.com> <20190510223744.10154-3-prsriva02@gmail.com> <45344b2f-d9ea-f7df-e45f-18037e2ba5ca@huawei.com> From: Roberto Sassu Message-ID: Date: Tue, 14 May 2019 15:22:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.220.96.108] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/14/2019 7:07 AM, prakhar srivastava wrote: > On Mon, May 13, 2019 at 6:48 AM Roberto Sassu wrote: >> >> On 5/11/2019 12:37 AM, Prakhar Srivastava wrote: >>> From: Prakhar Srivastava >>> >>> The buffer(cmdline args) added to the ima log cannot be attested >>> without having the actual buffer. Thus to make the measured buffer >>> available to store/read a new ima template (buf) is added. >> >> Hi Prakhar >> >> please fix the typos. More comments below. >> >> >>> + buffer_event_data->type = IMA_XATTR_BUFFER; >>> + buffer_event_data->buf_length = size; >>> + memcpy(buffer_event_data->buf, buf, size); >>> + >>> + event_data.xattr_value = (struct evm_ima_xattr_data *)buffer_event_data; >>> + event_data.xattr_len = alloc_length; >> >> I would prefer that you introduce two new fields in the ima_event_data >> structure. You can initialize them directly with the parameters of >> process_buffer_measurement(). > I will make the edits, this will definitely save the kzalloc in this code > path. >> >> ima_write_template_field_data() will make >> a copy. >> > Since event_data->type is used to distinguish what the template field > should contain. > Removing the type and subsequent check in the template_init, > buf template fmt will result in the whole event_Data structure > being added to the log, which is not the expected output. > For buffer entries, the buf templet fmt will contains the buffer itself. The purpose of ima_event_data is to pass data to the init method of template fields. Each method takes the data it needs. If you pass event_data->buf and event_data->buf_len to ima_write_template_field_data() this should be fine. Roberto >>> + .field_show = ima_show_template_buf}, >> >> Please update Documentation/security/IMA-templates.rst > Will update the documentation. > > Thanks, > Prakhar Srivastava >> >> Thanks >> >> Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHI