On Thu, Jun 13, 2024 at 11:02 AM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Wed, Jun 12, 2024 at 7:19 PM <flyingpenghao@xxxxxxxxx> wrote: > > > > From: Peng Hao <flyingpeng@xxxxxxxxxxx> > > > > When building kernel with clang, which will typically > > have sanitizers enabled, there is a warning about a large stack frame. > > > > kernel/bpf/verifier.c:21163:5: error: stack frame size (2392) exceeds > > limit (2048) in 'bpf_check' [-Werror,-Wframe-larger-than] > > int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, > > __u32 uattr_size) > > ^ > > 632/2392 (26.42%) spills, 1760/2392 (73.58%) variables > > so increase the limit for configurations that have KASAN or KCSAN enabled for not > > breaking the majority of builds. > > > > Signed-off-by: Peng Hao <flyingpeng@xxxxxxxxxxx> > > --- > > kernel/bpf/Makefile | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile > > index e497011261b8..07ed1e81aa62 100644 > > --- a/kernel/bpf/Makefile > > +++ b/kernel/bpf/Makefile > > @@ -6,6 +6,12 @@ cflags-nogcse-$(CONFIG_X86)$(CONFIG_CC_IS_GCC) := -fno-gcse > > endif > > CFLAGS_core.o += -Wno-override-init $(cflags-nogcse-yy) > > > > +ifneq ($(CONFIG_FRAME_WARN),0) > > +ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) > > +CFLAGS_verifier.o = -Wframe-larger-than=2392 > > that's very compiler specific. > version +-1 will have different results. > Please investigate what is causing the large stack size instead. > pw-bot: cr This increase in stack frame size only occurs when KASAN or KCSAN is configured. KASAN or KCSAN will cause the stack frame size to increase, and it will insert additional code and data structures to detect memory errors during compilation. These additional checks will increase the stack space requirements of the function. Thanks.