[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250620112003.3395792-1-arnd@kernel.org>
Date: Fri, 20 Jun 2025 13:19:58 +0200
From: Arnd Bergmann <arnd@...nel.org>
To: Kees Cook <kees@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>,
SeongJae Park <sj@...nel.org>,
David Gow <davidgow@...gle.com>,
Christian Brauner <brauner@...nel.org>,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] binfmt_elf: reduce stackusage in kunit test
From: Arnd Bergmann <arnd@...db.de>
Constructing arrays on the stack in the test case triggers a warning
in some configurations:
fs/tests/binfmt_elf_kunit.c: In function 'total_mapping_size_test':
fs/tests/binfmt_elf_kunit.c:52:1: error: the frame size of 1448 bytes is larger than 1408 bytes [-Werror=frame-larger-than=]
Change the arrays to 'static const' to not use any stack space at all.
This is possible since the contents are never modified.
Fixes: 9e1a3ce0a952 ("binfmt_elf: Introduce KUnit test")
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
fs/tests/binfmt_elf_kunit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/tests/binfmt_elf_kunit.c b/fs/tests/binfmt_elf_kunit.c
index 11d734fec366..023042f6aeee 100644
--- a/fs/tests/binfmt_elf_kunit.c
+++ b/fs/tests/binfmt_elf_kunit.c
@@ -3,7 +3,7 @@
static void total_mapping_size_test(struct kunit *test)
{
- struct elf_phdr empty[] = {
+ static const struct elf_phdr empty[] = {
{ .p_type = PT_LOAD, .p_vaddr = 0, .p_memsz = 0, },
{ .p_type = PT_INTERP, .p_vaddr = 10, .p_memsz = 999999, },
};
@@ -11,7 +11,7 @@ static void total_mapping_size_test(struct kunit *test)
* readelf -lW /bin/mount | grep '^ .*0x0' | awk '{print "\t\t{ .p_type = PT_" \
* $1 ", .p_vaddr = " $3 ", .p_memsz = " $6 ", },"}'
*/
- struct elf_phdr mount[] = {
+ static const struct elf_phdr mount[] = {
{ .p_type = PT_PHDR, .p_vaddr = 0x00000040, .p_memsz = 0x0002d8, },
{ .p_type = PT_INTERP, .p_vaddr = 0x00000318, .p_memsz = 0x00001c, },
{ .p_type = PT_LOAD, .p_vaddr = 0x00000000, .p_memsz = 0x0033a8, },
@@ -28,7 +28,7 @@ static void total_mapping_size_test(struct kunit *test)
};
size_t mount_size = 0xE070;
/* https://lore.kernel.org/linux-fsdevel/YfF18Dy85mCntXrx@fractal.localdomain */
- struct elf_phdr unordered[] = {
+ static const struct elf_phdr unordered[] = {
{ .p_type = PT_LOAD, .p_vaddr = 0x00000000, .p_memsz = 0x0033a8, },
{ .p_type = PT_LOAD, .p_vaddr = 0x0000d330, .p_memsz = 0x000d40, },
{ .p_type = PT_LOAD, .p_vaddr = 0x00004000, .p_memsz = 0x005c91, },
--
2.39.5
Powered by blists - more mailing lists