From: Roberto Sassu <roberto.sassu@polito.it>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-ima-devel@lists.sourceforge.net, zohar@us.ibm.com,
d.kasatkin@samsung.com, james.l.morris@oracle.com
Subject: Re: [RFC][PATCH 3/4] ima: display template format in meas. list if template name length is zero
Date: Thu, 05 Dec 2013 09:53:04 +0100 [thread overview]
Message-ID: <52A03EF0.4080702@polito.it> (raw)
In-Reply-To: <1386191323.20519.83.camel@dhcp-9-2-203-236.watson.ibm.com>
On 12/04/2013 10:08 PM, Mimi Zohar wrote:
> On Thu, 2013-11-07 at 15:00 +0100, Roberto Sassu wrote:
>> With the introduction of the 'ima_template_fmt' kernel cmdline parameter,
>> an user can define a new template descriptor with custom format. However,
>> in this case, userspace tools will be unable to parse the measurements
>> list because the new template is unknown. For this reason, this patch
>> modifies the current IMA behavior to display in the list the template
>> format instead of the name so that a tool can extract needed information
>> if it can handle listed fields.
>>
>> Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
>> ---
>> security/integrity/ima/ima_fs.c | 18 ++++++++++++++----
>> 1 file changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
>> index d47a7c8..6db74ff 100644
>> --- a/security/integrity/ima/ima_fs.c
>> +++ b/security/integrity/ima/ima_fs.c
>> @@ -118,6 +118,7 @@ static int ima_measurements_show(struct seq_file *m, void *v)
>> /* the list never shrinks, so we don't need a lock here */
>> struct ima_queue_entry *qe = v;
>> struct ima_template_entry *e;
>> + char *template_name;
>> int namelen;
>> u32 pcr = CONFIG_IMA_MEASURE_PCR_IDX;
>> int i;
>> @@ -127,6 +128,10 @@ static int ima_measurements_show(struct seq_file *m, void *v)
>> if (e == NULL)
>> return -1;
>>
>> + template_name = e->template_desc->name;
>> + if (strlen(e->template_desc->name) == 0)
>> + template_name = e->template_desc->fmt;
>> +
>
> Hi Roberto,
>
> The patch description unconditionally says, "this patch modifies the
> current IMA behavior to display in the list the template format instead
> of the name". The code only uses the 'fmt', if the name doesn't exist.
> Please update the patch description accordingly.
>
> Nothing is wrong with the above syntax, but template_name could be
> assigned once using a ternary conditional expression(?:), like:
>
> template_name = (strlen(e->template_desc->name) == 0) ?
> e->template_desc->name : e->template_desc->fmt;
>
Ok, I will make the changes.
Thanks
Roberto Sassu
> thanks,
>
> Mimi
>
>> /*
>> * 1st: PCRIndex
>> * PCR used is always the same (config option) in
>> @@ -138,14 +143,14 @@ static int ima_measurements_show(struct seq_file *m, void *v)
>> ima_putc(m, e->digest, TPM_DIGEST_SIZE);
>>
>> /* 3rd: template name size */
>> - namelen = strlen(e->template_desc->name);
>> + namelen = strlen(template_name);
>> ima_putc(m, &namelen, sizeof namelen);
>>
>> /* 4th: template name */
>> - ima_putc(m, e->template_desc->name, namelen);
>> + ima_putc(m, template_name, namelen);
>>
>> /* 5th: template length (except for 'ima' template) */
>> - if (strcmp(e->template_desc->name, IMA_TEMPLATE_IMA_NAME) != 0)
>> + if (strcmp(template_name, IMA_TEMPLATE_IMA_NAME) != 0)
>> ima_putc(m, &e->template_data_len,
>> sizeof(e->template_data_len));
>>
>> @@ -190,6 +195,7 @@ static int ima_ascii_measurements_show(struct seq_file *m, void *v)
>> /* the list never shrinks, so we don't need a lock here */
>> struct ima_queue_entry *qe = v;
>> struct ima_template_entry *e;
>> + char *template_name;
>> int i;
>>
>> /* get entry */
>> @@ -197,6 +203,10 @@ static int ima_ascii_measurements_show(struct seq_file *m, void *v)
>> if (e == NULL)
>> return -1;
>>
>> + template_name = e->template_desc->name;
>> + if (strlen(e->template_desc->name) == 0)
>> + template_name = e->template_desc->fmt;
>> +
>> /* 1st: PCR used (config option) */
>> seq_printf(m, "%2d ", CONFIG_IMA_MEASURE_PCR_IDX);
>>
>> @@ -204,7 +214,7 @@ static int ima_ascii_measurements_show(struct seq_file *m, void *v)
>> ima_print_digest(m, e->digest, TPM_DIGEST_SIZE);
>>
>> /* 3th: template name */
>> - seq_printf(m, " %s", e->template_desc->name);
>> + seq_printf(m, " %s", template_name);
>>
>> /* 4th: template specific data */
>> for (i = 0; i < e->template_desc->num_fields; i++) {
>
>
next prev parent reply other threads:[~2013-12-05 8:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-07 14:00 [RFC][PATCH 0/4] ima: add support for custom template formats Roberto Sassu
2013-11-07 14:00 ` [RFC][PATCH 1/4] ima: added error messages to template-related functions Roberto Sassu
2013-11-07 14:00 ` [RFC][PATCH 2/4] ima: make a copy of template_fmt in template_desc_init_fields() Roberto Sassu
2013-11-07 14:00 ` [RFC][PATCH 3/4] ima: display template format in meas. list if template name length is zero Roberto Sassu
2013-12-04 21:08 ` Mimi Zohar
2013-12-05 8:53 ` Roberto Sassu [this message]
2013-11-07 14:00 ` [RFC][PATCH 4/4] ima: added support for new kernel cmdline parameter ima_template_fmt Roberto Sassu
2013-11-18 15:35 ` Dmitry Kasatkin
2013-11-18 15:47 ` Roberto Sassu
2013-12-04 21:05 ` Mimi Zohar
2013-12-05 8:49 ` Roberto Sassu
2013-12-05 12:15 ` Mimi Zohar
2013-12-05 13:32 ` Mimi Zohar
2013-11-14 3:22 ` [RFC][PATCH 0/4] ima: add support for custom template formats Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52A03EF0.4080702@polito.it \
--to=roberto.sassu@polito.it \
--cc=d.kasatkin@samsung.com \
--cc=james.l.morris@oracle.com \
--cc=linux-ima-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=zohar@linux.vnet.ibm.com \
--cc=zohar@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.