Update num_symtab, symtab and strtab right after setup of core_num_syms, core_symtab and core_strtab.
PATCH 1/1 Update num_symtab, symtab and strtab right after setup of core_num_syms, core_symtab and core_strtab.
--- kernel/module.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
kernel/module.c +4 -5
@@ -2029,6 +2029,10 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)for (*s =0 , i =1 ; i < info->sechdrs[info->index.str].sh_size; ++i)if (test_bit (i, info->strmap)) *++s = mod->strtab[i]; + + mod->num_symtab = mod->core_num_syms; + mod->symtab = mod->core_symtab; + mod->strtab = mod->core_strtab; }#else static inline void layout_symtab (struct module *mod,struct load_info *info)
@@ -2738,11 +2742,6 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,/* Drop initial reference. */ module_put (mod);trim_init_extable (mod); -#ifdef CONFIG_KALLSYMS - mod->num_symtab = mod->core_num_syms; - mod->symtab = mod->core_symtab; - mod->strtab = mod->core_strtab; -#endif module_free (mod, mod->module_init); mod->module_init =NULL ; mod->init_size =0 ;
Signature · 1 line
1.7.3
Quoted 1 line · Hu Tao
Signed-off-by Hu Tao <[email protected]>
Changelog is empty.
What bug did you observe?
Quoted 21 lines
---
kernel/module.c| 9 ++++-----1 files changed, 4 insertions(+), 5 deletions(-)kernel/module.c +4
-0@@ -2029,6 +2029,10 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)for (*s =0 , i =1 ; i < info->sechdrs[info->index.str].sh_size; ++i)if (test_bit (i, info->strmap)) *++s = mod->strtab[i]; + + mod->num_symtab = mod->core_num_syms; + mod->symtab = mod->core_symtab; + mod->strtab = mod->core_strtab; }#else static inline void layout_symtab (struct module *mod,struct load_info *info)@@ -2738,11 +2742,6 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,/* Drop initial reference. */
kernel/module.c SYSCALL_DEFINE3(init_module, void __user *, umod, · line 2747
Quoted 10 lines
kernel/module.c +0
-5module_put (mod);trim_init_extable (mod); -#ifdef CONFIG_KALLSYMS - mod->num_symtab = mod->core_num_syms; - mod->symtab = mod->core_symtab; - mod->strtab = mod->core_strtab; -#endif module_free (mod, mod->module_init); mod->module_init =NULL ; mod->init_size =0 ;
This patch is not correct, symbols that are not core symbols will be dropped right after this piece of code. So NACK.
Quoted 6 lines · Américo Wang
Quoted 1 line · Hu Tao
Signed-off-by Hu Tao <[email protected]>Changelog is empty.
What bug did you observe?
symtab and strtab will point to vfreed memory after free_copy(&info) near end of load_module().
Quoted 28 lines
Quoted 28 lines
---
kernel/module.c| 9 ++++-----1 files changed, 4 insertions(+), 5 deletions(-)kernel/module.c +4
-4@@ -2029,6 +2029,10 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)for (*s =0 , i =1 ; i < info->sechdrs[info->index.str].sh_size; ++i)if (test_bit (i, info->strmap)) *++s = mod->strtab[i]; + + mod->num_symtab = mod->core_num_syms; + mod->symtab = mod->core_symtab; + mod->strtab = mod->core_strtab; }#else static inline void layout_symtab (struct module *mod,struct load_info *info)@@ -2738,11 +2742,6 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,/* Drop initial reference. */ module_put (mod);trim_init_extable (mod); -#ifdef CONFIG_KALLSYMS - mod->num_symtab = mod->core_num_syms; - mod->symtab = mod->core_symtab; - mod->strtab = mod->core_strtab;
Quoted 8 lines
kernel/module.c SYSCALL_DEFINE3(init_module, void __user *, umod, · line 2747
Quoted 4 lines
kernel/module.c +0
-1-#endif module_free (mod, mod->module_init); mod->module_init =NULL ; mod->init_size =0 ;This patch is not correct, symbols that are not core symbols will be dropped right after this piece of code. So NACK.
There is the reason why we should update num_symtab, symtab and strtab before non-core-symbols are dropped.
Américo Wang
Reviewed-byQuoted 11 lines · Hu Tao
Quoted 6 lines · Américo Wang
Quoted 1 line · Hu Tao
Signed-off-by Hu Tao <[email protected]>Changelog is empty.
What bug did you observe?symtab and strtab will point to vfreed memory after
free_copy(&info)near end ofload_module().
I think you must mean the error path in load_module(), yeah, probably.
But you need to check if this patch misses other thing, like
the other functions which are called after add_kallsyms() inside load_module(). According to my eyes, this seems fine (at least on x86), so
Quoted 7 lines
Quoted 4 lines
This patch is not correct, symbols that are not core symbols will be dropped right after this piece of code. So NACK.
There is the reason why we should update
num_symtab, symtab and strtab before non-core-symbols are dropped.
init section is dropped *after* these value are update, which is correct.
Again, you need to describe what you are trying to fix in your changelog. Please resend it with a proper changelog.
Thanks.
Quoted 6 lines · Américo Wang
Quoted 5 lines · Hu Tao
Quoted 4 lines · Américo Wang
Quoted 1 line · Hu Tao
Signed-off-by Hu Tao <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Changelog is empty.
What bug did you observe?symtab and strtab will point to vfreed memory after
free_copy(&info)near end ofload_module().I think you must mean the error path in
load_module(), yeah, probably.
No. There is a free_copy(&info) at the end of normal path of load_module().
Quoted 6 lines
But you need to check if this patch misses other thing, like
the other functions which are called afteradd_kallsyms()insideload_module(). According to my eyes, this seems fine (at least on x86), soReviewed-by WANG Cong <[email protected]>
Thanks for review.
Quoted 15 lines
Quoted 8 lines
Quoted 5 lines
This patch is not correct, symbols that are not core symbols will be dropped right after this piece of code. So NACK.
There is the reason why we should update
num_symtab, symtab and strtab before non-core-symbols are dropped.init section is dropped *after* these value are update, which is correct.
Again, you need to describe what you are trying to fix in your changelog. Please resend it with a proper changelog.
Thanks.