Message ID | 20250213131214.164982-1-mrpre@163.com |
---|---|
Headers | show |
Series | bpf: Fix array bounds error with may_goto and add selftest | expand |
On Thu, Feb 13, 2025 at 8:42 AM Jiayuan Chen <mrpre@163.com> wrote: > > On Thu, Feb 13, 2025 at 08:04:05AM -0800, Alexei Starovoitov wrote: > > On Thu, Feb 13, 2025 at 5:13 AM Jiayuan Chen <mrpre@163.com> wrote: > > > > > > Add test cases to ensure the maximum stack size can be properly limited to > > > 512. > > > > > > Test result: > > > echo "0" > /proc/sys/net/core/bpf_jit_enable > > > ./test_progs -t verifier_stack_ptr > > > verifier_stack_ptr/PTR_TO_STACK stack size 512 with may_goto with jit:SKIP > > > verifier_stack_ptr/PTR_TO_STACK stack size 512 with may_goto without jit:OK > > > > > > echo "1" > /proc/sys/net/core/bpf_jit_enable > > > verifier_stack_ptr/PTR_TO_STACK stack size 512 with may_goto with jit:OK > > > verifier_stack_ptr/PTR_TO_STACK stack size 512 with may_goto without jit:SKIP > > > > echo '0|1' is not longer necessary ? > > The commit log seems obsolete? > > > > pw-bot: cr > > It looks like the problem only arises when CONFIG_BPF_JIT_ALWAYS_ON is > turned off, and we're only restricting the stack size when > prog->jit_requested is false. To test this, I simulated different > scenarios by echoing '0' or '1' to see how the program would behave when > jit_requested is enabled or disabled. > > As expected, when I echoed '0', the program failed verification, and when > I echoed '1', it ran smoothly. I misunderstood the tags in patch 2. I thought: +#define __use_jit() __attribute__((btf_decl_tag("comment:run_mode=jit"))) +#define __use_interp() __attribute__((btf_decl_tag("comment:run_mode=interpreter"))) "use jit" actually means use jit. while what it's doing is different: + if ((jit_enabled && spec->run_mode & INTERP) || + (!jit_enabled && spec->run_mode & JIT)) { + test__skip(); + return; + } + The tags should probably be named __load_if_JITed and __load_if_interpreted or something like that.