From: steven chen <chenste@linux.microsoft.com>
To: Mimi Zohar <zohar@linux.ibm.com>, Baoquan He <bhe@redhat.com>
Cc: stefanb@linux.ibm.com, roberto.sassu@huaweicloud.com,
roberto.sassu@huawei.com, eric.snowberg@oracle.com,
ebiederm@xmission.com, paul@paul-moore.com, code@tyhicks.com,
bauermann@kolabnow.com, linux-integrity@vger.kernel.org,
kexec@lists.infradead.org, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, madvenka@linux.microsoft.com,
nramas@linux.microsoft.com,
James.Bottomley@hansenpartnership.com, vgoyal@redhat.com,
dyoung@redhat.com
Subject: Re: [PATCH v9 1/7] ima: copy only complete measurement records across kexec
Date: Tue, 11 Mar 2025 16:45:11 -0700 [thread overview]
Message-ID: <a952eaa2-faf4-4312-87bd-7cb6a9100df5@linux.microsoft.com> (raw)
In-Reply-To: <631f326006226e23f4f755fd32255792f6514a90.camel@linux.ibm.com>
On 3/11/2025 5:44 AM, Mimi Zohar wrote:
> On Thu, 2025-03-06 at 21:51 -0500, Mimi Zohar wrote:
>> On Thu, 2025-03-06 at 14:45 -0800, steven chen wrote:
>>> On 3/5/2025 4:27 AM, Mimi Zohar wrote:
>>>> On Wed, 2025-03-05 at 20:08 +0800, Baoquan He wrote:
>>>>> On 03/04/25 at 11:03am, steven chen wrote:
>>>>>> Carrying the IMA measurement list across kexec requires allocating a
>>>>>> buffer and copying the measurement records. Separate allocating the
>>>>>> buffer and copying the measurement records into separate functions in
>>>>>> order to allocate the buffer at kexec 'load' and copy the measurements
>>>>>> at kexec 'execute'.
>>>>>>
>>>>>> This patch includes the following changes:
>>>>> I don't know why one patch need include so many changes. From below log,
>>>>> it should be split into separate patches. It may not need to make one
>>>>> patch to reflect one change, we should at least split and wrap several
>>>>> kind of changes to ease patch understanding and reviewing. My personal
>>>>> opinion.
>>>> Agreed, well explained.
>>>>
>>>> Mimi
>>>>
>>>>>> - Refactor ima_dump_measurement_list() to move the memory allocation
>>>>>> to a separate function ima_alloc_kexec_file_buf() which allocates
>>>>>> buffer of size 'kexec_segment_size' at kexec 'load'.
>>>>>> - Make the local variable ima_kexec_file in ima_dump_measurement_list()
>>>>>> a local static to the file, so that it can be accessed from
>>>>>> ima_alloc_kexec_file_buf(). Compare actual memory required to ensure
>>>>>> there is enough memory for the entire measurement record.
>>>>>> - Copy only complete measurement records.
>>>>>> - Make necessary changes to the function ima_add_kexec_buffer() to call
>>>>>> the above two functions.
>>>>>> - Compared the memory size allocated with memory size of the entire
>>>>>> measurement record. Copy only complete measurement records if there
>>>>>> is enough memory. If there is not enough memory, it will not copy
>>>>>> any IMA measurement records, and this situation will result in a
>>>>>> failure of remote attestation.
>>>>>>
>>>>>> Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
>>>>>> Signed-off-by: Tushar Sugandhi <tusharsu@linux.microsoft.com>
>>>>>> Signed-off-by: steven chen <chenste@linux.microsoft.com>
>>> I will split this patch into the following two patches:
>>>
>>> ima: define and call ima_alloc_kexec_file_buf
>>> ima: copy measurement records as much as possible across kexec
>> Steven, breaking up code into patches is in order to simplify patch review.
>> This is done by limiting each patch to a single "logical change" [1]. For
>> example, the change below has nothing to do with "separate allocating the buffer
>> and copying the measurement records into separate functions".
>>
>> /* This is an append-only list, no need to hold the RCU read lock */
>> list_for_each_entry_rcu(qe, &ima_measurements, later, true) {
>> - if (file.count < file.size) {
>> + entry_size += ima_get_binary_runtime_entry_size(qe->entry);
>> + if (entry_size <= segment_size) {
>> khdr.count++;
>> - ima_measurements_show(&file, qe);
>> + ima_measurements_show(&ima_kexec_file, qe);
>> } else {
>> ret = -EINVAL;
>> + pr_err("IMA log file is too big for Kexec buf\n");
>> break;
>> }
>> }
>>
>> The original code potentially copied a partial last measurement record, not a
>> complete measurement record. For ease of review, the above change is fine, but
>> it needs to be a separate patch.
>>
>> Patches:
>> 1. ima: copy only complete measurement records across kexec
>> 2. ima: define and call ima_alloc_kexec_file_buf()
> Steven,
>
> The alternative would be to revert using ima_get_binary_runtime_entry_size() and
> simply use "ima_kexec_file.count < ima_kexec_file.size". Only
> ima_kexec_file.size would be initialized in ima_alloc_kexec_buf(). The rest
> would remain in ima_dump_measurement_list(). get_binary_runtime_size() wouldn't
> need to be made global.
>
> To further simplify the patch review, first define a separate patch to just
> rename the seq_file "file" to "ima_kexec_file".
>
> Mimi
Hi Mimi,
I will work on it.
Thanks,
Steven
next prev parent reply other threads:[~2025-03-11 23:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 19:03 [PATCH v9 0/7] ima: kexec: measure events between kexec load and execute steven chen
2025-03-04 19:03 ` [PATCH v9 1/7] ima: copy only complete measurement records across kexec steven chen
2025-03-05 2:08 ` Mimi Zohar
2025-03-05 11:34 ` Mimi Zohar
2025-03-05 12:08 ` Baoquan He
2025-03-05 12:27 ` Mimi Zohar
2025-03-06 22:45 ` steven chen
2025-03-07 2:51 ` Mimi Zohar
2025-03-11 12:44 ` Mimi Zohar
2025-03-11 23:45 ` steven chen [this message]
2025-03-04 19:03 ` [PATCH v9 2/7] kexec: define functions to map and unmap segments steven chen
2025-03-04 22:23 ` Jarkko Sakkinen
2025-03-05 0:55 ` steven chen
2025-03-05 12:24 ` Baoquan He
2025-03-17 18:26 ` steven chen
2025-03-06 6:35 ` Dan Carpenter
2025-03-04 19:03 ` [PATCH v9 3/7] ima: kexec: skip IMA segment validation after kexec soft reboot steven chen
2025-03-05 12:37 ` Baoquan He
2025-03-04 19:03 ` [PATCH v9 4/7] ima: kexec: define functions to copy IMA log at soft boot steven chen
2025-03-12 8:57 ` kernel test robot
2025-03-04 19:03 ` [PATCH v9 5/7] ima: kexec: move IMA log copy from kexec load to execute steven chen
2025-03-04 19:03 ` [PATCH v9 6/7] ima: make the kexec extra memory configurable steven chen
2025-03-04 19:03 ` [PATCH v9 7/7] ima: measure kexec load and exec events as critical data steven chen
2025-03-05 0:25 ` Mimi Zohar
2025-03-05 0:57 ` steven chen
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=a952eaa2-faf4-4312-87bd-7cb6a9100df5@linux.microsoft.com \
--to=chenste@linux.microsoft.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=bauermann@kolabnow.com \
--cc=bhe@redhat.com \
--cc=code@tyhicks.com \
--cc=dyoung@redhat.com \
--cc=ebiederm@xmission.com \
--cc=eric.snowberg@oracle.com \
--cc=kexec@lists.infradead.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=madvenka@linux.microsoft.com \
--cc=nramas@linux.microsoft.com \
--cc=paul@paul-moore.com \
--cc=roberto.sassu@huawei.com \
--cc=roberto.sassu@huaweicloud.com \
--cc=stefanb@linux.ibm.com \
--cc=vgoyal@redhat.com \
--cc=zohar@linux.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