From: Roberto Sassu <roberto.sassu@polito.it>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [BUG] 3ce1217d6cd5 ima patch causes s390 to crash on boot
Date: Fri, 22 Nov 2013 17:36:59 +0100 [thread overview]
Message-ID: <528F882B.5050808@polito.it> (raw)
In-Reply-To: <20131122163502.GE4208@osiris>
On 11/22/2013 05:35 PM, Heiko Carstens wrote:
> On Fri, Nov 22, 2013 at 05:23:49PM +0100, Roberto Sassu wrote:
>> Another problem that I found is that strsep()
>> modifies the source buffer by replacing the separator
>> character with '\0'. In particular, this function
>> modifies static data initialized at the beginning
>> of the ima_template.c file. Maybe, this is causing
>> the kernel panic. I already sent a patch to fix this
>> problem (attached to the email) even if it is not
>> supposed to land on the 3.13 kernel. Let me know
>> if this fixes the issue. Otherwise, I will check
>> the code more in depth.
>
> With your patch below applied the kernel boots again.
> So it should go into 3.13 (or a different fix).
>
Ok, good. Yes, we will apply this patch to the 3.13 kernel.
> Thanks!
No problem.
Roberto
>
>> From 2d3aa1c0328c44ecc3af7de162791c8cddfb6dfd Mon Sep 17 00:00:00 2001
>> From: Roberto Sassu <roberto.sassu@polito.it>
>> Date: Wed, 6 Nov 2013 13:51:35 +0100
>> Subject: [RFC][PATCH 2/4] ima: make a copy of template_fmt in
>> template_desc_init_fields()
>>
>> This patch makes a copy of the 'template_fmt' function argument so that
>> the latter will not be modified by strsep(), which does the splitting by
>> replacing the given separator with '\0'.
>>
>> Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
>> ---
>> security/integrity/ima/ima_template.c | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
>> index 7bcff5c..bb33576 100644
>> --- a/security/integrity/ima/ima_template.c
>> +++ b/security/integrity/ima/ima_template.c
>> @@ -113,13 +113,19 @@ static int template_desc_init_fields(char *template_fmt,
>> struct ima_template_field ***fields,
>> int *num_fields)
>> {
>> - char *c, *template_fmt_ptr = template_fmt;
>> + char *c, *template_fmt_ptr, *template_fmt_copy = NULL;
>> int template_num_fields = template_fmt_size(template_fmt);
>> int i, result = 0;
>>
>> if (template_num_fields > IMA_TEMPLATE_NUM_FIELDS_MAX)
>> return -EINVAL;
>>
>> + /* copying is needed as strsep() modifies the original buffer */
>> + template_fmt_copy = kstrdup(template_fmt, GFP_KERNEL);
>> + if (template_fmt_copy == NULL)
>> + return -ENOMEM;
>> +
>> + template_fmt_ptr = template_fmt_copy;
>> *fields = kzalloc(template_num_fields * sizeof(*fields), GFP_KERNEL);
>> if (*fields == NULL) {
>> result = -ENOMEM;
>> @@ -139,6 +145,7 @@ static int template_desc_init_fields(char *template_fmt,
>> *num_fields = i;
>> return 0;
>> out:
>> + kfree(template_fmt_copy);
>> kfree(*fields);
>> *fields = NULL;
>> return result;
>> --
>> 1.8.1.4
>>
>
next prev parent reply other threads:[~2013-11-22 16:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 11:48 [BUG] 3ce1217d6cd5 ima patch causes s390 to crash on boot Heiko Carstens
2013-11-22 13:28 ` Roberto Sassu
2013-11-22 14:13 ` Heiko Carstens
2013-11-22 16:23 ` Roberto Sassu
2013-11-22 16:35 ` Heiko Carstens
2013-11-22 16:36 ` Roberto Sassu [this message]
2013-11-22 16:40 ` 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=528F882B.5050808@polito.it \
--to=roberto.sassu@polito.it \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
--cc=zohar@linux.vnet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox