Re: [RFC] Add target module check before livepatch module loading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Mar 11, 2025, at 20:25, Petr Mladek <pmladek@xxxxxxxx> wrote:
> 
> On Tue 2025-03-11 11:53:59, zhang warden wrote:
>>> A single livepatch could modify more objects: vmlinux and several
>>> modules. The metadata for each modified object are in "struct
>>> klp_object". The related obect is currently identified only by obj->name.
>>> And we could add more precision identification by setting
>>> also "obj->srcversion" and/or "obj->build_id".
>>> 
>> 
>> Yep, but how can we get the obj->srcversion? If we tring to store it 
>> in klp_object, the information should be carried when livepatch is being build.
>> Otherwise, we don't know which srcversion is good to patch, isn't it?
> 
> I am not sure if I get the question correctly.
> 
> Anyway, struct klp_object must be defined in any livepatch, for example, see
> /prace/kernel/linux/samples/livepatch/livepatch-sample.c
> 
> I guess that you are using kPatch. I am not sure how it initializes
> these klp_patch, klp_object, and klp_func structures.
> But it has to create struct klp_object for the livepatched module
> and initialize at least .name, .func items.
> 
> The srcversion of the livepatched module can be read by modinfo,
> for example:
> 
> # modinfo test_printf
> filename:       /lib/modules/6.13.0-default+/kernel/lib/test_printf.ko
> license:        GPL
> description:    Test cases for printf facility
> author:         Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
> test:           Y
> srcversion:     AF319FC942A3220645E7E99
> depends:        
> intree:         Y
> name:           test_printf
> retpoline:      Y
> vermagic:       6.13.0-default+ SMP preempt mod_unload modversions 
> 
> You need to teach kPatch to read the srcversion of the livepatched
> module and set it in the related struct klp_object.
> 
> Best Regards,
> Petr

Oh,yeah.

You got the point. I am using kpatch[1] as userspace tool to build livepatch
module. Therefore, I am focusing on combining kPatch and kernel.

So, I need to teach kpatch module to learn the srvcversion, that's why 
I am trying to put srcversion into elf file. This elf file I mentioned is the 
livepatch module built by kPatch.

So, maybe now you can understand why my livepatch module miss the information
of the target srcversion. Because this livepatch module is built by kPatch, not building
it manually.

But now I think I have a mistake here. I should focus on the kernel first. And then,
 make adjustment to kpatch[1] after this feature is ready in kernel.

Regards
Wardenjohn

[1] kpatch: https://github.com/dynup/kpatch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux