Commit 3091b66
bpf: Relax allowlist for css_task iter
The newly added open-coded css_task iter would try to hold the global
css_set_lock in bpf_iter_css_task_new, so the bpf side has to be careful in
where it allows to use this iter. The mainly concern is dead locking on
css_set_lock. check_css_task_iter_allowlist() in verifier enforced css_task
can only be used in bpf_lsm hooks and sleepable bpf_iter.
This patch relax the allowlist for css_task iter. Any lsm and any iter
(even non-sleepable) and any sleepable are safe since they would not hold
the css_set_lock before entering BPF progs context.
This patch also fixes the misused BPF_TRACE_ITER in
check_css_task_iter_allowlist which compared bpf_prog_type with
bpf_attach_type.
Fixes: 9c66dc9 ("bpf: Introduce css_task open-coded iterator kfuncs")
Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20231031050438.93297-2-zhouchuyi@bytedance.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent 9af3775 commit 3091b66
2 files changed
Lines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11402 | 11402 | | |
11403 | 11403 | | |
11404 | 11404 | | |
| 11405 | + | |
| 11406 | + | |
| 11407 | + | |
| 11408 | + | |
| 11409 | + | |
| 11410 | + | |
11405 | 11411 | | |
11406 | 11412 | | |
11407 | 11413 | | |
11408 | 11414 | | |
11409 | 11415 | | |
11410 | 11416 | | |
11411 | 11417 | | |
11412 | | - | |
11413 | | - | |
| 11418 | + | |
| 11419 | + | |
| 11420 | + | |
| 11421 | + | |
11414 | 11422 | | |
11415 | | - | |
| 11423 | + | |
11416 | 11424 | | |
11417 | 11425 | | |
11418 | 11426 | | |
| |||
11671 | 11679 | | |
11672 | 11680 | | |
11673 | 11681 | | |
11674 | | - | |
| 11682 | + | |
11675 | 11683 | | |
11676 | 11684 | | |
11677 | 11685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
0 commit comments