linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* require EXPORT_SYMBOL_GPL symbols for symbol_get v2
@ 2023-08-01 17:35 Christoph Hellwig
  2023-08-01 17:35 ` [PATCH 1/5] ARM: pxa: remove use of symbol_get() Christoph Hellwig
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Christoph Hellwig @ 2023-08-01 17:35 UTC (permalink / raw)
  To: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Manuel Lauss,
	Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

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(-)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/5] ARM: pxa: remove use of symbol_get()
  2023-08-01 17:35 require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Christoph Hellwig
@ 2023-08-01 17:35 ` Christoph Hellwig
  2023-08-01 17:35 ` [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage Christoph Hellwig
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2023-08-01 17:35 UTC (permalink / raw)
  To: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Manuel Lauss,
	Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

From: Arnd Bergmann <arnd@arndb.de>

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.

Link: https://lore.kernel.org/lkml/20230731162639.GA9441@lst.de/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/mach-pxa/sharpsl_pm.c |  2 --
 arch/arm/mach-pxa/spitz.c      | 14 +-------------
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index d29bdcd5270e0f..72fa2e3fd35318 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -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_)
 {
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index d01ea54b0b7820..cc691b199429ca 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -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[] = {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage
  2023-08-01 17:35 require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Christoph Hellwig
  2023-08-01 17:35 ` [PATCH 1/5] ARM: pxa: remove use of symbol_get() Christoph Hellwig
@ 2023-08-01 17:35 ` Christoph Hellwig
  2023-08-02  7:12   ` Manuel Lauss
                     ` (2 more replies)
  2023-08-01 17:35 ` [PATCH 3/5] net: enetc: use EXPORT_SYMBOL_GPL for enetc_phc_index Christoph Hellwig
                   ` (3 subsequent siblings)
  5 siblings, 3 replies; 15+ messages in thread
From: Christoph Hellwig @ 2023-08-01 17:35 UTC (permalink / raw)
  To: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Manuel Lauss,
	Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

au1xmmc 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 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(-)

diff --git a/arch/mips/alchemy/devboards/db1000.c b/arch/mips/alchemy/devboards/db1000.c
index 79d66faa84828d..012da042d0a4f7 100644
--- a/arch/mips/alchemy/devboards/db1000.c
+++ b/arch/mips/alchemy/devboards/db1000.c
@@ -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;
 }
 
diff --git a/arch/mips/alchemy/devboards/db1200.c b/arch/mips/alchemy/devboards/db1200.c
index 1864eb935ca57f..76080c71a2a7b6 100644
--- a/arch/mips/alchemy/devboards/db1200.c
+++ b/arch/mips/alchemy/devboards/db1200.c
@@ -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)
diff --git a/arch/mips/alchemy/devboards/db1300.c b/arch/mips/alchemy/devboards/db1300.c
index e70e529ddd914d..ff61901329c626 100644
--- a/arch/mips/alchemy/devboards/db1300.c
+++ b/arch/mips/alchemy/devboards/db1300.c
@@ -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)
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 159a3e9490aed8..f7afd179dd10bf 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -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.
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/5] net: enetc: use EXPORT_SYMBOL_GPL for enetc_phc_index
  2023-08-01 17:35 require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Christoph Hellwig
  2023-08-01 17:35 ` [PATCH 1/5] ARM: pxa: remove use of symbol_get() Christoph Hellwig
  2023-08-01 17:35 ` [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage Christoph Hellwig
@ 2023-08-01 17:35 ` Christoph Hellwig
  2023-08-01 17:35 ` [PATCH 4/5] rtc: ds1685: use EXPORT_SYMBOL_GPL for ds1685_rtc_poweroff Christoph Hellwig
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2023-08-01 17:35 UTC (permalink / raw)
  To: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Manuel Lauss,
	Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules, Jakub Kicinski

enetc_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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/freescale/enetc/enetc_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ptp.c b/drivers/net/ethernet/freescale/enetc/enetc_ptp.c
index 17c097cef7d45f..5243fc03105890 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_ptp.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_ptp.c
@@ -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,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/5] rtc: ds1685: use EXPORT_SYMBOL_GPL for ds1685_rtc_poweroff
  2023-08-01 17:35 require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Christoph Hellwig
                   ` (2 preceding siblings ...)
  2023-08-01 17:35 ` [PATCH 3/5] net: enetc: use EXPORT_SYMBOL_GPL for enetc_phc_index Christoph Hellwig
@ 2023-08-01 17:35 ` Christoph Hellwig
  2023-08-01 17:35 ` [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules Christoph Hellwig
  2023-08-01 17:45 ` require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Luis Chamberlain
  5 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2023-08-01 17:35 UTC (permalink / raw)
  To: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Manuel Lauss,
	Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

ds1685_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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Joshua Kinard <kumba@gentoo.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/rtc/rtc-ds1685.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c
index 0f707be0eb87fa..04dbf35cf3b706 100644
--- a/drivers/rtc/rtc-ds1685.c
+++ b/drivers/rtc/rtc-ds1685.c
@@ -1432,7 +1432,7 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 		unreachable();
 	}
 }
-EXPORT_SYMBOL(ds1685_rtc_poweroff);
+EXPORT_SYMBOL_GPL(ds1685_rtc_poweroff);
 /* ----------------------------------------------------------------------- */
 
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
  2023-08-01 17:35 require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Christoph Hellwig
                   ` (3 preceding siblings ...)
  2023-08-01 17:35 ` [PATCH 4/5] rtc: ds1685: use EXPORT_SYMBOL_GPL for ds1685_rtc_poweroff Christoph Hellwig
@ 2023-08-01 17:35 ` Christoph Hellwig
  2023-10-18  0:30   ` David Woodhouse
  2023-08-01 17:45 ` require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Luis Chamberlain
  5 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2023-08-01 17:35 UTC (permalink / raw)
  To: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Manuel Lauss,
	Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

It 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.

Fixes: 262e6ae7081d ("modules: inherit TAINT_PROPRIETARY_MODULE")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/module/main.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/kernel/module/main.c b/kernel/module/main.c
index 59b1d067e52890..c395af9eced114 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -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);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: require EXPORT_SYMBOL_GPL symbols for symbol_get v2
  2023-08-01 17:35 require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Christoph Hellwig
                   ` (4 preceding siblings ...)
  2023-08-01 17:35 ` [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules Christoph Hellwig
@ 2023-08-01 17:45 ` Luis Chamberlain
  2023-08-02 11:56   ` Christoph Hellwig
  5 siblings, 1 reply; 15+ messages in thread
From: Luis Chamberlain @ 2023-08-01 17:45 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Greg Kroah-Hartman, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Ulf Hansson, Manuel Lauss, Yangbo Lu, Joshua Kinard,
	Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

On Tue, Aug 01, 2023 at 07:35:39PM +0200, Christoph Hellwig wrote:
> 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.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>

Let me know if you want this to go through the modules tree or your own.

  Luis


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage
  2023-08-01 17:35 ` [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage Christoph Hellwig
@ 2023-08-02  7:12   ` Manuel Lauss
  2023-08-02  8:31   ` Arnd Bergmann
  2023-08-08  9:15   ` Ulf Hansson
  2 siblings, 0 replies; 15+ messages in thread
From: Manuel Lauss @ 2023-08-02  7:12 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Yangbo Lu,
	Joshua Kinard, Daniel Vetter, Arnd Bergmann, linux-arm-kernel,
	open list, linux-mmc, netdev, linux-rtc, linux-modules

On Tue, Aug 1, 2023 at 7:36 PM Christoph Hellwig <hch@lst.de> wrote:
>
> au1xmmc 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.

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.


> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  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:

Acked-by: Manuel Lauss <manuel.lauss@gmail.com>

Thanks!
     Manuel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage
  2023-08-01 17:35 ` [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage Christoph Hellwig
  2023-08-02  7:12   ` Manuel Lauss
@ 2023-08-02  8:31   ` Arnd Bergmann
  2023-08-08  9:15   ` Ulf Hansson
  2 siblings, 0 replies; 15+ messages in thread
From: Arnd Bergmann @ 2023-08-02  8:31 UTC (permalink / raw)
  To: Christoph Hellwig, Luis Chamberlain, Greg Kroah-Hartman,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Ulf Hansson,
	Manuel Lauss, Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, linux-arm-kernel, open list,
	linux-mmc @ vger . kernel . org, Netdev, linux-rtc,
	linux-modules

On Tue, Aug 1, 2023, at 19:35, Christoph Hellwig wrote:
> au1xmmc 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Good idea.

>  	  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 needs a 

      depends on MMC=y

otherwise you get a link failure with CONFIG_MMC=m and
CONFIG_MMC_AU1X=y.

With that fixed,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: require EXPORT_SYMBOL_GPL symbols for symbol_get v2
  2023-08-01 17:45 ` require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Luis Chamberlain
@ 2023-08-02 11:56   ` Christoph Hellwig
  2023-08-02 18:19     ` Luis Chamberlain
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2023-08-02 11:56 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: Christoph Hellwig, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Ulf Hansson, Manuel Lauss,
	Yangbo Lu, Joshua Kinard, Daniel Vetter, Arnd Bergmann,
	linux-arm-kernel, open list, linux-mmc, netdev, linux-rtc,
	linux-modules

On Tue, Aug 01, 2023 at 10:45:34AM -0700, Luis Chamberlain wrote:
> On Tue, Aug 01, 2023 at 07:35:39PM +0200, Christoph Hellwig wrote:
> > 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.
> 
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> 
> 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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: require EXPORT_SYMBOL_GPL symbols for symbol_get v2
  2023-08-02 11:56   ` Christoph Hellwig
@ 2023-08-02 18:19     ` Luis Chamberlain
  0 siblings, 0 replies; 15+ messages in thread
From: Luis Chamberlain @ 2023-08-02 18:19 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Greg Kroah-Hartman, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Ulf Hansson, Manuel Lauss, Yangbo Lu, Joshua Kinard,
	Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

On Wed, Aug 02, 2023 at 01:56:58PM +0200, Christoph Hellwig wrote:
> On Tue, Aug 01, 2023 at 10:45:34AM -0700, Luis Chamberlain wrote:
> > On Tue, Aug 01, 2023 at 07:35:39PM +0200, Christoph Hellwig wrote:
> > > 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.
> > 
> > Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> > 
> > 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!

> 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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage
  2023-08-01 17:35 ` [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage Christoph Hellwig
  2023-08-02  7:12   ` Manuel Lauss
  2023-08-02  8:31   ` Arnd Bergmann
@ 2023-08-08  9:15   ` Ulf Hansson
  2 siblings, 0 replies; 15+ messages in thread
From: Ulf Hansson @ 2023-08-08  9:15 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Luis Chamberlain, Greg Kroah-Hartman, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Manuel Lauss, Yangbo Lu,
	Joshua Kinard, Daniel Vetter, Arnd Bergmann, linux-arm-kernel,
	open list, linux-mmc, netdev, linux-rtc, linux-modules

On Tue, 1 Aug 2023 at 19:36, Christoph Hellwig <hch@lst.de> wrote:
>
> au1xmmc 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

If not too late, feel free to add:

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  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(-)
>
> diff --git a/arch/mips/alchemy/devboards/db1000.c b/arch/mips/alchemy/devboards/db1000.c
> index 79d66faa84828d..012da042d0a4f7 100644
> --- a/arch/mips/alchemy/devboards/db1000.c
> +++ b/arch/mips/alchemy/devboards/db1000.c
> @@ -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;
>  }
>
> diff --git a/arch/mips/alchemy/devboards/db1200.c b/arch/mips/alchemy/devboards/db1200.c
> index 1864eb935ca57f..76080c71a2a7b6 100644
> --- a/arch/mips/alchemy/devboards/db1200.c
> +++ b/arch/mips/alchemy/devboards/db1200.c
> @@ -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)
> diff --git a/arch/mips/alchemy/devboards/db1300.c b/arch/mips/alchemy/devboards/db1300.c
> index e70e529ddd914d..ff61901329c626 100644
> --- a/arch/mips/alchemy/devboards/db1300.c
> +++ b/arch/mips/alchemy/devboards/db1300.c
> @@ -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)
> diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> index 159a3e9490aed8..f7afd179dd10bf 100644
> --- a/drivers/mmc/host/Kconfig
> +++ b/drivers/mmc/host/Kconfig
> @@ -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.
>
> --
> 2.39.2
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
  2023-08-01 17:35 ` [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules Christoph Hellwig
@ 2023-10-18  0:30   ` David Woodhouse
  2023-10-18  5:31     ` Christoph Hellwig
  0 siblings, 1 reply; 15+ messages in thread
From: David Woodhouse @ 2023-10-18  0:30 UTC (permalink / raw)
  To: Christoph Hellwig, Luis Chamberlain, Greg Kroah-Hartman,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Ulf Hansson,
	Manuel Lauss, Yangbo Lu, Joshua Kinard
  Cc: Daniel Vetter, Arnd Bergmann, linux-arm-kernel, open list,
	linux-mmc, netdev, linux-rtc, linux-modules

[-- Attachment #1: Type: text/plain, Size: 1932 bytes --]

On Tue, 2023-08-01 at 19:35 +0200, Christoph Hellwig wrote:
> It 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.

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?

> 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?

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
  2023-10-18  0:30   ` David Woodhouse
@ 2023-10-18  5:31     ` Christoph Hellwig
  2023-10-18 18:25       ` Luis Chamberlain
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2023-10-18  5:31 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Christoph Hellwig, Luis Chamberlain, Greg Kroah-Hartman,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Ulf Hansson,
	Manuel Lauss, Yangbo Lu, Joshua Kinard, Daniel Vetter,
	Arnd Bergmann, linux-arm-kernel, open list, linux-mmc, netdev,
	linux-rtc, linux-modules

On Wed, Oct 18, 2023 at 01:30:18AM +0100, David Woodhouse wrote:
> 
> 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().

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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
  2023-10-18  5:31     ` Christoph Hellwig
@ 2023-10-18 18:25       ` Luis Chamberlain
  0 siblings, 0 replies; 15+ messages in thread
From: Luis Chamberlain @ 2023-10-18 18:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: David Woodhouse, Greg Kroah-Hartman, Daniel Mack, Haojian Zhuang,
	Robert Jarzmik, Ulf Hansson, Manuel Lauss, Yangbo Lu,
	Joshua Kinard, Daniel Vetter, Arnd Bergmann, linux-arm-kernel,
	open list, linux-mmc, netdev, linux-rtc, linux-modules

On Wed, Oct 18, 2023 at 07:31:46AM +0200, Christoph Hellwig wrote:
> On Wed, Oct 18, 2023 at 01:30:18AM +0100, David Woodhouse wrote:
> > 
> > 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().
> 
> 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.

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-10-18 18:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01 17:35 require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Christoph Hellwig
2023-08-01 17:35 ` [PATCH 1/5] ARM: pxa: remove use of symbol_get() Christoph Hellwig
2023-08-01 17:35 ` [PATCH 2/5] mmc: au1xmmc: force non-modular build and remove symbol_get usage Christoph Hellwig
2023-08-02  7:12   ` Manuel Lauss
2023-08-02  8:31   ` Arnd Bergmann
2023-08-08  9:15   ` Ulf Hansson
2023-08-01 17:35 ` [PATCH 3/5] net: enetc: use EXPORT_SYMBOL_GPL for enetc_phc_index Christoph Hellwig
2023-08-01 17:35 ` [PATCH 4/5] rtc: ds1685: use EXPORT_SYMBOL_GPL for ds1685_rtc_poweroff Christoph Hellwig
2023-08-01 17:35 ` [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules Christoph Hellwig
2023-10-18  0:30   ` David Woodhouse
2023-10-18  5:31     ` Christoph Hellwig
2023-10-18 18:25       ` Luis Chamberlain
2023-08-01 17:45 ` require EXPORT_SYMBOL_GPL symbols for symbol_get v2 Luis Chamberlain
2023-08-02 11:56   ` Christoph Hellwig
2023-08-02 18:19     ` Luis Chamberlain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).