require EXPORT_SYMBOL_GPL symbols for symbol_get v2
Subsystems (12)
Hi all,
this series changes symbol_get to only work on EXPORT_SYMBOL_GPL as nvidia is abusing the lack of this check to bypass restrictions on importing symbols from proprietary modules.
Changes since v1:
- stop using symbol_get for sharpsl_pm.c (Arnd)
- stop using symbol_get for au1xmmc platform irq handlers
- better (and simpler) error reporting
Diffstat:
arch/arm/mach-pxa/sharpsl_pm.c | 2 -- arch/arm/mach-pxa/spitz.c | 14 +------------- arch/mips/alchemy/devboards/db1000.c | 8 +------- arch/mips/alchemy/devboards/db1200.c | 19 ++----------------- arch/mips/alchemy/devboards/db1300.c | 10 +--------- drivers/mmc/host/Kconfig | 4 ++-- drivers/net/ethernet/freescale/enetc/enetc_ptp.c | 2 +- drivers/rtc/rtc-ds1685.c | 2 +- kernel/module/main.c | 14 +++++++++++--- 9 files changed, 20 insertions(+), 55 deletions(-)
PATCH 1/5 ARM: pxa: remove use of symbol_get()
From: Arnd Bergmann <[email protected]>
The spitz board file uses the obscure symbol_get() function to optionally call a function from sharpsl_pm.c if that is built. However, the two files are always built together these days, and have been for a long time, so this can be changed to a normal function call.
--- arch/arm/mach-pxa/sharpsl_pm.c | 2 -- arch/arm/mach-pxa/spitz.c | 14 +------------- 2 files changed, 1 insertion(+), 15 deletions(-)
arch/arm/mach-pxa/sharpsl_pm.c +0 -2
@@ -216,8 +216,6 @@ void sharpsl_battery_kick(void) {schedule_delayed_work (&sharpsl_bat,msecs_to_jiffies (125 )); } -EXPORT_SYMBOL (sharpsl_battery_kick); -static void sharpsl_battery_thread (struct work_struct *private_) {
arch/arm/mach-pxa/spitz.c +1 -13
@@ -9,7 +9,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> /* symbol_get ; symbol_put */ #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/gpio_keys.h>
@@ -518,17 +517,6 @@ static struct gpiod_lookup_table spitz_ads7846_gpio_table = { }, }; -static void spitz_bl_kick_battery (void ) -{ -void (*kick_batt)(void ); - - kick_batt =symbol_get (sharpsl_battery_kick); -if (kick_batt) { -kick_batt (); -symbol_put (sharpsl_battery_kick); - } -} -static struct gpiod_lookup_table spitz_lcdcon_gpio_table = { .dev_id ="spi2.1" , .table = {
@@ -556,7 +544,7 @@ static struct corgi_lcd_platform_data spitz_lcdcon_info = { .max_intensity = 0x2f, .default_intensity = 0x1f, .limit_mask = 0x0b, - .kick_battery = spitz_bl_kick_battery, + .kick_battery = sharpsl_battery_kick, };static struct spi_board_info spitz_spi_devices[] = {
Signature · 1 line
2.39.2
PATCH 2/5 mmc: au1xmmc: force non-modular build and remove symbol_get usage
In reply to Christoph Hellwigau1xmmc is split somewhat awkwardly into the main mmc subsystem driver, and callbacks in platform_data that sit under arch/mips/ and are always built in. The latter than call mmc_detect_change through symbol_get. Remove the use of symbol_get by requiring the driver to be built in. In the future the interrupt handlers for card insert/eject detection should probably be moved into the main driver, and which point it can be built modular again.
--- arch/mips/alchemy/devboards/db1000.c | 8 +------- arch/mips/alchemy/devboards/db1200.c | 19 ++----------------- arch/mips/alchemy/devboards/db1300.c | 10 +--------- drivers/mmc/host/Kconfig | 4 ++-- 4 files changed, 6 insertions(+), 35 deletions(-)
arch/mips/alchemy/devboards/db1000.c +1 -7
@@ -14,7 +14,6 @@#include <linux/interrupt.h> #include <linux/leds.h> #include <linux/mmc/host.h> -#include <linux/module.h> #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/spi/spi.h>
@@ -167,12 +166,7 @@ static struct platform_device db1x00_audio_dev = {static irqreturn_t db1100_mmc_cd (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); -/* link against CONFIG_MMC=m */ - mmc_cd =symbol_get (mmc_detect_change); -mmc_cd (ptr,msecs_to_jiffies (500 )); -symbol_put (mmc_detect_change); - +mmc_detect_change (ptr,msecs_to_jiffies (500 ));return IRQ_HANDLED ; }
arch/mips/alchemy/devboards/db1200.c +2 -17
@@ -10,7 +10,6 @@#include <linux/gpio.h> #include <linux/i2c.h> #include <linux/init.h> -#include <linux/module.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/leds.h>
@@ -340,14 +339,7 @@ static irqreturn_t db1200_mmc_cd(int irq, void *ptr)static irqreturn_t db1200_mmc_cdfn (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); - -/* link against CONFIG_MMC=m */ - mmc_cd =symbol_get (mmc_detect_change); -if (mmc_cd) { -mmc_cd (ptr,msecs_to_jiffies (200 )); -symbol_put (mmc_detect_change); - } +mmc_detect_change (ptr,msecs_to_jiffies (200 ));msleep (100 );/* debounce */ if (irq ==DB1200_SD0_INSERT_INT )
@@ -431,14 +423,7 @@ static irqreturn_t pb1200_mmc1_cd(int irq, void *ptr)static irqreturn_t pb1200_mmc1_cdfn (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); - -/* link against CONFIG_MMC=m */ - mmc_cd =symbol_get (mmc_detect_change); -if (mmc_cd) { -mmc_cd (ptr,msecs_to_jiffies (200 )); -symbol_put (mmc_detect_change); - } +mmc_detect_change (ptr,msecs_to_jiffies (200 ));msleep (100 );/* debounce */ if (irq ==PB1200_SD1_INSERT_INT )
arch/mips/alchemy/devboards/db1300.c +1 -9
@@ -17,7 +17,6 @@#include <linux/interrupt.h> #include <linux/ata_platform.h> #include <linux/mmc/host.h> -#include <linux/module.h> #include <linux/mtd/mtd.h> #include <linux/mtd/platnand.h> #include <linux/platform_device.h>
@@ -459,14 +458,7 @@ static irqreturn_t db1300_mmc_cd(int irq, void *ptr)static irqreturn_t db1300_mmc_cdfn (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); - -/* link against CONFIG_MMC=m. We can only be called once MMC core has -* initialized the controller, so symbol_get() should always succeed. -*/ - mmc_cd =symbol_get (mmc_detect_change); -mmc_cd (ptr,msecs_to_jiffies (200 )); -symbol_put (mmc_detect_change); +mmc_detect_change (ptr,msecs_to_jiffies (200 ));msleep (100 );/* debounce */ if (irq ==DB1300_SD1_INSERT_INT )
drivers/mmc/host/Kconfig +2 -2
@@ -526,11 +526,11 @@ config MMC_ALCOR of Alcor Micro PCI-E card reader config MMC_AU1X - tristate "Alchemy AU1XX0 MMC Card Interface support" + bool "Alchemy AU1XX0 MMC Card Interface support" depends on MIPS_ALCHEMY help This selects the AMD Alchemy(R) Multimedia card interface. - If you have a Alchemy platform with a MMC slot, say Y or M here. + If you have a Alchemy platform with a MMC slot, say Y here. If unsure, say N.
Signature · 1 line
2.39.2
Re: [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage
Quoted 8 lines · Christoph Hellwig
au1xmmc is split somewhat awkwardly into the main mmc subsystem driver, and callbacks in
platform_datathat sit underarch/mips/and are always built in. The latter than callmmc_detect_changethroughsymbol_get. Remove the use ofsymbol_getby requiring the driver to be built in. In the future the interrupt handlers for card insert/eject detection should probably be moved into the main driver, and which point it can be built modular again.
The carddetection stuff is entirely system-specific, I don't want the driver littered with board-custom stuff; I'm fine with it being built-in only.
Quoted 7 lines
Signed-off-by Christoph Hellwig <[email protected]>--- arch/mips/alchemy/devboards/db1000.c | 8 +------- arch/mips/alchemy/devboards/db1200.c | 19 ++----------------- arch/mips/alchemy/devboards/db1300.c | 10 +--------- drivers/mmc/host/Kconfig | 4 ++-- 4 files changed, 6 insertions(+), 35 deletions(-)
Ok For me. If it matters:
Thanks!
Manuel
Re: [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
au1xmmc is split somewhat awkwardly into the main mmc subsystem driver, and callbacks in
platform_datathat sit underarch/mips/and are always built in. The latter than callmmc_detect_changethroughsymbol_get. Remove the use ofsymbol_getby requiring the driver to be built in. In the future the interrupt handlers for card insert/eject detection should probably be moved into the main driver, and which point it can be built modular again.Signed-off-by Christoph Hellwig <[email protected]>
Good idea.
drivers/mmc/host/Kconfig config MMC_ALCOR · line 531
Quoted 7 lines
drivers/mmc/host/Kconfig +1
-1of Alcor Micro PCI-E card reader config MMC_AU1X - tristate "Alchemy AU1XX0 MMC Card Interface support" + bool "Alchemy AU1XX0 MMC Card Interface support" depends on MIPS_ALCHEMY help
This needs a
depends on MMC=y
otherwise you get a link failure with CONFIG_MMC=m and CONFIG_MMC_AU1X=y.
With that fixed,
Re: [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage
In reply to Christoph HellwigQuoted 10 lines · Christoph Hellwig
au1xmmc is split somewhat awkwardly into the main mmc subsystem driver, and callbacks in
platform_datathat sit underarch/mips/and are always built in. The latter than callmmc_detect_changethroughsymbol_get. Remove the use ofsymbol_getby requiring the driver to be built in. In the future the interrupt handlers for card insert/eject detection should probably be moved into the main driver, and which point it can be built modular again.Signed-off-by Christoph Hellwig <[email protected]>
If not too late, feel free to add:
Kind regards
Uffe
Quoted 124 lines
--- arch/mips/alchemy/devboards/db1000.c | 8 +------- arch/mips/alchemy/devboards/db1200.c | 19 ++----------------- arch/mips/alchemy/devboards/db1300.c | 10 +--------- drivers/mmc/host/Kconfig | 4 ++-- 4 files changed, 6 insertions(+), 35 deletions(-)arch/mips/alchemy/devboards/db1000.c +1
-7@@ -14,7 +14,6 @@#include <linux/interrupt.h> #include <linux/leds.h> #include <linux/mmc/host.h> -#include <linux/module.h> #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/spi/spi.h> @@ -167,12 +166,7 @@ static struct platform_device db1x00_audio_dev = {static irqreturn_t db1100_mmc_cd (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); -/* link against CONFIG_MMC=m */ - mmc_cd =symbol_get (mmc_detect_change); -mmc_cd (ptr,msecs_to_jiffies (500 )); -symbol_put (mmc_detect_change); - +mmc_detect_change (ptr,msecs_to_jiffies (500 ));return IRQ_HANDLED ; }arch/mips/alchemy/devboards/db1200.c +2
-17@@ -10,7 +10,6 @@#include <linux/gpio.h> #include <linux/i2c.h> #include <linux/init.h> -#include <linux/module.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/leds.h> @@ -340,14 +339,7 @@ static irqreturn_t db1200_mmc_cd(int irq, void *ptr)static irqreturn_t db1200_mmc_cdfn (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); - -/* link against CONFIG_MMC=m */ - mmc_cd =symbol_get (mmc_detect_change); -if (mmc_cd) { -mmc_cd (ptr,msecs_to_jiffies (200 )); -symbol_put (mmc_detect_change); - } +mmc_detect_change (ptr,msecs_to_jiffies (200 ));msleep (100 );/* debounce */ if (irq ==DB1200_SD0_INSERT_INT )@@ -431,14 +423,7 @@ static irqreturn_t pb1200_mmc1_cd(int irq, void *ptr)static irqreturn_t pb1200_mmc1_cdfn (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); - -/* link against CONFIG_MMC=m */ - mmc_cd =symbol_get (mmc_detect_change); -if (mmc_cd) { -mmc_cd (ptr,msecs_to_jiffies (200 )); -symbol_put (mmc_detect_change); - } +mmc_detect_change (ptr,msecs_to_jiffies (200 ));msleep (100 );/* debounce */ if (irq ==PB1200_SD1_INSERT_INT )arch/mips/alchemy/devboards/db1300.c +1
-9@@ -17,7 +17,6 @@#include <linux/interrupt.h> #include <linux/ata_platform.h> #include <linux/mmc/host.h> -#include <linux/module.h> #include <linux/mtd/mtd.h> #include <linux/mtd/platnand.h> #include <linux/platform_device.h> @@ -459,14 +458,7 @@ static irqreturn_t db1300_mmc_cd(int irq, void *ptr)static irqreturn_t db1300_mmc_cdfn (int irq,void *ptr) { -void (*mmc_cd)(struct mmc_host *,unsigned long ); - -/* link against CONFIG_MMC=m. We can only be called once MMC core has -* initialized the controller, so symbol_get() should always succeed. -*/ - mmc_cd =symbol_get (mmc_detect_change); -mmc_cd (ptr,msecs_to_jiffies (200 )); -symbol_put (mmc_detect_change); +mmc_detect_change (ptr,msecs_to_jiffies (200 ));msleep (100 );/* debounce */ if (irq ==DB1300_SD1_INSERT_INT )drivers/mmc/host/Kconfig +2
-3@@ -526,11 +526,11 @@ config MMC_ALCOR of Alcor Micro PCI-E card reader config MMC_AU1X - tristate "Alchemy AU1XX0 MMC Card Interface support" + bool "Alchemy AU1XX0 MMC Card Interface support" depends on MIPS_ALCHEMY help This selects the AMD Alchemy(R) Multimedia card interface. - If you have a Alchemy platform with a MMC slot, say Y or M here. + If you have a Alchemy platform with a MMC slot, say Y here. If unsure, say N. --
Quoted 2 lines
2.39.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/5 net: enetc: use EXPORT_SYMBOL_GPL for enetc_phc_index
In reply to Christoph Hellwigenetc_phc_index is only used via symbol_get, which was only ever intended for very internal symbols like this one. Use EXPORT_SYMBOL_GPL for it so that symbol_get can enforce only being used on EXPORT_SYMBOL_GPL symbols.
--- drivers/net/ethernet/freescale/enetc/enetc_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc_ptp.c +1 -1
@@ -8,7 +8,7 @@#include "enetc.h" int enetc_phc_index =-1 ; -EXPORT_SYMBOL (enetc_phc_index); +EXPORT_SYMBOL_GPL (enetc_phc_index);static struct ptp_clock_info enetc_ptp_caps = { .owner =THIS_MODULE ,
Signature · 1 line
2.39.2
PATCH 4/5 rtc: ds1685: use EXPORT_SYMBOL_GPL for ds1685_rtc_poweroff
In reply to Christoph Hellwigds1685_rtc_poweroff is only used externally via symbol_get, which was only ever intended for very internal symbols like this one. Use EXPORT_SYMBOL_GPL for it so that symbol_get can enforce only being used on EXPORT_SYMBOL_GPL symbols.
--- drivers/rtc/rtc-ds1685.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1685.c +1 -1
@@ -1432,7 +1432,7 @@ ds1685_rtc_poweroff(struct platform_device *pdev)unreachable (); } } -EXPORT_SYMBOL (ds1685_rtc_poweroff); +EXPORT_SYMBOL_GPL (ds1685_rtc_poweroff);/* ----------------------------------------------------------------------- */
Signature · 1 line
2.39.2
PATCH 5/5 modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
In reply to Christoph HellwigIt has recently come to my attention that nvidia is circumventing the protection added in 262e6ae7081d ("modules: inherit TAINT_PROPRIETARY_MODULE") by importing exports from their proprietary modules into an allegedly GPL licensed module and then rexporting them.
Given that symbol_get was only ever intended for tightly cooperating modules using very internal symbols it is logical to restrict it to being used on EXPORT_SYMBOL_GPL and prevent nvidia from costly DMCA Circumvention of Access Controls law suites.
All symbols except for four used through symbol_get were already exported as EXPORT_SYMBOL_GPL, and the remaining four ones were switched over in the preparation patches.
--- kernel/module/main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
kernel/module/main.c +11 -3
@@ -1295,12 +1295,20 @@ void *__symbol_get(const char *symbol) };preempt_disable (); -if (!find_symbol (&fsa) ||strong_try_module_get (fsa.owner)) { -preempt_enable (); -return NULL ; +if (!find_symbol (&fsa)) + goto fail; +if (fsa.license !=GPL_ONLY ) { +pr_warn ("failing symbol_get of non-GPLONLY symbol %s.\n" , + symbol); + goto fail; } +if (strong_try_module_get (fsa.owner)) + goto fail;preempt_enable ();return (void *)kernel_symbol_value (fsa.sym); +fail: +preempt_enable (); +return NULL ; }EXPORT_SYMBOL_GPL (__symbol_get);
Signature · 1 line
2.39.2
Re: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
Quoted 9 lines · Christoph Hellwig
It has recently come to my attention that nvidia is circumventing the protection added in
262e6ae7081d("modules: inheritTAINT_PROPRIETARY_MODULE") by importing exports from their proprietary modules into an allegedly GPL licensed module and then rexporting them.Given that
symbol_getwas only ever intended for tightly cooperating modules using very internal symbols it is logical to restrict it to being used onEXPORT_SYMBOL_GPLand prevent nvidia from costly DMCA Circumvention of Access Controls law suites.
I'm all for insisting that everything be exported with EXPORT_SYMBOL_GPL and nothing at all ever be exported with just EXPORT_SYMBOL.
But if we're going to tolerate the core kernel still exporting some stuff with EXPORT_SYMBOL, why isn't OK for a GPL-licensed module do to the same? Even an *in-tree* GPL-licensed module now can't export functionality with EXPORT_SYMBOL and have it used with symbol_get().
We're forced to *either* allow direct linking by non-GPL modules, or allow symbol_get(), but not both?
Quoted 1 line
Fixes 262e6ae7081d ("modules: inherit TAINT_PROPRIETARY_MODULE")
Hm, the condition we really need to fix *that* is "symbol_get() will only import symbols from GPL-licensed modules", isn't it?
As long as that property is correctly transitive, why does the symbol itself have to be EXPORT_SYMBOL_GPL instead of EXPORT_SYMBOL? Am I missing another potential loophole?
I suppose there's now scope for a different type of shim which *directly* imports an EXPORT_SYMBOL function in order to export it again as EXPORT_SYMBOL_GPL and thus allow the GPL export to be found with symbol_get()?
That's the *converse* of the problematic shim that was being used before, and from a licensing point of view it seems fine... it's just working around the unintended side-effects of this patch?
Re: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
Quoted 5 lines · David Woodhouse
But if we're going to tolerate the core kernel still exporting some stuff with
EXPORT_SYMBOL, why isn't OK for a GPL-licensed module do to the same? Even an *in-tree* GPL-licensed module now can't export functionality withEXPORT_SYMBOLand have it used withsymbol_get().
Anything using symbol_get is by intent very deeply internal for tightly coupled modules working together, and thus not a non-GPL export.
In fact the current series is just a stepping stone. Once some mess in the kvm/vfio integration is fixed up we'll require a new explicit EXPORT_SYMBOL variant as symbol_get wasn't ever intended to be used on totally random symbols not exported for use by symbol_get.
Luis Chamberlain
maintainerRe: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · David Woodhouse
But if we're going to tolerate the core kernel still exporting some stuff with
EXPORT_SYMBOL, why isn't OK for a GPL-licensed module do to the same? Even an *in-tree* GPL-licensed module now can't export functionality withEXPORT_SYMBOLand have it used withsymbol_get().
Quoted 7 lines
Anything using
symbol_getis by intent very deeply internal for tightly coupled modules working together, and thus not a non-GPL export.In fact the current series is just a stepping stone. Once some mess in the kvm/vfio integration is fixed up we'll require a new explicit
EXPORT_SYMBOLvariant assymbol_getwasn't ever intended to be used on totally random symbols not exported for use bysymbol_get.
The later patches in the series also show we could resolves most uses through Kconfig and at build time, it really begs the question if we even need it for any real valid uses.
Luis
Quoted 5 lines · Christoph Hellwig
Hi all,
this series changes
symbol_getto only work onEXPORT_SYMBOL_GPLas nvidia is abusing the lack of this check to bypass restrictions on importing symbols from proprietary modules.
Let me know if you want this to go through the modules tree or your own.
Luis
Quoted 10 lines · Luis Chamberlain
Quoted 5 lines · Christoph Hellwig
Hi all,
this series changes
symbol_getto only work onEXPORT_SYMBOL_GPLas nvidia is abusing the lack of this check to bypass restrictions on importing symbols from proprietary modules.Reviewed-by Luis Chamberlain <[email protected]>Let me know if you want this to go through the modules tree or your own.
I don't think this would fit anywhere but the modules tree.
Let me know if you want me to resend for the mmc dependency fixup or if you want to squash it yourself.
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Luis Chamberlain
Quoted 5 lines · Christoph Hellwig
Hi all,
this series changes
symbol_getto only work onEXPORT_SYMBOL_GPLas nvidia is abusing the lack of this check to bypass restrictions on importing symbols from proprietary modules.
Quoted 5 lines
Quoted 3 lines
Reviewed-by Luis Chamberlain <[email protected]>Let me know if you want this to go through the modules tree or your own.
I don't think this would fit anywhere but the modules tree.
OK sure!
Quoted 2 lines
Let me know if you want me to resend for the mmc dependency fixup or if you want to squash it yourself.
Applied, I squashed the depends on MMC=y as suggested by Arnd and pushed out to modules-next.`
Luis