Commit 4524b7f
bpf: Fix array bounds error with may_goto
[ Upstream commit 6ebc503 ]
may_goto uses an additional 8 bytes on the stack, which causes the
interpreters[] array to go out of bounds when calculating index by
stack_size.
1. If a BPF program is rewritten, re-evaluate the stack size. For non-JIT
cases, reject loading directly.
2. For non-JIT cases, calculating interpreters[idx] may still cause
out-of-bounds array access, and just warn about it.
3. For jit_requested cases, the execution of bpf_func also needs to be
warned. So move the definition of function __bpf_prog_ret0_warn out of
the macro definition CONFIG_BPF_JIT_ALWAYS_ON.
Reported-by: [email protected]
Closes: https://lore.kernel.org/bpf/[email protected]/
Fixes: 011832b ("bpf: Introduce may_goto instruction")
Signed-off-by: Jiayuan Chen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>1 parent 37fd07b commit 4524b7f
2 files changed
+22
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2290 | 2290 | | |
2291 | 2291 | | |
2292 | 2292 | | |
2293 | | - | |
| 2293 | + | |
| 2294 | + | |
2294 | 2295 | | |
2295 | 2296 | | |
2296 | 2297 | | |
2297 | 2298 | | |
2298 | | - | |
| 2299 | + | |
| 2300 | + | |
2299 | 2301 | | |
2300 | 2302 | | |
2301 | 2303 | | |
2302 | 2304 | | |
2303 | | - | |
2304 | 2305 | | |
2305 | 2306 | | |
2306 | 2307 | | |
| |||
2380 | 2381 | | |
2381 | 2382 | | |
2382 | 2383 | | |
| 2384 | + | |
2383 | 2385 | | |
2384 | | - | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
2385 | 2396 | | |
2386 | 2397 | | |
2387 | 2398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21472 | 21472 | | |
21473 | 21473 | | |
21474 | 21474 | | |
| 21475 | + | |
| 21476 | + | |
| 21477 | + | |
| 21478 | + | |
| 21479 | + | |
| 21480 | + | |
| 21481 | + | |
21475 | 21482 | | |
21476 | 21483 | | |
21477 | 21484 | | |
| |||
0 commit comments