Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: memcpy: Split slow memcpy tests into MEMCPY_SLOW_KUNIT_TEST

Since the long memcpy tests may stall a system for tens of seconds
in virtualized architecture environments, split those tests off under
CONFIG_MEMCPY_SLOW_KUNIT_TEST so they can be separately disabled.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/lkml/20221226195206.GA2626419@roeck-us.net
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-and-tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: David Gow <davidgow@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>

+11
+9
lib/Kconfig.debug
··· 2566 2566 2567 2567 If unsure, say N. 2568 2568 2569 + config MEMCPY_SLOW_KUNIT_TEST 2570 + bool "Include exhaustive memcpy tests" 2571 + depends on MEMCPY_KUNIT_TEST 2572 + default y 2573 + help 2574 + Some memcpy tests are quite exhaustive in checking for overlaps 2575 + and bit ranges. These can be very slow, so they are split out 2576 + as a separate config, in case they need to be disabled. 2577 + 2569 2578 config IS_SIGNED_TYPE_KUNIT_TEST 2570 2579 tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS 2571 2580 depends on KUNIT
+2
lib/memcpy_kunit.c
··· 309 309 310 310 static void init_large(struct kunit *test) 311 311 { 312 + if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST)) 313 + kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y"); 312 314 313 315 /* Get many bit patterns. */ 314 316 get_random_bytes(large_src, ARRAY_SIZE(large_src));