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: Factor out elf_validity_cache_strtab

This patch only moves the existing strtab population to a function.
Validation comes in a following patch, this is split out to make the new
validation checks more clearly separated.

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
837031e0 f3f56121

+20 -3
+20 -3
kernel/module/main.c
··· 2089 2089 return 0; 2090 2090 } 2091 2091 2092 + /** 2093 + * elf_validity_cache_strtab() - Cache symbol string table 2094 + * @info: Load info to read from and update. 2095 + * Must have &load_info->sechdrs and &load_info->secstrings populated. 2096 + * Must have &load_info->index populated. 2097 + * 2098 + * Return: 0 on success, negative error code if a check failed. 2099 + */ 2100 + static int elf_validity_cache_strtab(struct load_info *info) 2101 + { 2102 + Elf_Shdr *str_shdr = &info->sechdrs[info->index.str]; 2103 + char *strtab = (char *)info->hdr + str_shdr->sh_offset; 2104 + 2105 + info->strtab = strtab; 2106 + return 0; 2107 + } 2108 + 2092 2109 /* 2093 2110 * Check userspace passed ELF module against our expectations, and cache 2094 2111 * useful variables for further processing as we go. ··· 2139 2122 err = elf_validity_cache_index(info, flags); 2140 2123 if (err < 0) 2141 2124 return err; 2142 - 2143 - /* Sets internal strings. */ 2144 - info->strtab = (char *)info->hdr + info->sechdrs[info->index.str].sh_offset; 2125 + err = elf_validity_cache_strtab(info); 2126 + if (err < 0) 2127 + return err; 2145 2128 2146 2129 /* This is temporary: point mod into copy of data. */ 2147 2130 info->mod = (void *)info->hdr + info->sechdrs[info->index.mod].sh_offset;