Re: [POC 22/23] livepatch/module: Remove obsolete copy_module_elf()

From: Joe Lawrence
Date: Fri Apr 03 2020 - 14:03:39 EST


On Fri, Jan 17, 2020 at 04:03:22PM +0100, Petr Mladek wrote:
> The split livepatch modules can be relocated immedidately when they
> are loaded. There is no longer needed to preserve the elf sections.
>
> Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
> ---
> Documentation/livepatch/module-elf-format.rst | 18 ++++++
> include/linux/module.h | 3 -
> kernel/module.c | 87 ---------------------------
> 3 files changed, 18 insertions(+), 90 deletions(-)
>
> diff --git a/Documentation/livepatch/module-elf-format.rst b/Documentation/livepatch/module-elf-format.rst
> index 9f0c997d4940..8c6b894c4661 100644
> --- a/Documentation/livepatch/module-elf-format.rst
> +++ b/Documentation/livepatch/module-elf-format.rst
> @@ -14,6 +14,7 @@ This document outlines the Elf format requirements that livepatch modules must f
> 4. Livepatch symbols
> 4.1 A livepatch module's symbol table
> 4.2 Livepatch symbol format
> + 5. Symbol table and Elf section access
>
> 1. Background and motivation
> ============================
> @@ -295,3 +296,20 @@ See include/uapi/linux/elf.h for the actual definitions.
> [*]
> Note that the 'Ndx' (Section index) for these symbols is SHN_LIVEPATCH (0xff20).
> "OS" means OS-specific.
> +
> +5. Symbol table and Elf section access
> +======================================
> +A livepatch module's symbol table is accessible through module->symtab.
> +
> +Since apply_relocate_add() requires access to a module's section headers,
> +symbol table, and relocation section indices, Elf information is preserved for
> +livepatch modules and is made accessible by the module loader through
> +module->klp_info, which is a klp_modinfo struct. When a livepatch module loads,
> +this struct is filled in by the module loader. Its fields are documented below::
> +
> + struct klp_modinfo {
> + Elf_Ehdr hdr; /* Elf header */
> + Elf_Shdr *sechdrs; /* Section header table */
> + char *secstrings; /* String table for the section headers */
> + unsigned int symndx; /* The symbol table section index */
> + };

I think this file was inadvertently reverted, or at least the Symbol
table and Elf section access section was supposed to stay gone, right?

-- Joe