[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <798d64a7-eb93-433d-ab6b-37a7c5d89412@linux.microsoft.com>
Date: Fri, 21 Mar 2025 09:18:22 -0700
From: steven chen <chenste@...ux.microsoft.com>
To: Mimi Zohar <zohar@...ux.ibm.com>, Baoquan He <bhe@...hat.com>
Cc: stefanb@...ux.ibm.com, roberto.sassu@...weicloud.com,
roberto.sassu@...wei.com, eric.snowberg@...cle.com, ebiederm@...ssion.com,
paul@...l-moore.com, code@...icks.com, bauermann@...abnow.com,
linux-integrity@...r.kernel.org, kexec@...ts.infradead.org,
linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org,
madvenka@...ux.microsoft.com, nramas@...ux.microsoft.com,
James.Bottomley@...senpartnership.com, vgoyal@...hat.com, dyoung@...hat.com
Subject: Re: [PATCH v10 2/8] ima: define and call ima_alloc_kexec_file_buf()
On 3/20/2025 6:06 AM, Mimi Zohar wrote:
> On Thu, 2025-03-20 at 09:51 +0800, Baoquan He wrote:
>>>>> diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
>>>>> index 8567619889d1..45170e283272 100644
>>>>> --- a/security/integrity/ima/ima_kexec.c
>>>>> +++ b/security/integrity/ima/ima_kexec.c
>>>>> @@ -15,6 +15,48 @@
>>>>> #include "ima.h"
>>>>>
>>>>> #ifdef CONFIG_IMA_KEXEC
>>>>> +static struct seq_file ima_kexec_file;
>>>>> +
>>>>> +static void ima_reset_kexec_file(struct seq_file *sf)
>>>>> +{
>>>>> + sf->buf = NULL;
>>>>> + sf->size = 0;
>>>>> + sf->read_pos = 0;
>>>>> + sf->count = 0;
>>>>> +}
>>>>> +
>>>>> +static void ima_free_kexec_file_buf(struct seq_file *sf)
>>>>> +{
>>>>> + vfree(sf->buf);
>>>>> + ima_reset_kexec_file(sf);
>>>>> +}
>>>>> +
>>>>> +static int ima_alloc_kexec_file_buf(size_t segment_size)
>>>>> +{
>>>>> + /*
>>>>> + * kexec 'load' may be called multiple times.
>>>>> + * Free and realloc the buffer only if the segment_size is
>>>>> + * changed from the previous kexec 'load' call.
>>>>> + */
>>>>> + if (ima_kexec_file.buf && ima_kexec_file.size == segment_size)
>>>>> + goto out;
>>> The call to ima_reset_kexec_file() in ima_add_kexec_buffer() resets
>>> ima_kexec_file.buf() hiding the fact that the above test always fails and falls
>>> through. As a result, 'buf' is always being re-allocated.
> Hi Steven,
>
> [Reiterating the comment in the "ima: kexec: move IMA log copy from kexec load
> to execute" thread, here, for completeness.]
>
> Instead of adding and then removing the ima_reset_kexec_file() call from
> ima_add_kexec_buffer(), defer adding the segment size test to when it is
> actually possible for the segment size to change. Please make the segment size
> test as a separate patch.
>
> ima_reset_kexec_file() will then only be called by ima_free_kexec_file_buf().
> Inline the ima_reset_kexec_file() code in ima_free_kexec_file_buf().
>
> thanks,
>
> Mimi
Hi Mimi,
I will update in next version.
Thanks,
Steven
Powered by blists - more mailing lists