aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorMatthias Maennich <maennich@google.com>2019-09-06 06:32:25 -0400
committerJessica Yu <jeyu@kernel.org>2019-09-10 04:30:02 -0400
commitc5e4a062fe661806ab291a7576dc4a41613adb86 (patch)
treea50413326d297a9e44827e57f04ecb713420d121 /kernel/module.c
parent089cf7f6ecb266b6a4164919a2e69bd2f938374a (diff)
module: support reading multiple values per modinfo tag
Similar to modpost's get_next_modinfo(), introduce get_next_modinfo() in kernel/module.c to acquire any further values associated with the same modinfo tag name. That is useful for any tags that have multiple occurrences (such as 'alias'), but is in particular introduced here as part of the symbol namespaces patch series to read the (potentially) multiple namespaces a module is importing. Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Reviewed-by: Martijn Coenen <maco@android.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Jessica Yu <jeyu@kernel.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 9ee93421269c..3ee507c0a92f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2481,7 +2481,8 @@ static char *next_string(char *string, unsigned long *secsize)
2481 return string; 2481 return string;
2482} 2482}
2483 2483
2484static char *get_modinfo(struct load_info *info, const char *tag) 2484static char *get_next_modinfo(const struct load_info *info, const char *tag,
2485 char *prev)
2485{ 2486{
2486 char *p; 2487 char *p;
2487 unsigned int taglen = strlen(tag); 2488 unsigned int taglen = strlen(tag);
@@ -2492,13 +2493,25 @@ static char *get_modinfo(struct load_info *info, const char *tag)
2492 * get_modinfo() calls made before rewrite_section_headers() 2493 * get_modinfo() calls made before rewrite_section_headers()
2493 * must use sh_offset, as sh_addr isn't set! 2494 * must use sh_offset, as sh_addr isn't set!
2494 */ 2495 */
2495 for (p = (char *)info->hdr + infosec->sh_offset; p; p = next_string(p, &size)) { 2496 char *modinfo = (char *)info->hdr + infosec->sh_offset;
2497
2498 if (prev) {
2499 size -= prev - modinfo;
2500 modinfo = next_string(prev, &size);
2501 }
2502
2503 for (p = modinfo; p; p = next_string(p, &size)) {
2496 if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=') 2504 if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
2497 return p + taglen + 1; 2505 return p + taglen + 1;
2498 } 2506 }
2499 return NULL; 2507 return NULL;
2500} 2508}
2501 2509
2510static char *get_modinfo(const struct load_info *info, const char *tag)
2511{
2512 return get_next_modinfo(info, tag, NULL);
2513}
2514
2502static void setup_modinfo(struct module *mod, struct load_info *info) 2515static void setup_modinfo(struct module *mod, struct load_info *info)
2503{ 2516{
2504 struct module_attribute *attr; 2517 struct module_attribute *attr;