sorting of exports breaks modpost's GPL checking
Is it known (and being worked on) that exported symbols residing themselves in modules are no longer properly handled by modpost, due to the .o files to be linked into .ko (other than vmlinux and the .ko files) still carrying the ___ksymtab*+<symbol> sections?
If not - what are the thoughts to resolve this? It's not really obvious, since
- doing the section sorting already when generating the .o-s is incompatible (at least) with .ko-s consisting of just a single .o,
- passing the .ko-s instead of the .o-s to modpost would create a chicken-and-egg situation, and
- adjusting modpost itself would require the tool to track all the ___ksymtab*+<symbol> section (i.e. causing possibly measurable extra overhead).
Thanks, Jan
Dear Mr. Beulich,
2011/7/4 Jan Beulich <[email protected]>:
Quoted 6 lines
Is it known (and being worked on) that exported symbols residing themselves in modules are no longer properly handled by modpost, due to the .o files to be linked into .ko (other than vmlinux and the .ko files) still carrying the ___ksymtab*+<symbol> sections?
If not - what are the thoughts to resolve this?
[...]
Could you tell me how reproduce the problem?
Thanks!
Ciao,
Alessio
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Alessio Igor Bogani
Dear Mr. Beulich,
2011/7/4 Jan Beulich <[email protected]>:
Quoted 5 lines
Is it known (and being worked on) that exported symbols residing themselves in modules are no longer properly handled by modpost, due to the .o files to be linked into .ko (other than vmlinux and the .ko files) still carrying the ___ksymtab*+<symbol> sections?
Quoted 4 lines
Quoted 1 line
If not - what are the thoughts to resolve this?
[...]
Could you tell me how reproduce the problem?
Just look at Modules.symvers - all the symbols coming from modules will be tagged "(unknown)" rather than EXPORT_SYMBOL, EXPORT_SYMBOL_GPL, etc.
As to reproducing the actual bad behavior - creating a non-GPL module that consumes a GPL-only export should be all you need.
Jan
Quoted 14 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Alessio Igor Bogani
Dear Mr. Beulich,
2011/7/4 Jan Beulich <[email protected]>:
Quoted 5 lines
Is it known (and being worked on) that exported symbols residing themselves in modules are no longer properly handled by modpost, due to the .o files to be linked into .ko (other than vmlinux and the .ko files) still carrying the ___ksymtab*+<symbol> sections?
Quoted 4 lines
Quoted 1 line
If not - what are the thoughts to resolve this?
[...]
Could you tell me how reproduce the problem?
Quoted 8 lines
Just look at Modules.symvers - all the symbols coming from modules will be tagged "(unknown)" rather than
EXPORT_SYMBOL,EXPORT_SYMBOL_GPL, etc.As to reproducing the actual bad behavior - creating a non-GPL module that consumes a GPL-only export should be all you need.
Jan
We could just drop this detection. It's a courtesy, after all: the gpl stuff is enforced at runtime.
Thoughts?
Rusty.
Quoted 23 lines
Quoted 1 line
Quoted 1 line · Rusty Russell
Quoted 21 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Alessio Igor Bogani
Dear Mr. Beulich,
2011/7/4 Jan Beulich <[email protected]>:
Quoted 5 lines
Is it known (and being worked on) that exported symbols residing themselves in modules are no longer properly handled by modpost, due to the .o files to be linked into .ko (other than vmlinux and the .ko files) still carrying the ___ksymtab*+<symbol> sections?
Quoted 4 lines
Quoted 1 line
If not - what are the thoughts to resolve this?
[...]
Could you tell me how reproduce the problem?
Just look at Modules.symvers - all the symbols coming from modules will be tagged "(unknown)" rather than
EXPORT_SYMBOL,EXPORT_SYMBOL_GPL, etc.As to reproducing the actual bad behavior - creating a non-GPL module that consumes a GPL-only export should be all you need.
Quoted 6 lines
Quoted 1 line
Jan
We could just drop this detection. It's a courtesy, after all: the gpl stuff is enforced at runtime.
Thoughts?
Especially for the purpose of distros I think it is quite valuable to know at build time whether there's any inconsistency that would result in runtime problems (and you certainly don't expect that testing would manage to cover each and every obscure module).
Jan
Quoted 1 line
Rusty.
Dear Mr. Beulich,
2011/7/7 Jan Beulich <[email protected]>:
[...]
Quoted 4 lines
Especially for the purpose of distros I think it is quite valuable to know at build time whether there's any inconsistency that would result in runtime problems (and you certainly don't expect that testing would manage to cover each and every obscure module).
I have just started working on this issue. I hope to fix as soon as possible but the modpost.c's code isn't trivial so I'll could take some days.
Any help by more experienced developers is appreciated.
Thanks!
Ciao,
Alessio
PATCH 1/1 modpost: Fix modpost's license checking
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux (already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules.
This patch makes modpost aware of the new exported symbols structure.
This work was supported by a hardware donation from the CE Linux Forum.
--- scripts/mod/modpost.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-)
scripts/mod/modpost.c +26 -1
@@ -254,6 +254,26 @@ static enum export export_no(const char *s)return export_unknown; } +static const char *sec_name (struct elf_info *elf,int secindex); + +static enum export export_from_secname (struct elf_info *elf,unsigned int sec) +{ +const char *secname =sec_name (elf, sec); + +if (strncmp (secname,"___ksymtab+" ,11 ) ==0 ) +return export_plain; +else if (strncmp (secname,"___ksymtab_unused+" ,18 ) ==0 ) +return export_unused; +else if (strncmp (secname,"___ksymtab_gpl+" ,15 ) ==0 ) +return export_gpl; +else if (strncmp (secname,"___ksymtab_unused_gpl+" ,22 ) ==0 ) +return export_unused_gpl; +else if (strncmp (secname,"___ksymtab_gpl_future+" ,22 ) ==0 ) +return export_gpl_future; +else +return export_unknown; +} +static enum export export_from_sec (struct elf_info *elf,unsigned int sec) {if (sec == elf->export_sec)
@@ -563,7 +583,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) {unsigned int crc; -enum export export =export_from_sec (info,get_secindex (info, sym)); +enum export export; + +if (!is_vmlinux (mod->name) &&strncmp (symname,"__ksymtab" ,9 ) ==0 ) + export =export_from_secname (info,get_secindex (info, sym)); +else + export =export_from_sec (info,get_secindex (info, sym));switch (sym->st_shndx) {case SHN_COMMON :
Signature · 1 line
1.7.4.1
Re: [PATCH] modpost: Fix modpost's license checking
Hi,
Quoted 21 lines · Alessio Igor Bogani
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux (already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules.
This patch makes modpost aware of the new exported symbols structure.
This work was supported by a hardware donation from the CE Linux Forum.
Signed-off-by Alessio Igor Bogani <[email protected]>---
scripts/mod/modpost.c | 27 ++++++++++++++++++++++++++-1 files changed, 26 insertions(+), 1 deletions(-)scripts/mod/modpost.c +0
-0
scripts/mod/modpost.c static enum export export_no(const char *s) · line 263
Quoted 10 lines
scripts/mod/modpost.c +7
-0@@ -254,6 +254,26 @@ static enum export export_no(const char *s) return export_unknown; } +static const char *sec_name (struct elf_info *elf,int secindex); + +static enum export export_from_secname (struct elf_info *elf,unsigned int sec) +{ + const char *secname = sec_name(elf, sec); + + if (strncmp(secname, "___ksymtab+", 11) == 0)
I'd suppose 11 here is `sizeof "___ksymtab+" - 1' ? Why not making that explicit though a macro, ala:
#define SEC_NAME_MATCH(name, str) (strncmp(name, str, strlen(str) - 1) == 0)
This would avoid bug in the future if the string is updated but not the size, and/or copy paste error where only the string is changed.
- Arnaud
Quoted 38 lines
scripts/mod/modpost.c +19
-1+ return export_plain; + else if (strncmp(secname, "___ksymtab_unused+", 18) == 0) + return export_unused; + else if (strncmp(secname, "___ksymtab_gpl+", 15) == 0) + return export_gpl; + else if (strncmp(secname, "___ksymtab_unused_gpl+", 22) == 0) + return export_unused_gpl; + else if (strncmp(secname, "___ksymtab_gpl_future+", 22) == 0) + return export_gpl_future; + else + return export_unknown; +} + static enum export export_from_sec(struct elf_info *elf, unsigned int sec) { if (sec == elf->export_sec)@@ -563,7 +583,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) { unsigned int crc; - enum export export = export_from_sec(info, get_secindex(info, sym)); + enum export export; + + if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0) + export = export_from_secname(info, get_secindex(info, sym)); + else + export = export_from_sec(info, get_secindex(info, sym)); switch (sym->st_shndx) {case
SHN_COMMON:
--
1.7.4.1--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 modpost: Fix modpost's license checking V2
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux (already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure. Thanks to Arnaud Lacombe <[email protected]> for providing useful suggestion about code.
This work was supported by a hardware donation from the CE Linux Forum.
--- scripts/mod/modpost.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)
scripts/mod/modpost.c +28 -1
@@ -254,6 +254,28 @@ static enum export export_no(const char *s)return export_unknown; } +static const char *sec_name (struct elf_info *elf,int secindex); + +#define SEC_NAME_MATCH (name, str) (strncmp(name, str, strlen(str) - 1) == 0) + +static enum export export_from_secname (struct elf_info *elf,unsigned int sec) +{ +const char *secname =sec_name (elf, sec); + +if (SEC_NAME_MATCH (secname,"___ksymtab+" )) +return export_plain; +else if (SEC_NAME_MATCH (secname,"___ksymtab_unused+" )) +return export_unused; +else if (SEC_NAME_MATCH (secname,"___ksymtab_gpl+" )) +return export_gpl; +else if (SEC_NAME_MATCH (secname,"___ksymtab_unused_gpl+" )) +return export_unused_gpl; +else if (SEC_NAME_MATCH (secname,"___ksymtab_gpl_future+" )) +return export_gpl_future; +else +return export_unknown; +} +static enum export export_from_sec (struct elf_info *elf,unsigned int sec) {if (sec == elf->export_sec)
@@ -563,7 +585,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) {unsigned int crc; -enum export export =export_from_sec (info,get_secindex (info, sym)); +enum export export; + +if (!is_vmlinux (mod->name) &&strncmp (symname,"__ksymtab" ,9 ) ==0 ) + export =export_from_secname (info,get_secindex (info, sym)); +else + export =export_from_sec (info,get_secindex (info, sym));switch (sym->st_shndx) {case SHN_COMMON :
Signature · 1 line
1.7.4.1
Re: [PATCH] modpost: Fix modpost's license checking V2
Quoted 1 line · Alessio Igor Bogani
+#define
SEC_NAME_MATCH(name, str)(strncmp(name, str, strlen(str) - 1)== 0)
Surely you meant strlen() or sizeof() - 1, not strlen() - 1?
Quoted 1 line
+ if (!is_vmlinux(mod->name) &&
strncmp(symname, "__ksymtab", 9)== 0)
Same strncmp pattern here. BTW, your macro is the strstarts() function in include/linux/string.h.
Anders
Re: [PATCH] modpost: Fix modpost's license checking V2
Hi,
Quoted 10 lines · Anders Kaseorg
Quoted 1 line · Alessio Igor Bogani
+#define
SEC_NAME_MATCH(name, str)(strncmp(name, str, strlen(str) - 1)== 0)Surely you meant
strlen()orsizeof()- 1, notstrlen()- 1?Quoted 1 line
+ if (!is_vmlinux(mod->name) &&
strncmp(symname, "__ksymtab", 9)== 0)Same strncmp pattern here. BTW, your macro is the
strstarts()function ininclude/linux/string.h.
modpost is an host tool, it should not include kernel header. Content of this file is not exported to userland anyway.
- Arnaud
- Arnaud
Re: [PATCH] modpost: Fix modpost's license checking V2
Quoted 2 lines · Arnaud Lacombe
modpost is an host tool, it should not include kernel header. Content of this file is not exported to userland anyway.
My point was more that you might as well reuse the same name and probably the same code so that people don’t have to look carefully at a new macro to decide whether it’s off-by-one from what they expect.
Anders
Re: [PATCH] modpost: Fix modpost's license checking V2
Hi,
Quoted 8 lines · Anders Kaseorg
Quoted 2 lines · Arnaud Lacombe
modpost is an host tool, it should not include kernel header. Content of this file is not exported to userland anyway.
My point was more that you might as well reuse the same name and probably the same code so that people don’t have to look carefully at a new macro to decide whether it’s off-by-one from what they expect.
Agree. I was not entirely sure of what you meant, ie. whether including "include/linux/string.h" or adjusting the name and definition to match the existing. So I thought it would just be better to clear any potential misunderstanding :)
- Arnaud
PATCH 1/1 modpost: Fix modpost's license checking V3
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux (already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure.
Thanks to Arnaud Lacombe <[email protected]> and Anders Kaseorg <[email protected]> for providing useful suggestions about code.
This work was supported by a hardware donation from the CE Linux Forum.
--- scripts/mod/modpost.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)
scripts/mod/modpost.c +28 -1
@@ -254,6 +254,28 @@ static enum export export_no(const char *s)return export_unknown; } +static const char *sec_name (struct elf_info *elf,int secindex); + +#define strstarts (str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) + +static enum export export_from_secname (struct elf_info *elf,unsigned int sec) +{ +const char *secname =sec_name (elf, sec); + +if (strstarts (secname,"___ksymtab+" )) +return export_plain; +else if (strstarts (secname,"___ksymtab_unused+" )) +return export_unused; +else if (strstarts (secname,"___ksymtab_gpl+" )) +return export_gpl; +else if (strstarts (secname,"___ksymtab_unused_gpl+" )) +return export_unused_gpl; +else if (strstarts (secname,"___ksymtab_gpl_future+" )) +return export_gpl_future; +else +return export_unknown; +} +static enum export export_from_sec (struct elf_info *elf,unsigned int sec) {if (sec == elf->export_sec)
@@ -563,7 +585,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) {unsigned int crc; -enum export export =export_from_sec (info,get_secindex (info, sym)); +enum export export; + +if (!is_vmlinux (mod->name) &&strncmp (symname,"__ksymtab" ,9 ) ==0 ) + export =export_from_secname (info,get_secindex (info, sym)); +else + export =export_from_sec (info,get_secindex (info, sym));switch (sym->st_shndx) {case SHN_COMMON :
Signature · 1 line
1.7.4.1
Re: [PATCH] modpost: Fix modpost's license checking V3
Quoted 11 lines · Alessio Igor Bogani
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux (already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure.
Thanks to Arnaud Lacombe<[email protected]> and Anders Kaseorg <[email protected]> for providing useful suggestions about code.
Quoted 7 lines
This work was supported by a hardware donation from the CE Linux Forum.
Reported-by Jan Beulich<[email protected]>Signed-off-by Alessio Igor Bogani<[email protected]>--- scripts/mod/modpost.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)
Rusty, will you take this patch or should I apply it to kbuild-2.6.git?
Michal
Quoted 47 lines
scripts/mod/modpost.c +28
-1@@ -254,6 +254,28 @@ static enum export export_no(const char *s)return export_unknown; } +static const char *sec_name (struct elf_info *elf,int secindex); + +#define strstarts (str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) + +static enum export export_from_secname (struct elf_info *elf,unsigned int sec) +{ +const char *secname =sec_name (elf, sec); + +if (strstarts (secname,"___ksymtab+" )) +return export_plain; +else if (strstarts (secname,"___ksymtab_unused+" )) +return export_unused; +else if (strstarts (secname,"___ksymtab_gpl+" )) +return export_gpl; +else if (strstarts (secname,"___ksymtab_unused_gpl+" )) +return export_unused_gpl; +else if (strstarts (secname,"___ksymtab_gpl_future+" )) +return export_gpl_future; +else +return export_unknown; +} +static enum export export_from_sec (struct elf_info *elf,unsigned int sec) {if (sec == elf->export_sec)@@ -563,7 +585,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) {unsigned int crc; -enum export export =export_from_sec (info,get_secindex (info, sym)); +enum export export; + +if (!is_vmlinux (mod->name)&&strncmp (symname,"__ksymtab" ,9 ) ==0 ) + export =export_from_secname (info,get_secindex (info, sym)); +else + export =export_from_sec (info,get_secindex (info, sym));switch (sym->st_shndx) {case SHN_COMMON :
Re: [PATCH] modpost: Fix modpost's license checking V3
Quoted 14 lines · Michal Marek
Quoted 13 lines · Alessio Igor Bogani
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux (already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure.
Thanks to Arnaud Lacombe<[email protected]> and Anders Kaseorg <[email protected]> for providing useful suggestions about code.
This work was supported by a hardware donation from the CE Linux Forum.
Quoted 7 lines
Quoted 5 lines
Reported-by Jan Beulich<[email protected]>Signed-off-by Alessio Igor Bogani<[email protected]>--- scripts/mod/modpost.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)Rusty, will you take this patch or should I apply it to kbuild-2.6.git?
I took it.
Thanks,
Rusty.
Rusty Russell
AppliedRe: [PATCH] modpost: Fix modpost's license checking V3
In reply to Alessio Igor BoganiQuoted 8 lines · Alessio Igor Bogani
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux (already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure.
Quoted 4 lines
Thanks to Arnaud Lacombe <[email protected]> and Anders Kaseorg <[email protected]> for providing useful suggestions about code.
This work was supported by a hardware donation from the CE Linux Forum.
Applied.
Thanks!
Rusty.
Re: [PATCH] modpost: Fix modpost's license checking V3
In reply to Alessio Igor BoganiQuoted 3 lines · Alessio Igor Bogani
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux
Yet another unfortunately: modpost parses vmlinux.o instead of vmlinux (vmlinux does not yet exist at this point of the build). vmlinux.o also does not have the many sections sorted and merged into the canonical sections. As a result, the Module.symvers created my modpost incorrectly reports the license of all exports as "(unknown)".
Can you fix this also please?
Quoted 8 lines
(already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure.
Thanks to Arnaud Lacombe <[email protected]> and Anders Kaseorg <[email protected]> for providing useful suggestions about code.
Quoted 7 lines
This work was supported by a hardware donation from the CE Linux Forum.
Reported-by Jan Beulich <[email protected]>Signed-off-by Alessio Igor Bogani <[email protected]>--- scripts/mod/modpost.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)
< snip >
-Frank Rowand
Re: [PATCH] modpost: Fix modpost's license checking V3
Quoted 9 lines · Frank Rowand
Quoted 3 lines · Alessio Igor Bogani
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux
Yet another unfortunately: modpost parses vmlinux.o instead of vmlinux (vmlinux does not yet exist at this point of the build). vmlinux.o also does not have the many sections sorted and merged into the canonical sections. As a result, the Module.symvers created my modpost incorrectly reports the license of all
^^^ s/my/by/
Quoted 26 lines
exports as "(unknown)".
Can you fix this also please?
Quoted 8 lines
(already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure.
Thanks to Arnaud Lacombe <[email protected]> and Anders Kaseorg <[email protected]> for providing useful suggestions about code.
Quoted 7 lines
This work was supported by a hardware donation from the CE Linux Forum.
Reported-by Jan Beulich <[email protected]>Signed-off-by Alessio Igor Bogani <[email protected]>--- scripts/mod/modpost.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)< snip >
-Frank Rowand
.
Re: [PATCH] modpost: Fix modpost's license checking V3
In reply to Frank RowandQuoted 5 lines · Frank Rowand
Quoted 3 lines · Alessio Igor Bogani
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux
Quoted 7 lines
Yet another unfortunately: modpost parses vmlinux.o instead of vmlinux (vmlinux does not yet exist at this point of the build). vmlinux.o also does not have the many sections sorted and merged into the canonical sections. As a result, the Module.symvers created my modpost incorrectly reports the license of all exports as "(unknown)".
Can you fix this also please?
The attached patch modifies your patch to also use export_from_secname() for vmlinux and vmlinux.o.
This is a rather blind shot at fixing the problem, so please review carefully. After applying the patch, Module.symvers reports the license correctly for exports from vmlinux.o.
Quoted 18 lines
Quoted 10 lines
(already linked) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules. This patch makes modpost aware of the new exported symbols structure.
Thanks to Arnaud Lacombe <[email protected]> and Anders Kaseorg <[email protected]> for providing useful suggestions about code.
Quoted 7 lines
This work was supported by a hardware donation from the CE Linux Forum.
Reported-by Jan Beulich <[email protected]>Signed-off-by Alessio Igor Bogani <[email protected]>--- scripts/mod/modpost.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)
Quoted 3 lines
< snip >
-Frank Rowand
---
scripts/mod/modpost.c | 2 1 + 1 - 0 !
1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
@@ -589,7 +589,7 @@ static void handle_modversions(struct mounsigned int crc;enum export export; -if (!is_vmlinux (mod->name) &&strncmp (symname,"__ksymtab" ,9 ) ==0 ) +if (strncmp (symname,"__ksymtab" ,9 ) ==0 ) export =export_from_secname (info,get_secindex (info, sym));else export =export_from_sec (info,get_secindex (info, sym));
Re: [PATCH] modpost: Fix modpost's license checking V3
Dear Mr. Rowand,
Il 27 marzo 2012 03:58, Frank Rowand <[email protected]> ha scritto:
Quoted 12 lines · Frank Rowand
Quoted 11 lines · Alessio Igor Bogani
Quoted 3 lines
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux
Yet another unfortunately: modpost parses vmlinux.o instead of vmlinux (vmlinux does not yet exist at this point of the build). vmlinux.o also does not have the many sections sorted and merged into the canonical sections. As a result, the Module.symvers created my modpost incorrectly reports the license of all exports as "(unknown)".
Quoted 8 lines
Quoted 1 line
Can you fix this also please?
The attached patch modifies your patch to also use
export_from_secname()for vmlinux and vmlinux.o.This is a rather blind shot at fixing the problem, so please review carefully. After applying the patch, Module.symvers reports the license correctly for exports from vmlinux.o.
Could you show me how reproduce that problem? Indeed on my system "unknown" is reported (erroneously) in the v3.0 series before the commit 62a2635610dbc83c5e8d724e00941eee4d18c186 (and obviously after my patchset which adds that bug).
Thanks!
Ciao,
Alessio
Re: [PATCH] modpost: Fix modpost's license checking V3
Quoted 23 lines · Alessio Igor Bogani
Dear Mr. Rowand,
Il 27 marzo 2012 03:58, Frank Rowand <[email protected]> ha scritto:
Quoted 20 lines · Frank Rowand
Quoted 5 lines · Alessio Igor Bogani
Quoted 3 lines
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux
Quoted 7 lines
Yet another unfortunately: modpost parses vmlinux.o instead of vmlinux (vmlinux does not yet exist at this point of the build). vmlinux.o also does not have the many sections sorted and merged into the canonical sections. As a result, the Module.symvers created my modpost incorrectly reports the license of all exports as "(unknown)".
Can you fix this also please?
The attached patch modifies your patch to also use
export_from_secname()for vmlinux and vmlinux.o.This is a rather blind shot at fixing the problem, so please review carefully. After applying the patch, Module.symvers reports the license correctly for exports from vmlinux.o.
That version of my patch broke modpost for vmlinux. I don't know if anyone uses modpost against vmlinux instead of vmlinux.o, but the attached patch works for both vmlinux and vmlinux.o
Quoted 5 lines
Could you show me how reproduce that problem? Indeed on my system "unknown" is reported (erroneously) in the v3.0 series before the commit
62a2635610dbc83c5e8d724e00941eee4d18c186(and obviously after my patchset which adds that bug).
I'm not sure what you are asking here.
You mention "my patchset which adds that bug" (which from looking at the source, appears to me to probably be commit f02e8a6596b7dc9b2171f7ff5654039ef0950cdc).
The email that I originally replied to is your fix to modpost for modules, and shows up as commit 62a2635610dbc83c5e8d724e00941eee4d18c186.
My attached fix is meant to extend 62a2635610dbc83c5e8d724e00941eee4d18c186 to also fix modpost for vmlinux.o.
Quoted 6 lines
Thanks!
Ciao,
Alessio
---
scripts/mod/modpost.c | 7 5 + 2 - 0 ! scripts/mod/modpost.h | 1 1 + 0 - 0 ! 2 files changed, 6 insertions(+), 2 deletions(-)
scripts/mod/modpost.c +5 -2
@@ -132,8 +132,10 @@ static struct module *new_module(char *m/* strip trailing .o */ s =strrchr (p,'.' );if (s !=NULL ) -if (strcmp (s,".o" ) ==0 ) +if (strcmp (s,".o" ) ==0 ) { *s ='\0' ; + mod->is_dot_o =1 ; + }/* add to list */ mod->name = p;
@@ -589,7 +591,8 @@ static void handle_modversions(struct mounsigned int crc;enum export export; -if (!is_vmlinux (mod->name) &&strncmp (symname,"__ksymtab" ,9 ) ==0 ) +if ((!is_vmlinux (mod->name) || mod->is_dot_o) + &&strncmp (symname,"__ksymtab" ,9 ) ==0 ) export =export_from_secname (info,get_secindex (info, sym));else export =export_from_sec (info,get_secindex (info, sym));
scripts/mod/modpost.h +1 -0
@@ -115,6 +115,7 @@ struct module {char **markers;size_t nmarkers;char srcversion[25 ]; +int is_dot_o; };struct elf_info {
Re: [PATCH] modpost: Fix modpost's license checking V3
Dear Mr. Rowand,
Frank Rowand <[email protected]> wrote:
[...]
Quoted 3 lines
Quoted 1 line
Could you show me how reproduce that problem?
I'm not sure what you are asking here.
I meant the kernel version, the kernel configuration and so the Module.symvers file you obtain.
Thanks!
Ciao,
Alessio
Re: [PATCH] modpost: Fix modpost's license checking V3
In reply to Frank RowandQuoted 2 lines · Frank Rowand
The attached patch modifies your patch to also use
export_from_secname()for vmlinux and vmlinux.o.
OK, today is my last day online for six weeks, so Alessio, please come up with a fix and push straight to Linus once consensus is reached.
If that's impossible, I'll review when I get back.
Thanks,
Rusty.
Signature · 1 line
How could I marry someone with more hair than me? http://baldalex.org
Re: [PATCH] modpost: Fix modpost's license checking V3
Quoted 11 lines · Rusty Russell
Quoted 2 lines · Frank Rowand
The attached patch modifies your patch to also use
export_from_secname()for vmlinux and vmlinux.o.OK, today is my last day online for six weeks, so Alessio, please come up with a fix and push straight to Linus once consensus is reached.
If that's impossible, I'll review when I get back.
Thanks,
Rusty.
Linus,
Alessio asked me to send this directly to you.
-Frank
The commit f02e8a6 sorts symbols placing each of them in its own elf section. The sorting and merging into the canonical sections are done by the linker. Unfortunately modpost to generate Module.symvers file parses vmlinux.o (which is not linked yet) and all modules object files (which aren't linked yet). These aren't sanitized by the linker yet. That breaks modpost that can't detect license properly for modules.
This patch makes modpost aware of the new exported symbols structure.
The above is a slightly corrected version of the explanation of the problem, copied from commit 62a26356. That commit fixed the problem for module object files, but not for vmlinux.o. This patch fixes modpost for vmlinux.o.
---
scripts/mod/modpost.c | 7 5 + 2 - 0 ! scripts/mod/modpost.h | 1 1 + 0 - 0 ! 2 files changed, 6 insertions(+), 2 deletions(-)
scripts/mod/modpost.c +5 -2
@@ -132,8 +132,10 @@ static struct module *new_module(char *m/* strip trailing .o */ s =strrchr (p,'.' );if (s !=NULL ) -if (strcmp (s,".o" ) ==0 ) +if (strcmp (s,".o" ) ==0 ) { *s ='\0' ; + mod->is_dot_o =1 ; + }/* add to list */ mod->name = p;
@@ -587,7 +589,8 @@ static void handle_modversions(struct mounsigned int crc;enum export export; -if (!is_vmlinux (mod->name) &&strncmp (symname,"__ksymtab" ,9 ) ==0 ) +if ((!is_vmlinux (mod->name) || mod->is_dot_o) && +strncmp (symname,"__ksymtab" ,9 ) ==0 ) export =export_from_secname (info,get_secindex (info, sym));else export =export_from_sec (info,get_secindex (info, sym));
scripts/mod/modpost.h +1 -0
@@ -113,6 +113,7 @@ struct module {int has_cleanup;struct buffer dev_table_buf;char srcversion[25 ]; +int is_dot_o; };struct elf_info {