Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

module: Group section index calculations together

Group all the index detection together to make the parent function
easier to read.

Signed-off-by: Matthew Maurer <mmaurer@google.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

authored by

Matthew Maurer and committed by
Luis Chamberlain
f3f56121 0a939533

+51 -17
+51 -17
kernel/module/main.c
··· 2039 2039 return 0; 2040 2040 } 2041 2041 2042 + /** 2043 + * elf_validity_cache_index() - Resolve, validate, cache section indices 2044 + * @info: Load info to read from and update. 2045 + * &load_info->sechdrs and &load_info->secstrings must be populated. 2046 + * @flags: Load flags, relevant to suppress version loading, see 2047 + * uapi/linux/module.h 2048 + * 2049 + * Populates &load_info->index, validating as it goes. 2050 + * See child functions for per-field validation: 2051 + * 2052 + * * elf_validity_cache_index_info() 2053 + * * elf_validity_cache_index_mod() 2054 + * * elf_validity_cache_index_sym() 2055 + * * elf_validity_cache_index_str() 2056 + * 2057 + * If versioning is not suppressed via flags, load the version index from 2058 + * a section called "__versions" with no validation. 2059 + * 2060 + * If CONFIG_SMP is enabled, load the percpu section by name with no 2061 + * validation. 2062 + * 2063 + * Return: 0 on success, negative error code if an index failed validation. 2064 + */ 2065 + static int elf_validity_cache_index(struct load_info *info, int flags) 2066 + { 2067 + int err; 2068 + 2069 + err = elf_validity_cache_index_info(info); 2070 + if (err < 0) 2071 + return err; 2072 + err = elf_validity_cache_index_mod(info); 2073 + if (err < 0) 2074 + return err; 2075 + err = elf_validity_cache_index_sym(info); 2076 + if (err < 0) 2077 + return err; 2078 + err = elf_validity_cache_index_str(info); 2079 + if (err < 0) 2080 + return err; 2081 + 2082 + if (flags & MODULE_INIT_IGNORE_MODVERSIONS) 2083 + info->index.vers = 0; /* Pretend no __versions section! */ 2084 + else 2085 + info->index.vers = find_sec(info, "__versions"); 2086 + 2087 + info->index.pcpu = find_pcpusec(info); 2088 + 2089 + return 0; 2090 + } 2091 + 2042 2092 /* 2043 2093 * Check userspace passed ELF module against our expectations, and cache 2044 2094 * useful variables for further processing as we go. ··· 2119 2069 err = elf_validity_cache_secstrings(info); 2120 2070 if (err < 0) 2121 2071 return err; 2122 - err = elf_validity_cache_index_info(info); 2123 - if (err < 0) 2124 - return err; 2125 - err = elf_validity_cache_index_mod(info); 2126 - if (err < 0) 2127 - return err; 2128 - err = elf_validity_cache_index_sym(info); 2129 - if (err < 0) 2130 - return err; 2131 - err = elf_validity_cache_index_str(info); 2072 + err = elf_validity_cache_index(info, flags); 2132 2073 if (err < 0) 2133 2074 return err; 2134 2075 ··· 2135 2094 */ 2136 2095 if (!info->name) 2137 2096 info->name = info->mod->name; 2138 - 2139 - if (flags & MODULE_INIT_IGNORE_MODVERSIONS) 2140 - info->index.vers = 0; /* Pretend no __versions section! */ 2141 - else 2142 - info->index.vers = find_sec(info, "__versions"); 2143 - 2144 - info->index.pcpu = find_pcpusec(info); 2145 2097 2146 2098 return 0; 2147 2099 }