* [PATCH] bcachefs: ioctl: avoid stack overflow warning
@ 2025-06-10 9:24 Arnd Bergmann
2025-06-10 13:37 ` Kent Overstreet
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2025-06-10 9:24 UTC (permalink / raw)
To: Kent Overstreet, Nathan Chancellor
Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
Thomas Bertschinger, linux-bcachefs, linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
Multiple ioctl handlers individually use a lot of stack space, and clang chooses
to inline them into the bch2_fs_ioctl() function, blowing through the warning
limit:
fs/bcachefs/chardev.c:655:6: error: stack frame size (1032) exceeds limit (1024) in 'bch2_fs_ioctl' [-Werror,-Wframe-larger-than]
655 | long bch2_fs_ioctl(struct bch_fs *c, unsigned cmd, void __user *arg)
By marking the largest two of them as noinline_for_stack, no indidual code path
ends up using this much, which avoids the warning and reduces the possible
total stack usage in the ioctl handler.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/bcachefs/chardev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
index 2d38466eddfd..fde3c2380e28 100644
--- a/fs/bcachefs/chardev.c
+++ b/fs/bcachefs/chardev.c
@@ -399,7 +399,7 @@ static long bch2_ioctl_data(struct bch_fs *c,
return ret;
}
-static long bch2_ioctl_fs_usage(struct bch_fs *c,
+static noinline_for_stack long bch2_ioctl_fs_usage(struct bch_fs *c,
struct bch_ioctl_fs_usage __user *user_arg)
{
struct bch_ioctl_fs_usage arg = {};
@@ -469,7 +469,7 @@ static long bch2_ioctl_query_accounting(struct bch_fs *c,
}
/* obsolete, didn't allow for new data types: */
-static long bch2_ioctl_dev_usage(struct bch_fs *c,
+static noinline_for_stack long bch2_ioctl_dev_usage(struct bch_fs *c,
struct bch_ioctl_dev_usage __user *user_arg)
{
struct bch_ioctl_dev_usage arg;
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bcachefs: ioctl: avoid stack overflow warning
2025-06-10 9:24 [PATCH] bcachefs: ioctl: avoid stack overflow warning Arnd Bergmann
@ 2025-06-10 13:37 ` Kent Overstreet
0 siblings, 0 replies; 2+ messages in thread
From: Kent Overstreet @ 2025-06-10 13:37 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Nathan Chancellor, Arnd Bergmann, Nick Desaulniers, Bill Wendling,
Justin Stitt, Thomas Bertschinger, linux-bcachefs, linux-kernel,
llvm
On Tue, Jun 10, 2025 at 11:24:04AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Multiple ioctl handlers individually use a lot of stack space, and clang chooses
> to inline them into the bch2_fs_ioctl() function, blowing through the warning
> limit:
>
> fs/bcachefs/chardev.c:655:6: error: stack frame size (1032) exceeds limit (1024) in 'bch2_fs_ioctl' [-Werror,-Wframe-larger-than]
> 655 | long bch2_fs_ioctl(struct bch_fs *c, unsigned cmd, void __user *arg)
>
> By marking the largest two of them as noinline_for_stack, no indidual code path
> ends up using this much, which avoids the warning and reduces the possible
> total stack usage in the ioctl handler.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied, thanks
> ---
> fs/bcachefs/chardev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
> index 2d38466eddfd..fde3c2380e28 100644
> --- a/fs/bcachefs/chardev.c
> +++ b/fs/bcachefs/chardev.c
> @@ -399,7 +399,7 @@ static long bch2_ioctl_data(struct bch_fs *c,
> return ret;
> }
>
> -static long bch2_ioctl_fs_usage(struct bch_fs *c,
> +static noinline_for_stack long bch2_ioctl_fs_usage(struct bch_fs *c,
> struct bch_ioctl_fs_usage __user *user_arg)
> {
> struct bch_ioctl_fs_usage arg = {};
> @@ -469,7 +469,7 @@ static long bch2_ioctl_query_accounting(struct bch_fs *c,
> }
>
> /* obsolete, didn't allow for new data types: */
> -static long bch2_ioctl_dev_usage(struct bch_fs *c,
> +static noinline_for_stack long bch2_ioctl_dev_usage(struct bch_fs *c,
> struct bch_ioctl_dev_usage __user *user_arg)
> {
> struct bch_ioctl_dev_usage arg;
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-10 13:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 9:24 [PATCH] bcachefs: ioctl: avoid stack overflow warning Arnd Bergmann
2025-06-10 13:37 ` Kent Overstreet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox