Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2401349yba; Fri, 17 May 2019 16:40:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8kTlVUStYNibq8Ljnzf1p7Fe3iNZuaDisKz5xMvTCz1Fg8wznnB264PoJfkjLo/Bz7OZs X-Received: by 2002:a62:e205:: with SMTP id a5mr26311185pfi.40.1558136426582; Fri, 17 May 2019 16:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558136426; cv=none; d=google.com; s=arc-20160816; b=LjaxaXDLo/lSIAzex1+lHDZW6yUggsU6mAVnuUNRZjoREvHLYsMfOfaQivM4THv38q Ve7+xnyOWVqRtbOjP7VoXgQ4UnDLzHpDlb02izDtNQGrRfOn9FK2uAO2HAoB5/zYPN74 oGmzeVWgdSlH8lV7eKFoLRs/zrVPSfoQR4Kd7NmXi+OKR5dY2hNYkWh9Vfpd3tmOZHu3 eMU/zSfjC8q3b8XUrdtL2Ls6V0v+GWKSefoEeJm4rJq/RkOlzBznpxLyuJ/qbowlnmsi p89Wev7l3BoqJqCckKMj+5Yi2Cj8PX/w1FCBGHHWe/gg5gijwNwk6vAuWtzjc7yiI6q2 vUwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=awtvMvpzZhsaTZUbEfHRJE4Vbfvc7fc0pIJD8NnJozs=; b=sxZLVpu9f7F8V6Yz5alI7xXoPe5vXVMiMOgkE68M5PAzd6YeTFo1cHOLlVZJW7v+CI VC4eY6PJRokRhFOMsBZEQlnjJAVtt5+VLmVchuPLJauANjLoOWHCnYwNA5vWfmQS2v1c Kl5oM4rR4YDRYLeTfZ2wFTTL7Iomx5PD6nwnjk3yK7118PeQxoeGK40TAWvQyqL+Oqu2 ifdXrLfUOzlfBweiaoZENxYiSGSLtOsPkD/bgUzHvSVpV6M0d4MzwpVLqqtWQt7FuLAD iAhPRW1lxJCocBstXJWglzaIc0ofe1wDpIcNBFHN3Z8E9Qzlb9przM74Nz9yHHqffHhE XFpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HN4Hs2kL; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si9145597pll.2.2019.05.17.16.40.09; Fri, 17 May 2019 16:40:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HN4Hs2kL; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbfEQXcs (ORCPT + 99 others); Fri, 17 May 2019 19:32:48 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41558 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726519AbfEQXcr (ORCPT ); Fri, 17 May 2019 19:32:47 -0400 Received: by mail-pl1-f194.google.com with SMTP id f12so4010762plt.8; Fri, 17 May 2019 16:32:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=awtvMvpzZhsaTZUbEfHRJE4Vbfvc7fc0pIJD8NnJozs=; b=HN4Hs2kLz7PmjXNIeyWPid/KV5LSQeemV3ykbNHLA+pyXaVFJvmO1q8/Jry7ro8Bbz 26lB/uPzGX4TTL/NAgLs7YQqPI3eDV6W/fP3r+jpaTPuMQmHDTbD2UIepgS4sm5SutqG fqB+j7oVREHQYd2Q57EAHKIqgmgkb8twzRSk4P8neMzFT8j7W+QjCDgrsQbizuvSpm1j q5N+mszjAJpjEcdEt9iGBSl3I1HSssXcYPkjF2FiV4z+olaktv+qI60CxTBjOCtO/trO g7zkmy+06JS9D/fbI+N9SnPsRJzYd2cQPtXfwqSvrMePHjGD3jpgXvNRLKQdZczsvlkV wXpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=awtvMvpzZhsaTZUbEfHRJE4Vbfvc7fc0pIJD8NnJozs=; b=G3nDratVo4I3ZSwSZi9wtpL2AiX3ej471cr5LazaZSw/66hCq0MLSmqQIo21Pvj33H kuYdCxuTx7ParBdJYXkPx/Os/X4NQaPwRsyGaHoCdFIWP8wvSCM9VDHPxM4Z+W+ZiuKJ 72ojTfvVGurejR9B+alGhuMT9VdJyBq5NrwAXt+Ig9rEUQtqtnUyXjkrWwWsUqty+96P EarohVgsNLIJM19hBpqiglaRNxv+Qz3txDtlrhq4/n+MCPRbOX/EpdGH0TFIO/HytE1n qznM4V7J1exjQFGzlUXTU5w0032ZJprOmv71LoTycf2yjeX1+qqLYiDJKcGHQ9Z7baLE WnBg== X-Gm-Message-State: APjAAAUkmZwg2grVWpIDZxeojk5wD+m9rCGD2Y7iOORM4azRYh5x8V4v rQx/zWusm/s1OO/M9xAt37CP2O+KCc4f9HcNj38= X-Received: by 2002:a17:902:112b:: with SMTP id d40mr59939401pla.31.1558135967232; Fri, 17 May 2019 16:32:47 -0700 (PDT) MIME-Version: 1.0 References: <20190510223744.10154-1-prsriva02@gmail.com> <20190510223744.10154-3-prsriva02@gmail.com> <45344b2f-d9ea-f7df-e45f-18037e2ba5ca@huawei.com> In-Reply-To: From: prakhar srivastava Date: Fri, 17 May 2019 16:32:36 -0700 Message-ID: Subject: Re: [PATCH 2/3 v5] add a new template field buf to contain the buffer To: Roberto Sassu Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Mimi Zohar , ebiederm@xmission.com, vgoyal@redhat.com, Prakhar Srivastava Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 14, 2019 at 6:22 AM Roberto Sassu wrote: > > 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 template 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. Hi Roberto, I did some testing after making the needed code changes, the output is as expected the buf template field only contains the buf when the ima_event_data.buf is set. However i just want to double check if adding two new fields to the struct ima_event_data is approach you want me to take? Mimi any concerns? what all tests do i need to run to confirm i am not in-inadvertently breaking some thing else? Thanks, Prakhar Srivastava > > 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