[PATCH v5 4/8] ima: kexec: define functions to copy IMA log at soft boot

Tushar Sugandhi tusharsu at linux.microsoft.com
Wed Feb 14 22:55:54 PST 2024



On 2/14/24 12:47, Stefan Berger wrote:
> 
> 
> On 2/14/24 10:38, Tushar Sugandhi wrote:
...
<snip/>
...
>> +void kimage_file_post_load(struct kimage *image)
>> +{
>> +    ima_kexec_post_load(image);
>> +}
>> +
> 
> We get this here at this point but it disappears later -- missing header?
> 
> kernel/kexec_file.c:189:6: warning: no previous prototype for 
> ‘kimage_file_post_load’ [-Wmissing-prototypes]
>    189 | void kimage_file_post_load(struct kimage *image)
>        |      ^~~~~~~~~~~~~~~~~~~~~
> 
> 
Thanks Stefan.
I was also getting it.
But couldn't figure out why. And I was puzzled why it was going away.

Since kimage_file_post_load() is called from the same file in patch 5/8,
I don't see a need of declaring it in a header file like 
include/linux/kexec.h.

Making kimage_file_post_load() local static resolves the warning.
But then it throws "defined but not used" warning. I will have to call 
it from kexec_file_load syscall in this patch (4/8) instead 5/8 to 
resolve that warning.

I will make the function a stub function in this patch and
make it call ima_kexec_post_load(image) in the next patch to avoid any 
potential bisect safe issues.

It aligns with the goals of patch 4/8 and 5/8 anyways.

+static void kimage_file_post_load(struct kimage *image)
+{
+	/*
+	 * this will call ima_kexec_post_load(image) to map the segment
+	 * and register the reboot notifier for moving the IMA log at
+	 * kexec execute
+	 */
+}
+


@@ -410,6 +410,9 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, 
int, initrd_fd,
         kimage_terminate(image);
+    if (!(flags & KEXEC_FILE_ON_CRASH))
+        kimage_file_post_load(image);
+

...
...<snip/>
...

> 
> Reviewed-by: Stefan Berger <stefanb at linux.ibm.com>
Thanks for the tag. I will apply it on the next version.

~Tushar



More information about the kexec mailing list