* [RFC] EXPORT_SYMBOL_GPL_FUTURE()
@ 2006-02-08 6:20 Greg KH
2006-02-08 7:33 ` Andrew Morton
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Greg KH @ 2006-02-08 6:20 UTC (permalink / raw)
To: linux-kernel
Currently we don't have a way to show people that some kernel symbols
will be changed in the future from EXPORT_SYMBOL() to
EXPORT_SYMBOL_GPL(). As we all know, not everyone reads the
Documentation/feature_removal.txt file, so we need a bigger way to
remind people.
So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE(). It
basically says that some time in the future, this symbol is going to
change and not be allowed to be called from non-GPL licensed kernel
modules.
Now I'm not wed to the name, so if anyone else has a better suggestion
as to what to call this, please let me know. I also feel that the text
that is spit out to the kernel log is a bit stilted, so again,
suggestions welcome.
Comments?
I only implemented this for those arches and sub-arches that use the
asm-generic/vmlinux.lds.h file. I think there are still a few others
out there that do not do this, so I'll have to fix them up too for the
final version of this patch.
thanks,
greg k-h
---------------------
From: Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH] add EXPORT_SYMBOL_GPL_FUTURE()
This patch adds the ability to mark symbols that will be changed in the
future, so that non-GPL usage of them is flagged by the kernel and
printed out to the system log.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
include/asm-generic/vmlinux.lds.h | 14 ++++++++++++
include/linux/module.h | 8 +++++++
kernel/module.c | 36 +++++++++++++++++++++++++++++++--
--- gregkh-2.6.orig/include/asm-generic/vmlinux.lds.h
+++ gregkh-2.6/include/asm-generic/vmlinux.lds.h
@@ -58,6 +58,13 @@
VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
} \
\
+ /* Kernel symbol table: GPL-future-only symbols */ \
+ __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
+ VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
+ *(__ksymtab_gpl_future) \
+ VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
+ } \
+ \
/* Kernel symbol table: Normal symbols */ \
__kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
VMLINUX_SYMBOL(__start___kcrctab) = .; \
@@ -72,6 +79,13 @@
VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
} \
\
+ /* Kernel symbol table: GPL-only symbols */ \
+ __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
+ VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
+ *(__kcrctab_gpl_future) \
+ VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
+ } \
+ \
/* Kernel symbol table: strings */ \
__ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
*(__ksymtab_strings) \
--- gregkh-2.6.orig/include/linux/module.h
+++ gregkh-2.6/include/linux/module.h
@@ -198,6 +198,9 @@ void *__symbol_get_gpl(const char *symbo
#define EXPORT_SYMBOL_GPL(sym) \
__EXPORT_SYMBOL(sym, "_gpl")
+#define EXPORT_SYMBOL_GPL_FUTURE(sym) \
+ __EXPORT_SYMBOL(sym, "_gpl_future")
+
#endif
struct module_ref
@@ -255,6 +258,11 @@ struct module
unsigned int num_gpl_syms;
const unsigned long *gpl_crcs;
+ /* symbols that will be GPL-only in the near future. */
+ const struct kernel_symbol *gpl_future_syms;
+ unsigned int num_gpl_future_syms;
+ const unsigned long *gpl_future_crcs;
+
/* Exception table */
unsigned int num_exentries;
const struct exception_table_entry *extable;
--- gregkh-2.6.orig/kernel/module.c
+++ gregkh-2.6/kernel/module.c
@@ -126,8 +126,11 @@ extern const struct kernel_symbol __star
extern const struct kernel_symbol __stop___ksymtab[];
extern const struct kernel_symbol __start___ksymtab_gpl[];
extern const struct kernel_symbol __stop___ksymtab_gpl[];
+extern const struct kernel_symbol __start___ksymtab_gpl_future[];
+extern const struct kernel_symbol __stop___ksymtab_gpl_future[];
extern const unsigned long __start___kcrctab[];
extern const unsigned long __start___kcrctab_gpl[];
+extern const unsigned long __start___kcrctab_gpl_future[];
#ifndef CONFIG_MODVERSIONS
#define symversion(base, idx) NULL
@@ -159,6 +162,16 @@ static unsigned long __find_symbol(const
return __start___ksymtab_gpl[i].value;
}
}
+ for (i = 0; __start___ksymtab_gpl_future+i < __stop___ksymtab_gpl_future; i++) {
+ if (strcmp(__start___ksymtab_gpl_future[i].name, name) == 0) {
+ *crc = symversion(__start___kcrctab_gpl_future, i);
+ if (!gplok)
+ printk(KERN_WARNING "symbol %s is being used "
+ "by a non-GPL module, which will not "
+ "be allowed in the future\n", name);
+ return __start___ksymtab_gpl_future[i].value;
+ }
+ }
/* Now try modules. */
list_for_each_entry(mod, &modules, list) {
@@ -177,6 +190,16 @@ static unsigned long __find_symbol(const
}
}
}
+ for (i = 0; i < mod->num_gpl_future_syms; i++) {
+ if (strcmp(mod->gpl_future_syms[i].name, name) == 0) {
+ *crc = symversion(mod->gpl_future_crcs, i);
+ if (!gplok)
+ printk(KERN_WARNING "symbol %s is being used "
+ "by a non-GPL module, which will not "
+ "be allowed in the future\n", name);
+ return mod->gpl_future_syms[i].value;
+ }
+ }
}
DEBUGP("Failed to find symbol %s\n", name);
return 0;
@@ -1537,7 +1560,8 @@ static struct module *load_module(void _
char *secstrings, *args, *modmagic, *strtab = NULL;
unsigned int i, symindex = 0, strindex = 0, setupindex, exindex,
exportindex, modindex, obsparmindex, infoindex, gplindex,
- crcindex, gplcrcindex, versindex, pcpuindex;
+ crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex,
+ gplfuturecrcindex;
long arglen;
struct module *mod;
long err = 0;
@@ -1618,8 +1642,10 @@ static struct module *load_module(void _
/* Optional sections */
exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab");
gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl");
+ gplfutureindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl_future");
crcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab");
gplcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl");
+ gplfuturecrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl_future");
setupindex = find_sec(hdr, sechdrs, secstrings, "__param");
exindex = find_sec(hdr, sechdrs, secstrings, "__ex_table");
obsparmindex = find_sec(hdr, sechdrs, secstrings, "__obsparm");
@@ -1772,10 +1798,16 @@ static struct module *load_module(void _
mod->gpl_syms = (void *)sechdrs[gplindex].sh_addr;
if (gplcrcindex)
mod->gpl_crcs = (void *)sechdrs[gplcrcindex].sh_addr;
+ mod->num_gpl_future_syms = sechdrs[gplfutureindex].sh_size /
+ sizeof(*mod->gpl_future_syms);
+ mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr;
+ if (gplfuturecrcindex)
+ mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr;
#ifdef CONFIG_MODVERSIONS
if ((mod->num_syms && !crcindex) ||
- (mod->num_gpl_syms && !gplcrcindex)) {
+ (mod->num_gpl_syms && !gplcrcindex) ||
+ (mod->num_gpl_future_syms && !gplfuturecrcindex)) {
printk(KERN_WARNING "%s: No versions for exported symbols."
" Tainting kernel.\n", mod->name);
add_taint(TAINT_FORCED_MODULE);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-08 6:20 [RFC] EXPORT_SYMBOL_GPL_FUTURE() Greg KH
@ 2006-02-08 7:33 ` Andrew Morton
2006-02-08 17:36 ` Greg KH
2006-02-08 14:23 ` Alan Cox
2006-02-12 2:34 ` Mark Lord
2 siblings, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2006-02-08 7:33 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
Greg KH <gregkh@suse.de> wrote:
>
> + printk(KERN_WARNING "symbol %s is being used "
> + "by a non-GPL module, which will not "
> + "be allowed in the future\n", name);
"See Documentation/feature-removal.txt for details".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-08 6:20 [RFC] EXPORT_SYMBOL_GPL_FUTURE() Greg KH
2006-02-08 7:33 ` Andrew Morton
@ 2006-02-08 14:23 ` Alan Cox
2006-02-08 17:42 ` Greg KH
2006-02-12 2:34 ` Mark Lord
2 siblings, 1 reply; 11+ messages in thread
From: Alan Cox @ 2006-02-08 14:23 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On Maw, 2006-02-07 at 22:20 -0800, Greg KH wrote:
> Currently we don't have a way to show people that some kernel symbols
> will be changed in the future from EXPORT_SYMBOL() to
> EXPORT_SYMBOL_GPL().
For a good reason. When Linus first accepted the _GPL changes he did so
on the clear understanding that people wouldn't go around "privatising"
existing symbols.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-08 7:33 ` Andrew Morton
@ 2006-02-08 17:36 ` Greg KH
0 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2006-02-08 17:36 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
On Tue, Feb 07, 2006 at 11:33:18PM -0800, Andrew Morton wrote:
> Greg KH <gregkh@suse.de> wrote:
> >
> > + printk(KERN_WARNING "symbol %s is being used "
> > + "by a non-GPL module, which will not "
> > + "be allowed in the future\n", name);
>
> "See Documentation/feature-removal.txt for details".
Doh, that makes more sense :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-08 14:23 ` Alan Cox
@ 2006-02-08 17:42 ` Greg KH
2006-02-08 18:38 ` Alan Cox
0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2006-02-08 17:42 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel
On Wed, Feb 08, 2006 at 02:23:49PM +0000, Alan Cox wrote:
> On Maw, 2006-02-07 at 22:20 -0800, Greg KH wrote:
> > Currently we don't have a way to show people that some kernel symbols
> > will be changed in the future from EXPORT_SYMBOL() to
> > EXPORT_SYMBOL_GPL().
>
> For a good reason. When Linus first accepted the _GPL changes he did so
> on the clear understanding that people wouldn't go around "privatising"
> existing symbols.
But look at Documentation/feature-removal-schedule.txt:
What: RCU API moves to EXPORT_SYMBOL_GPL
When: April 2006
Files: include/linux/rcupdate.h, kernel/rcupdate.c
Why: Outside of Linux, the only implementations of anything even
vaguely resembling RCU that I am aware of are in DYNIX/ptx,
VM/XA, Tornado, and K42. I do not expect anyone to port binary
drivers or kernel modules from any of these, since the first two
are owned by IBM and the last two are open-source research OSes.
So these will move to GPL after a grace period to allow
people, who might be using implementations that I am not aware
of, to adjust to this upcoming change.
Who: Paul E. McKenney <paulmck@us.ibm.com>
That's just one example.
The other example, and is what just happened last week, is for the USB
api. We have changed enough over the years to cause a new function
call to be created, yet we offered a inline function to help with the
transition. That new function was marked EXPORT_SYMBOL_GPL() as the USB
developers feel there has been enough change to warrant this marking.
Also because they provide a way for userspace USB drivers to be written
for those that want to do closed source stuff.
So, no matter how it is marked in this text file, people will miss it.
If we complain in the syslog, it makes it very hard to miss it, and will
allow people notice to be able to port stuff properly.
In short, due to the lack of the "unstable/stable" series cycle, we
don't have a method to mark stuff GPL only that will give enough
exposure. This patch provides it.
I'll repost the series based on the comments in this thread, and stuff
that others have sent me privately.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-08 17:42 ` Greg KH
@ 2006-02-08 18:38 ` Alan Cox
0 siblings, 0 replies; 11+ messages in thread
From: Alan Cox @ 2006-02-08 18:38 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On Mer, 2006-02-08 at 09:42 -0800, Greg KH wrote:
> > For a good reason. When Linus first accepted the _GPL changes he did so
> > on the clear understanding that people wouldn't go around "privatising"
> > existing symbols.
>
> But look at Documentation/feature-removal-schedule.txt:
RCIU is special. Very special in that it uses patented techniques that
are only avaialble to GPL users without signing licenses with IBM.
The rest of the problem I concur with. I'm simply explaining the
historical background.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-08 6:20 [RFC] EXPORT_SYMBOL_GPL_FUTURE() Greg KH
2006-02-08 7:33 ` Andrew Morton
2006-02-08 14:23 ` Alan Cox
@ 2006-02-12 2:34 ` Mark Lord
2006-02-12 4:15 ` Greg KH
2 siblings, 1 reply; 11+ messages in thread
From: Mark Lord @ 2006-02-12 2:34 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
Greg KH wrote:
>
> So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE(). It
> basically says that some time in the future, this symbol is going to
> change and not be allowed to be called from non-GPL licensed kernel
> modules.
The wording and intent here are incorrect.
All kernel modules are already *GPL licensed*,
whether the authors think so or not.
So this patch (if it goes through), should be reworded
so as not to muddy those waters (as the above excerpt does).
Cheers
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-12 2:34 ` Mark Lord
@ 2006-02-12 4:15 ` Greg KH
2006-02-12 4:18 ` Mark Lord
2006-02-12 4:41 ` Kyle Moffett
0 siblings, 2 replies; 11+ messages in thread
From: Greg KH @ 2006-02-12 4:15 UTC (permalink / raw)
To: Mark Lord; +Cc: linux-kernel
On Sat, Feb 11, 2006 at 09:34:40PM -0500, Mark Lord wrote:
> Greg KH wrote:
> >
> >So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE(). It
> >basically says that some time in the future, this symbol is going to
> >change and not be allowed to be called from non-GPL licensed kernel
> >modules.
>
> The wording and intent here are incorrect.
>
> All kernel modules are already *GPL licensed*,
> whether the authors think so or not.
>
> So this patch (if it goes through), should be reworded
> so as not to muddy those waters (as the above excerpt does).
Care to provide some text that you feel will be better?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-12 4:15 ` Greg KH
@ 2006-02-12 4:18 ` Mark Lord
2006-02-22 5:39 ` Greg KH
2006-02-12 4:41 ` Kyle Moffett
1 sibling, 1 reply; 11+ messages in thread
From: Mark Lord @ 2006-02-12 4:18 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
Greg KH wrote:
> On Sat, Feb 11, 2006 at 09:34:40PM -0500, Mark Lord wrote:
>> Greg KH wrote:
>>> So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE(). It
>>> basically says that some time in the future, this symbol is going to
>>> change and not be allowed to be called from non-GPL licensed kernel
>>> modules.
>> The wording and intent here are incorrect.
>>
>> All kernel modules are already *GPL licensed*,
>> whether the authors think so or not.
>>
>> So this patch (if it goes through), should be reworded
>> so as not to muddy those waters (as the above excerpt does).
>
> Care to provide some text that you feel will be better?
Just something simple, like this rewording of your original post:
>>> So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE(). It
>>> basically says that some time in the future, this symbol is going to
>>> change and not be allowed to be called from
...kernel modules that don't include MODULE_LICENSE("GPL") in the source.
Cheers
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-12 4:15 ` Greg KH
2006-02-12 4:18 ` Mark Lord
@ 2006-02-12 4:41 ` Kyle Moffett
1 sibling, 0 replies; 11+ messages in thread
From: Kyle Moffett @ 2006-02-12 4:41 UTC (permalink / raw)
To: Greg KH; +Cc: Mark Lord, linux-kernel
On Feb 11, 2006, at 23:15, Greg KH wrote:
> On Sat, Feb 11, 2006 at 09:34:40PM -0500, Mark Lord wrote:
>> Greg KH wrote:
>>> So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE().
>>> It basically says that some time in the future, this symbol is
>>> going to change and not be allowed to be called from non-GPL
>>> licensed kernel modules.
>>
>> The wording and intent here are incorrect.
>>
>> All kernel modules are already *GPL licensed*, whether the authors
>> think so or not.
>>
>> So this patch (if it goes through), should be reworded so as not
>> to muddy those waters (as the above excerpt does).
>
> Care to provide some text that you feel will be better?
IANAL, but this or some lawyer-revised derivative might be good for
an official changelog comment (if it ever gets committed):
It was noticed that the source-code restrictions on certain exported
symbols did not match the effective legal restrictions. Therefore,
in the interests of preserving some backwards compatibility with
buggy kernel modules that do not specify a license string or specify
an incorrect license string, this patch creates a new symbol export
macro "EXPORT_SYMBOL_GPL_FUTURE()". This macro causes uses of the
symbol from modules not marked "GPL" to be warned about, so that
module developers may correctly specify a compatible license in their
sources. The set of all symbols flagged this way is no way
exclusive; it's possible that we should flag _all_ presently exported
symbols this way. On the other hand, in the interests of avoiding
thousands of warnings on boot for buggy modules, only some of the
symbols are actually changed to use this new flag. For each instance
of EXPORT_SYMBOL_GPL_FUTURE, ample time (a couple kernel versions or
so) will be provided for for buggy modules to be fixed after which it
will be changed to EXPORT_SYMBOL_GPL.
Cheers,
Kyle Moffett
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCM/CS/IT/E/U d- s++: a18 C++++>$ ULBX*++++(+++)>$ P++++(+++)>$ L++++
(+++)>$ !E- W+++(++) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+ PGP
+ t+(+++) 5 X R? !tv-(--) b++++(++) DI+(++) D+++ G e>++++$ h*(+)>++$ r
%(--) !y?-(--)
------END GEEK CODE BLOCK------
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC] EXPORT_SYMBOL_GPL_FUTURE()
2006-02-12 4:18 ` Mark Lord
@ 2006-02-22 5:39 ` Greg KH
0 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2006-02-22 5:39 UTC (permalink / raw)
To: Mark Lord; +Cc: linux-kernel
On Sat, Feb 11, 2006 at 11:18:06PM -0500, Mark Lord wrote:
> Greg KH wrote:
> >On Sat, Feb 11, 2006 at 09:34:40PM -0500, Mark Lord wrote:
> >>Greg KH wrote:
> >>>So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE(). It
> >>>basically says that some time in the future, this symbol is going to
> >>>change and not be allowed to be called from non-GPL licensed kernel
> >>>modules.
> >>The wording and intent here are incorrect.
> >>
> >>All kernel modules are already *GPL licensed*,
> >>whether the authors think so or not.
> >>
> >>So this patch (if it goes through), should be reworded
> >>so as not to muddy those waters (as the above excerpt does).
> >
> >Care to provide some text that you feel will be better?
>
> Just something simple, like this rewording of your original post:
>
> >>> So, here's a patch that implements EXPORT_SYMBOL_GPL_FUTURE(). It
> >>> basically says that some time in the future, this symbol is going to
> >>> change and not be allowed to be called from
> ...kernel modules that don't include MODULE_LICENSE("GPL") in the source.
Ok, I've tweaked it to look more like this.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-02-22 6:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-08 6:20 [RFC] EXPORT_SYMBOL_GPL_FUTURE() Greg KH
2006-02-08 7:33 ` Andrew Morton
2006-02-08 17:36 ` Greg KH
2006-02-08 14:23 ` Alan Cox
2006-02-08 17:42 ` Greg KH
2006-02-08 18:38 ` Alan Cox
2006-02-12 2:34 ` Mark Lord
2006-02-12 4:15 ` Greg KH
2006-02-12 4:18 ` Mark Lord
2006-02-22 5:39 ` Greg KH
2006-02-12 4:41 ` Kyle Moffett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox