* [PATCH] kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests
@ 2025-04-11 9:59 Richard Fitzgerald
2025-04-12 6:30 ` David Gow
2025-05-29 15:38 ` Jakub Kicinski
0 siblings, 2 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2025-04-11 9:59 UTC (permalink / raw)
To: brendan.higgins, davidgow, rmoar
Cc: linux-kselftest, kunit-dev, linux-kernel, patches
Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests.config. This helps
to detect use of uninitialized local variables.
This option found an uninitialized data bug in the cs_dsp test.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
tools/testing/kunit/configs/all_tests.config | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/kunit/configs/all_tests.config b/tools/testing/kunit/configs/all_tests.config
index cdd9782f9646..4a60bb71fe72 100644
--- a/tools/testing/kunit/configs/all_tests.config
+++ b/tools/testing/kunit/configs/all_tests.config
@@ -10,6 +10,7 @@ CONFIG_KUNIT_EXAMPLE_TEST=y
CONFIG_KUNIT_ALL_TESTS=y
CONFIG_FORTIFY_SOURCE=y
+CONFIG_INIT_STACK_ALL_PATTERN=y
CONFIG_IIO=y
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests
2025-04-11 9:59 [PATCH] kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests Richard Fitzgerald
@ 2025-04-12 6:30 ` David Gow
2025-05-29 15:38 ` Jakub Kicinski
1 sibling, 0 replies; 4+ messages in thread
From: David Gow @ 2025-04-12 6:30 UTC (permalink / raw)
To: Richard Fitzgerald
Cc: brendan.higgins, rmoar, linux-kselftest, kunit-dev, linux-kernel,
patches
[-- Attachment #1: Type: text/plain, Size: 1155 bytes --]
On Fri, 11 Apr 2025 at 17:59, Richard Fitzgerald
<rf@opensource.cirrus.com> wrote:
>
> Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests.config. This helps
> to detect use of uninitialized local variables.
>
> This option found an uninitialized data bug in the cs_dsp test.
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> ---
Hmm... for KASAN, we had a separate config fragment for picking these
sorts of things up. Then again, given we've already got stackinit
tests, we probably want this anyway, and it's clearly useful to have
it as a default.
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
> tools/testing/kunit/configs/all_tests.config | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/kunit/configs/all_tests.config b/tools/testing/kunit/configs/all_tests.config
> index cdd9782f9646..4a60bb71fe72 100644
> --- a/tools/testing/kunit/configs/all_tests.config
> +++ b/tools/testing/kunit/configs/all_tests.config
> @@ -10,6 +10,7 @@ CONFIG_KUNIT_EXAMPLE_TEST=y
> CONFIG_KUNIT_ALL_TESTS=y
>
> CONFIG_FORTIFY_SOURCE=y
> +CONFIG_INIT_STACK_ALL_PATTERN=y
>
> CONFIG_IIO=y
>
> --
> 2.39.5
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests
2025-04-11 9:59 [PATCH] kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests Richard Fitzgerald
2025-04-12 6:30 ` David Gow
@ 2025-05-29 15:38 ` Jakub Kicinski
2025-05-30 13:23 ` Richard Fitzgerald
1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2025-05-29 15:38 UTC (permalink / raw)
To: Richard Fitzgerald
Cc: brendan.higgins, davidgow, rmoar, linux-kselftest, kunit-dev,
linux-kernel, patches
On Fri, 11 Apr 2025 10:59:04 +0100 Richard Fitzgerald wrote:
> Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests.config. This helps
> to detect use of uninitialized local variables.
>
> This option found an uninitialized data bug in the cs_dsp test.
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> ---
> tools/testing/kunit/configs/all_tests.config | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/kunit/configs/all_tests.config b/tools/testing/kunit/configs/all_tests.config
> index cdd9782f9646..4a60bb71fe72 100644
> --- a/tools/testing/kunit/configs/all_tests.config
> +++ b/tools/testing/kunit/configs/all_tests.config
> @@ -10,6 +10,7 @@ CONFIG_KUNIT_EXAMPLE_TEST=y
> CONFIG_KUNIT_ALL_TESTS=y
>
> CONFIG_FORTIFY_SOURCE=y
> +CONFIG_INIT_STACK_ALL_PATTERN=y
This breaks kunit for older compilers:
$ ./tools/testing/kunit/kunit.py run --alltests --json --arch=x86_64
Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=x86_64 O=.kunit olddefconfig
ERROR:root:Not all Kconfig options selected in kunitconfig were in the generated .config.
This is probably due to unsatisfied dependencies.
Missing: CONFIG_INIT_STACK_ALL_PATTERN=y
$ gcc --version
gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
IIUC GCC 11.5 is supported so pattern init can't be a hard requirement.
How about we do this instead? Can you check if it'd work for you?
diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening
index c17366ce8224..904b99f34cd0 100644
--- a/security/Kconfig.hardening
+++ b/security/Kconfig.hardening
@@ -113,6 +113,7 @@ choice
bool "pattern-init everything (strongest)"
+ default KUNIT_ALL_TESTS
depends on CC_HAS_AUTO_VAR_INIT_PATTERN
depends on !KMSAN
help
Initializes everything on the stack (including padding)
with a specific debug value. This is intended to eliminate
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests
2025-05-29 15:38 ` Jakub Kicinski
@ 2025-05-30 13:23 ` Richard Fitzgerald
0 siblings, 0 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2025-05-30 13:23 UTC (permalink / raw)
To: Jakub Kicinski
Cc: brendan.higgins, davidgow, rmoar, linux-kselftest, kunit-dev,
linux-kernel, patches
On 29/5/25 16:38, Jakub Kicinski wrote:
> On Fri, 11 Apr 2025 10:59:04 +0100 Richard Fitzgerald wrote:
>> Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests.config. This helps
>> to detect use of uninitialized local variables.
>>
>> This option found an uninitialized data bug in the cs_dsp test.
>>
>> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
>> ---
>> tools/testing/kunit/configs/all_tests.config | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/tools/testing/kunit/configs/all_tests.config b/tools/testing/kunit/configs/all_tests.config
>> index cdd9782f9646..4a60bb71fe72 100644
>> --- a/tools/testing/kunit/configs/all_tests.config
>> +++ b/tools/testing/kunit/configs/all_tests.config
>> @@ -10,6 +10,7 @@ CONFIG_KUNIT_EXAMPLE_TEST=y
>> CONFIG_KUNIT_ALL_TESTS=y
>>
>> CONFIG_FORTIFY_SOURCE=y
>> +CONFIG_INIT_STACK_ALL_PATTERN=y
>
> This breaks kunit for older compilers:
Drop it then.
It's not essential. Just something that showed a bug in a test so I
thought would be useful to test always. But if there are compatibility
problems it would be better not to have it in all_tests.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-30 13:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 9:59 [PATCH] kunit: configs: Enable CONFIG_INIT_STACK_ALL_PATTERN in all_tests Richard Fitzgerald
2025-04-12 6:30 ` David Gow
2025-05-29 15:38 ` Jakub Kicinski
2025-05-30 13:23 ` Richard Fitzgerald
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.