bcachefs: ioctl: avoid stack overflow warning
authorArnd Bergmann <arnd@arndb.de>
Tue, 10 Jun 2025 09:24:04 +0000 (11:24 +0200)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 12 Jun 2025 03:21:30 +0000 (23:21 -0400)
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>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/chardev.c

index 2d38466eddfd919d939f708304a64f274f8b52a7..fde3c2380e28e79f22b189577256517dc26f92eb 100644 (file)
@@ -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 @@ err:
 }
 
 /* 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;