Commit 7b5fff5
bpf: Fix GFP flags for non-sleepable async callbacks
Fix storage_get helpers to use GFP_ATOMIC when called from non-sleepable
contexts within sleepable programs, such as bpf_timer callbacks.
Currently, the check in do_misc_fixups assumes that env->prog->sleepable,
previously in_sleepable(env) which only resolved to this check before
last commit, holds across the program's execution, but that is not true.
Instead, the func_atomic bit must be set whenever we see the function
being called in an atomic context. Previously, this is being done when
the helper is invoked in atomic contexts in sleepable programs, we can
simply just set the value to true without doing an in_sleepable() check.
We must also do a standalone in_sleepable() check to handle cases where
the async callback itself is armed from a sleepable program, but is
itself non-sleepable (e.g., timer callback) and invokes such a helper,
thus needing the func_atomic bit to be true for the said call.
Adjust do_misc_fixups() to drop any checks regarding sleepable nature of
the program, and just depend on the func_atomic bit to decide which GFP
flag to pass.
Fixes: b00fa38 ("bpf: Enable non-atomic allocations in local storage")
Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]>1 parent 0c3f208 commit 7b5fff5
1 file changed
+11
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11438 | 11438 | | |
11439 | 11439 | | |
11440 | 11440 | | |
11441 | | - | |
| 11441 | + | |
11442 | 11442 | | |
11443 | 11443 | | |
11444 | 11444 | | |
| |||
11449 | 11449 | | |
11450 | 11450 | | |
11451 | 11451 | | |
11452 | | - | |
| 11452 | + | |
11453 | 11453 | | |
11454 | 11454 | | |
11455 | 11455 | | |
| |||
11460 | 11460 | | |
11461 | 11461 | | |
11462 | 11462 | | |
11463 | | - | |
| 11463 | + | |
11464 | 11464 | | |
11465 | 11465 | | |
11466 | 11466 | | |
| 11467 | + | |
| 11468 | + | |
| 11469 | + | |
| 11470 | + | |
| 11471 | + | |
| 11472 | + | |
| 11473 | + | |
11467 | 11474 | | |
11468 | 11475 | | |
11469 | 11476 | | |
| |||
22495 | 22502 | | |
22496 | 22503 | | |
22497 | 22504 | | |
22498 | | - | |
22499 | | - | |
| 22505 | + | |
22500 | 22506 | | |
22501 | 22507 | | |
22502 | 22508 | | |
| |||
0 commit comments