module: trivial cleanups for symbol search
PATCH 2/3 module: do not binary-search in __ksymtab_gpl if fsa->gplok is false
In reply to Masahiro YamadaCurrently, !fsa->gplok && syms->license == GPL_ONLY) is checked after bsearch() succeeds.
It is meaningless to do the binary search in the GPL symbol table when fsa->gplok is false because we know find_exported_symbol_in_section() will fail anyway.
This check should be done before bsearch().
---
kernel/module.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/module.c +3 -2
@@ -448,8 +448,6 @@ static bool check_exported_symbol(const struct symsearch *syms, struct module *owner, unsigned int symnum, struct find_symbol_arg *fsa) { - if (!fsa->gplok && syms->license == GPL_ONLY) - return false; fsa->owner = owner; fsa->crc =symversion (syms->crcs, symnum); fsa->sym = &syms->start[symnum];
@@ -497,6 +495,9 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms, {struct kernel_symbol *sym; +if (!fsa->gplok && syms->license ==GPL_ONLY ) +return false; + sym =bsearch (fsa->name, syms->start, syms->stop - syms->start,sizeof (struct kernel_symbol ), cmp_name);
Signature · 1 line
2.32.0
cover module: trivial cleanups for symbol search
Masahiro Yamada (3):
module: do not pass opaque pointer for symbol search
module: do not binary-search in __ksymtab_gpl if fsa->gplok is false
module: merge check_exported_symbol() into
find_exported_symbol_in_section()
kernel/module.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/3 module: do not pass opaque pointer for symbol search
There is no need to use an opaque pointer for check_exported_symbol() or find_exported_symbol_in_section.
Pass (struct find_symbol_arg *) explicitly.
---
kernel/module.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
kernel/module.c +4 -7
@@ -445,11 +445,9 @@ struct find_symbol_arg { };static bool check_exported_symbol (const struct symsearch *syms, -struct module *owner, -unsigned int symnum,void *data) +struct module *owner,unsigned int symnum, +struct find_symbol_arg *fsa) { -struct find_symbol_arg *fsa = data; -if (!fsa->gplok && syms->license ==GPL_ONLY )return false; fsa->owner = owner;
@@ -495,16 +493,15 @@ static int cmp_name(const void *name, const void *sym)static bool find_exported_symbol_in_section (const struct symsearch *syms,struct module *owner, -void *data) +struct find_symbol_arg *fsa) { -struct find_symbol_arg *fsa = data;struct kernel_symbol *sym; sym =bsearch (fsa->name, syms->start, syms->stop - syms->start,sizeof (struct kernel_symbol ), cmp_name);if (sym !=NULL &&check_exported_symbol (syms, owner, - sym - syms->start, data)) + sym - syms->start, fsa))return true;return false;
Signature · 1 line
2.32.0
PATCH 3/3 module: merge check_exported_symbol() into find_exported_symbol_in_section()
In reply to Masahiro YamadaNow check_exported_symbol() always succeeds.
Merge it into find_exported_symbol_in_search() to make the code concise.
---
kernel/module.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
kernel/module.c +7 -15
@@ -444,17 +444,6 @@ struct find_symbol_arg {enum mod_license license; }; -static bool check_exported_symbol (const struct symsearch *syms, -struct module *owner,unsigned int symnum, -struct find_symbol_arg *fsa) -{ - fsa->owner = owner; - fsa->crc =symversion (syms->crcs, symnum); - fsa->sym = &syms->start[symnum]; - fsa->license = syms->license; -return true; -} -static unsigned long kernel_symbol_value (const struct kernel_symbol *sym) {#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
@@ -500,12 +489,15 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms, sym =bsearch (fsa->name, syms->start, syms->stop - syms->start,sizeof (struct kernel_symbol ), cmp_name); +if (!sym) +return false; -if (sym !=NULL &&check_exported_symbol (syms, owner, - sym - syms->start, fsa)) -return true; + fsa->owner = owner; + fsa->crc =symversion (syms->crcs, sym - syms->start); + fsa->sym = sym; + fsa->license = syms->license; -return false; +return true; }/*
Signature · 1 line
2.32.0
Quoted 9 lines · Masahiro Yamada
Masahiro Yamada (3):
module: do not pass opaque pointer for symbol search
module: do not binary-search in__ksymtab_gpliffsa->gplokis false
module: mergecheck_exported_symbol()into
find_exported_symbol_in_section()kernel/module.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
Thanks! The droid you are looking for however has morphed quite a bit, any chance you can rebase onto modules-next [0] and resend a v2?
[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=modules-next
Luis