[PATCH] regmap: REGMAP_KUNIT must not select REGMAP

0 views
Skip to first unread message

Geert Uytterhoeven

unread,
Apr 26, 2023, 8:01:10 AM4/26/23
to Mark Brown, David Gow, Brendan Higgins, Greg Kroah-Hartman, Rafael J . Wysocki, linux-k...@vger.kernel.org, kuni...@googlegroups.com, linux-...@vger.kernel.org, Geert Uytterhoeven
Enabling a (modular) test must not silently enable additional kernel
functionality, as that may increase the attack vector of a product.

Fix this by making REGMAP_KUNIT depend on REGMAP instead.

Fixes: 2238959b6ad27040 ("regmap: Add some basic kunit tests")
Signed-off-by: Geert Uytterhoeven <ge...@linux-m68k.org>
---
drivers/base/regmap/Kconfig | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig
index 33a8366e22a584a5..20327c15cbce5d8c 100644
--- a/drivers/base/regmap/Kconfig
+++ b/drivers/base/regmap/Kconfig
@@ -11,9 +11,8 @@ config REGMAP

config REGMAP_KUNIT
tristate "KUnit tests for regmap"
- depends on KUNIT
+ depends on KUNIT && REGMAP
default KUNIT_ALL_TESTS
- select REGMAP
select REGMAP_RAM

config REGMAP_AC97
--
2.34.1

Mark Brown

unread,
Apr 26, 2023, 8:42:53 AM4/26/23
to Geert Uytterhoeven, David Gow, Brendan Higgins, Greg Kroah-Hartman, Rafael J . Wysocki, linux-k...@vger.kernel.org, kuni...@googlegroups.com, linux-...@vger.kernel.org
On Wed, Apr 26, 2023 at 01:56:44PM +0200, Geert Uytterhoeven wrote:
> Enabling a (modular) test must not silently enable additional kernel
> functionality, as that may increase the attack vector of a product.
>
> Fix this by making REGMAP_KUNIT depend on REGMAP instead.

This doesn't work since regmap is a selected library so there's no way
to directly enable regmap other than by enabling something that uses it
and it is very likely that the virtual configurations people often use
with KUnit will not have any physical hardware and therefore will not
need regmap. It seems a lot more likely that someone would want to run
the tests on a platform that doesn't otherwise use regmap than that
someone would end up building in regmap on a production kernel that
wouldn't otherwise have enabled it.
signature.asc

Geert Uytterhoeven

unread,
Apr 26, 2023, 9:34:43 AM4/26/23
to Mark Brown, David Gow, Brendan Higgins, Greg Kroah-Hartman, Rafael J . Wysocki, linux-k...@vger.kernel.org, kuni...@googlegroups.com, linux-...@vger.kernel.org
Hi Mark,
Thanks, I had missed that. Will send a v2...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Geert Uytterhoeven

unread,
Apr 26, 2023, 9:35:52 AM4/26/23
to Mark Brown, David Gow, Brendan Higgins, Greg Kroah-Hartman, Rafael J . Wysocki, linux-k...@vger.kernel.org, kuni...@googlegroups.com, linux-...@vger.kernel.org, Geert Uytterhoeven
Enabling a (modular) test must not silently enable additional kernel
functionality, as that may increase the attack vector of a product.

Fix this by:
1. making REGMAP visible if CONFIG_KUNIT_ALL_TESTS is enabled,
2. making REGMAP_KUNIT depend on REGMAP instead of selecting it.

After this, one can safely enable CONFIG_KUNIT_ALL_TESTS=m to build
modules for all appropriate tests for ones system, without pulling in
extra unwanted functionality, while still allowing a tester to manually
enable REGMAP and its test suite on a system where REGMAP is not enabled
by default.

Fixes: 2238959b6ad27040 ("regmap: Add some basic kunit tests")
Signed-off-by: Geert Uytterhoeven <ge...@linux-m68k.org>
---
v2:
- Make REGMAP visible if CONFIG_KUNIT_ALL_TESTS is enabled.
---
drivers/base/regmap/Kconfig | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig
index 33a8366e22a584a5..0db2021f7477f2ab 100644
--- a/drivers/base/regmap/Kconfig
+++ b/drivers/base/regmap/Kconfig
@@ -4,16 +4,23 @@
# subsystems should select the appropriate symbols.

config REGMAP
+ bool "Register Map support" if KUNIT_ALL_TESTS
default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SOUNDWIRE_MBQ || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM || REGMAP_MDIO || REGMAP_FSI)
select IRQ_DOMAIN if REGMAP_IRQ
select MDIO_BUS if REGMAP_MDIO
- bool
+ help
+ Enable support for the Register Map (regmap) access API.
+
+ Usually, this option is automatically selected when needed.
+ However, you may want to enable it manually for running the regmap
+ KUnit tests.
+
+ If unsure, say N.

Mark Brown

unread,
May 8, 2023, 10:23:02 AM5/8/23
to David Gow, Brendan Higgins, Geert Uytterhoeven, Greg Kroah-Hartman, Rafael J . Wysocki, linux-k...@vger.kernel.org, kuni...@googlegroups.com, linux-...@vger.kernel.org
On Wed, 26 Apr 2023 15:35:45 +0200, Geert Uytterhoeven wrote:
> Enabling a (modular) test must not silently enable additional kernel
> functionality, as that may increase the attack vector of a product.
>
> Fix this by:
> 1. making REGMAP visible if CONFIG_KUNIT_ALL_TESTS is enabled,
> 2. making REGMAP_KUNIT depend on REGMAP instead of selecting it.
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: REGMAP_KUNIT must not select REGMAP
commit: 70a640c0efa7667453c3911b13335304ce46ad8b

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

Reply all
Reply to author
Forward
0 new messages