FROMGIT: module: Group section index calculations together
Group all the index detection together to make the parent function easier to read. Change-Id: Ifc0dc5b134d7b82ca390d9a0cbde1fc2f04ead55 Signed-off-by: Matthew Maurer <mmaurer@google.com> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> (cherry picked from commit f3f561218bb60afd6d3e3b26add39ff46de89c83 kernel/git/modules/linux.git modules-next) Bug: 347787665
This commit is contained in:
committed by
Matthias Männich
parent
a12cb510f1
commit
3158d3f337
+51
-17
@@ -2075,6 +2075,56 @@ static int elf_validity_cache_index_str(struct load_info *info)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* elf_validity_cache_index() - Resolve, validate, cache section indices
|
||||
* @info: Load info to read from and update.
|
||||
* &load_info->sechdrs and &load_info->secstrings must be populated.
|
||||
* @flags: Load flags, relevant to suppress version loading, see
|
||||
* uapi/linux/module.h
|
||||
*
|
||||
* Populates &load_info->index, validating as it goes.
|
||||
* See child functions for per-field validation:
|
||||
*
|
||||
* * elf_validity_cache_index_info()
|
||||
* * elf_validity_cache_index_mod()
|
||||
* * elf_validity_cache_index_sym()
|
||||
* * elf_validity_cache_index_str()
|
||||
*
|
||||
* If versioning is not suppressed via flags, load the version index from
|
||||
* a section called "__versions" with no validation.
|
||||
*
|
||||
* If CONFIG_SMP is enabled, load the percpu section by name with no
|
||||
* validation.
|
||||
*
|
||||
* Return: 0 on success, negative error code if an index failed validation.
|
||||
*/
|
||||
static int elf_validity_cache_index(struct load_info *info, int flags)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = elf_validity_cache_index_info(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = elf_validity_cache_index_mod(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = elf_validity_cache_index_sym(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = elf_validity_cache_index_str(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
if (flags & MODULE_INIT_IGNORE_MODVERSIONS)
|
||||
info->index.vers = 0; /* Pretend no __versions section! */
|
||||
else
|
||||
info->index.vers = find_sec(info, "__versions");
|
||||
|
||||
info->index.pcpu = find_pcpusec(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check userspace passed ELF module against our expectations, and cache
|
||||
* useful variables for further processing as we go.
|
||||
@@ -2105,16 +2155,7 @@ static int elf_validity_cache_copy(struct load_info *info, int flags)
|
||||
err = elf_validity_cache_secstrings(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = elf_validity_cache_index_info(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = elf_validity_cache_index_mod(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = elf_validity_cache_index_sym(info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = elf_validity_cache_index_str(info);
|
||||
err = elf_validity_cache_index(info, flags);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
@@ -2131,13 +2172,6 @@ static int elf_validity_cache_copy(struct load_info *info, int flags)
|
||||
if (!info->name)
|
||||
info->name = info->mod->name;
|
||||
|
||||
if (flags & MODULE_INIT_IGNORE_MODVERSIONS)
|
||||
info->index.vers = 0; /* Pretend no __versions section! */
|
||||
else
|
||||
info->index.vers = find_sec(info, "__versions");
|
||||
|
||||
info->index.pcpu = find_pcpusec(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user