You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address PR review comments: add overflow checks and improve large program test
- Add overflow checks for calloc in ubpf_create, ubpf_unload_code, and ubpf_set_max_instructions
- Update ubpf_test_large_program to actually JIT compile and execute large programs
- Initialize r0 to 0 in test program and verify result
- Set appropriate JIT buffer size for large programs
- Update documentation to reflect actual test behavior
Co-authored-by: Alan-Jowett <[email protected]>
This test validates that programs with more than 65,536 instructions can be loaded correctly when `ubpf_set_max_instructions()` is used to increase the limit.
3
+
This test validates that programs with more than 65,536 instructions can be loaded, JIT compiled, and executed correctly when `ubpf_set_max_instructions()` is used to increase the limit.
4
4
5
5
The test performs the following:
6
6
1. Creates a VM and sets max_instructions to 100,000
7
7
2. Generates a program with 66,000 instructions (NOP-like JA instructions with offset 0) plus an EXIT
8
8
3. Loads the program into the VM
9
+
4. JIT compiles the program
10
+
5. Executes the JIT-compiled program
9
11
10
12
This validates that:
11
13
- The type change from uint16_t to uint32_t for num_insts works correctly
12
14
- Programs beyond the old 65,536 limit can be loaded
13
15
- The validation path handles large instruction counts correctly
16
+
- The JIT compiler can handle large programs (> 65,536 instructions)
17
+
- JIT-compiled large programs execute correctly
14
18
15
-
Note: The test skips interpreter and JIT execution to keep test runtime reasonable.
16
-
Large programs with many sequential NOPs would take prohibitively long to execute.
19
+
Note: The test skips interpreter execution because executing 66,000 sequential NOP-like
20
+
instructions via the interpreter would take prohibitively long for a test.
0 commit comments