Skip to content

Commit e7e5809

Browse files
arndbKernel Patches Daemon
authored andcommitted
bpf: turn off sanitizer in do_misc_fixups for old clang
clang versions before version 18 manage to badly optimize the bpf verifier, with lots of variable spills leading to excessive stack usage in addition to likely rather slow code: kernel/bpf/verifier.c:23936:5: error: stack frame size (2096) exceeds limit (1280) in 'bpf_check' [-Werror,-Wframe-larger-than] kernel/bpf/verifier.c:21563:12: error: stack frame size (1984) exceeds limit (1280) in 'do_misc_fixups' [-Werror,-Wframe-larger-than] Turn off the sanitizer in the two functions that suffer the most from this when using one of the affected clang version. Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 097b64d commit e7e5809

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

kernel/bpf/verifier.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19811,7 +19811,14 @@ static int do_check_insn(struct bpf_verifier_env *env, bool *do_print_state)
1981119811
return 0;
1981219812
}
1981319813

19814-
static int do_check(struct bpf_verifier_env *env)
19814+
#if defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 180100
19815+
/* old clang versions cause excessive stack usage here */
19816+
#define __workaround_kasan __disable_sanitizer_instrumentation
19817+
#else
19818+
#define __workaround_kasan
19819+
#endif
19820+
19821+
static __workaround_kasan int do_check(struct bpf_verifier_env *env)
1981519822
{
1981619823
bool pop_log = !(env->log.level & BPF_LOG_LEVEL2);
1981719824
struct bpf_verifier_state *state = env->cur_state;
@@ -21818,7 +21825,7 @@ static int add_hidden_subprog(struct bpf_verifier_env *env, struct bpf_insn *pat
2181821825
/* Do various post-verification rewrites in a single program pass.
2181921826
* These rewrites simplify JIT and interpreter implementations.
2182021827
*/
21821-
static int do_misc_fixups(struct bpf_verifier_env *env)
21828+
static __workaround_kasan int do_misc_fixups(struct bpf_verifier_env *env)
2182221829
{
2182321830
struct bpf_prog *prog = env->prog;
2182421831
enum bpf_attach_type eatype = prog->expected_attach_type;

0 commit comments

Comments
 (0)