Skip to content

Commit 1170453

Browse files
committed
Merge tag 'livepatching-for-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
Pull livepatching updates from Petr Mladek: - Code and documentation cleanup * tag 'livepatching-for-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching: livepatch: Make kobj_type structures constant livepatch: fix ELF typos
2 parents 7ec85f3 + c9c8133 commit 1170453

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

Documentation/livepatch/module-elf-format.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
===========================
2-
Livepatch module Elf format
2+
Livepatch module ELF format
33
===========================
44

5-
This document outlines the Elf format requirements that livepatch modules must follow.
5+
This document outlines the ELF format requirements that livepatch modules must follow.
66

77

88
.. Table of Contents
@@ -20,17 +20,17 @@ code. So, instead of duplicating code and re-implementing what the module
2020
loader can already do, livepatch leverages existing code in the module
2121
loader to perform the all the arch-specific relocation work. Specifically,
2222
livepatch reuses the apply_relocate_add() function in the module loader to
23-
write relocations. The patch module Elf format described in this document
23+
write relocations. The patch module ELF format described in this document
2424
enables livepatch to be able to do this. The hope is that this will make
2525
livepatch more easily portable to other architectures and reduce the amount
2626
of arch-specific code required to port livepatch to a particular
2727
architecture.
2828

2929
Since apply_relocate_add() requires access to a module's section header
30-
table, symbol table, and relocation section indices, Elf information is
30+
table, symbol table, and relocation section indices, ELF information is
3131
preserved for livepatch modules (see section 5). Livepatch manages its own
3232
relocation sections and symbols, which are described in this document. The
33-
Elf constants used to mark livepatch symbols and relocation sections were
33+
ELF constants used to mark livepatch symbols and relocation sections were
3434
selected from OS-specific ranges according to the definitions from glibc.
3535

3636
Why does livepatch need to write its own relocations?
@@ -43,7 +43,7 @@ reject the livepatch module. Furthermore, we cannot apply relocations that
4343
affect modules not yet loaded at patch module load time (e.g. a patch to a
4444
driver that is not loaded). Formerly, livepatch solved this problem by
4545
embedding special "dynrela" (dynamic rela) sections in the resulting patch
46-
module Elf output. Using these dynrela sections, livepatch could resolve
46+
module ELF output. Using these dynrela sections, livepatch could resolve
4747
symbols while taking into account its scope and what module the symbol
4848
belongs to, and then manually apply the dynamic relocations. However this
4949
approach required livepatch to supply arch-specific code in order to write
@@ -80,7 +80,7 @@ Example:
8080
3. Livepatch relocation sections
8181
================================
8282

83-
A livepatch module manages its own Elf relocation sections to apply
83+
A livepatch module manages its own ELF relocation sections to apply
8484
relocations to modules as well as to the kernel (vmlinux) at the
8585
appropriate time. For example, if a patch module patches a driver that is
8686
not currently loaded, livepatch will apply the corresponding livepatch
@@ -95,7 +95,7 @@ also possible for a livepatch module to have no livepatch relocation
9595
sections, as in the case of the sample livepatch module (see
9696
samples/livepatch).
9797

98-
Since Elf information is preserved for livepatch modules (see Section 5), a
98+
Since ELF information is preserved for livepatch modules (see Section 5), a
9999
livepatch relocation section can be applied simply by passing in the
100100
appropriate section index to apply_relocate_add(), which then uses it to
101101
access the relocation section and apply the relocations.
@@ -291,12 +291,12 @@ Examples:
291291
Note that the 'Ndx' (Section index) for these symbols is SHN_LIVEPATCH (0xff20).
292292
"OS" means OS-specific.
293293

294-
5. Symbol table and Elf section access
294+
5. Symbol table and ELF section access
295295
======================================
296296
A livepatch module's symbol table is accessible through module->symtab.
297297

298298
Since apply_relocate_add() requires access to a module's section headers,
299-
symbol table, and relocation section indices, Elf information is preserved for
299+
symbol table, and relocation section indices, ELF information is preserved for
300300
livepatch modules and is made accessible by the module loader through
301301
module->klp_info, which is a :c:type:`klp_modinfo` struct. When a livepatch module
302302
loads, this struct is filled in by the module loader.

include/linux/module.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ struct mod_kallsyms {
353353

354354
#ifdef CONFIG_LIVEPATCH
355355
/**
356-
* struct klp_modinfo - Elf information preserved from the livepatch module
356+
* struct klp_modinfo - ELF information preserved from the livepatch module
357357
*
358-
* @hdr: Elf header
358+
* @hdr: ELF header
359359
* @sechdrs: Section header table
360360
* @secstrings: String table for the section headers
361361
* @symndx: The symbol table section index
@@ -523,7 +523,7 @@ struct module {
523523
bool klp; /* Is this a livepatch module? */
524524
bool klp_alive;
525525

526-
/* Elf information */
526+
/* ELF information */
527527
struct klp_modinfo *klp_info;
528528
#endif
529529

kernel/livepatch/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ static void klp_kobj_release_patch(struct kobject *kobj)
596596
complete(&patch->finish);
597597
}
598598

599-
static struct kobj_type klp_ktype_patch = {
599+
static const struct kobj_type klp_ktype_patch = {
600600
.release = klp_kobj_release_patch,
601601
.sysfs_ops = &kobj_sysfs_ops,
602602
.default_groups = klp_patch_groups,
@@ -612,7 +612,7 @@ static void klp_kobj_release_object(struct kobject *kobj)
612612
klp_free_object_dynamic(obj);
613613
}
614614

615-
static struct kobj_type klp_ktype_object = {
615+
static const struct kobj_type klp_ktype_object = {
616616
.release = klp_kobj_release_object,
617617
.sysfs_ops = &kobj_sysfs_ops,
618618
.default_groups = klp_object_groups,
@@ -628,7 +628,7 @@ static void klp_kobj_release_func(struct kobject *kobj)
628628
klp_free_func_nop(func);
629629
}
630630

631-
static struct kobj_type klp_ktype_func = {
631+
static const struct kobj_type klp_ktype_func = {
632632
.release = klp_kobj_release_func,
633633
.sysfs_ops = &kobj_sysfs_ops,
634634
};

kernel/module/livepatch.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "internal.h"
1212

1313
/*
14-
* Persist Elf information about a module. Copy the Elf header,
14+
* Persist ELF information about a module. Copy the ELF header,
1515
* section header table, section string table, and symtab section
1616
* index from info to mod->klp_info.
1717
*/
@@ -25,27 +25,27 @@ int copy_module_elf(struct module *mod, struct load_info *info)
2525
if (!mod->klp_info)
2626
return -ENOMEM;
2727

28-
/* Elf header */
28+
/* ELF header */
2929
size = sizeof(mod->klp_info->hdr);
3030
memcpy(&mod->klp_info->hdr, info->hdr, size);
3131

32-
/* Elf section header table */
32+
/* ELF section header table */
3333
size = sizeof(*info->sechdrs) * info->hdr->e_shnum;
3434
mod->klp_info->sechdrs = kmemdup(info->sechdrs, size, GFP_KERNEL);
3535
if (!mod->klp_info->sechdrs) {
3636
ret = -ENOMEM;
3737
goto free_info;
3838
}
3939

40-
/* Elf section name string table */
40+
/* ELF section name string table */
4141
size = info->sechdrs[info->hdr->e_shstrndx].sh_size;
4242
mod->klp_info->secstrings = kmemdup(info->secstrings, size, GFP_KERNEL);
4343
if (!mod->klp_info->secstrings) {
4444
ret = -ENOMEM;
4545
goto free_sechdrs;
4646
}
4747

48-
/* Elf symbol section index */
48+
/* ELF symbol section index */
4949
symndx = info->index.sym;
5050
mod->klp_info->symndx = symndx;
5151

0 commit comments

Comments
 (0)