All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>,
	Alexander Mikhalitsyn <alexander@mihalicyn.com>,
	Andrew Halaney <andrew@amutable.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Jan Kara <jack@suse.cz>,
	Oleg Nesterov <oleg@redhat.com>,
	Kees Cook <kees+treewide@kernel.org>, NeilBrown <neil@brown.name>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] coredump: reduce stack usage in vfs_coredump
Date: Fri, 16 Oct 2026 21:46:39 +0200	[thread overview]
Message-ID: <20261016194650.1580988-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

A recent patch changed the coredump code in mostly harmless ways,
but after this I get a very high stack usage in one function
that was benign before:

fs/coredump.c: In function 'vfs_coredump':
fs/coredump.c:1313:1: error: the frame size of 1872 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

This happens reproducibly every couple of randconfig builds on
s390 with gcc-16 and seems to be caused by kasan checks causing
local variables to be spilled to the stack.

Marking the do_coredump function as noinline_for_stack avoids
the problem here, instead I get only 464 and 672 bytes in
the worst case for vfs_coredump and do_coredump, respectively.

Fixes: 3209535cd39e ("pidfs: record the coredump on the dumping thread's pid too")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
If anyone wants to look at it in more detail, here is the
information I have:

randconfig: https://pastebin.com/raw/bskKJixQ
assembler output: https://pastebin.com/raw/Wr1V8kRS

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/coredump.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index b25ef2ffbdee..82ef9d115999 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1198,8 +1198,10 @@ static inline bool coredump_skip(const struct coredump_params *cprm,
 	return false;
 }
 
-static void do_coredump(struct core_name *cn, struct coredump_params *cprm,
-			size_t **argv, int *argc, const struct linux_binfmt *binfmt)
+static noinline_for_stack void do_coredump(struct core_name *cn,
+					   struct coredump_params *cprm,
+					   size_t **argv, int *argc,
+					   const struct linux_binfmt *binfmt)
 {
 	trace_coredump(cprm->siginfo->si_signo);
 
-- 
2.53.0


                 reply	other threads:[~2026-10-16 19:46 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=20261016194650.1580988-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=alexander@mihalicyn.com \
    --cc=andrew@amutable.com \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=kees+treewide@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 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.