linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, SeongJae Park <sj@kernel.org>,
	David Gow <davidgow@google.com>,
	Christian Brauner <brauner@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] binfmt_elf: reduce stackusage in kunit test
Date: Fri, 20 Jun 2025 13:19:58 +0200	[thread overview]
Message-ID: <20250620112003.3395792-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.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@arndb.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



                 reply	other threads:[~2025-06-20 11:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250620112003.3395792-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=davidgow@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox