x86 part: was: Re: [PATCH v6] livepatch: Clear relocation targets on a module removal

From
Petr Mladek <pmladek@suse.com>
Date
2022-12-09 12:36:26
Also in
live-patching, lkml
Reply to
Song Liu, 2022-11-29
On Mon 2022-11-28 17:57:06, Song Liu wrote:
quoted hunk ↗ jump to hunk
On Fri, Nov 18, 2022 at 8:24 AM Petr Mladek [off-list ref] wrote:
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
quoted
This duplicates a lot of code. Please, rename apply_relocate_add() the
same way as __apply_clear_relocate_add() and add the "apply" parameter.
Then add the wrappers for this:

int write_relocate_add(Elf64_Shdr *sechdrs,
                       const char *strtab,
                       unsigned int symindex,
                       unsigned int relsec,
                       struct module *me,
                       bool apply)
{
        int ret;
        bool early = me->state == MODULE_STATE_UNFORMED;
        void *(*write)(void *, const void *, size_t) = memcpy;

        if (!early) {
                write = text_poke;
                mutex_lock(&text_mutex);
        }
How about we move the "early" logic into __write_relocate_add()?
If I get it correctly then __write_relocate_add() has three different
return paths. I am not sure if this could be moved there a reasonable
way.

Anyway, I do not resist on the above proposal. Feel free to find
another solution that reduces the duplicated code and looks
reasonable. I am sure that there are more possibilities.

Best Regards,
Petr
Thread (27 messages) 27 messages, 5 authors, last reply 2022-12-13
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help