Commit 81f6d05
bpf: check changes_pkt_data property for extension programs
When processing calls to global sub-programs, verifier decides whether
to invalidate all packet pointers in current state depending on the
changes_pkt_data property of the global sub-program.
Because of this, an extension program replacing a global sub-program
must be compatible with changes_pkt_data property of the sub-program
being replaced.
This commit:
- adds changes_pkt_data flag to struct bpf_prog_aux:
- this flag is set in check_cfg() for main sub-program;
- in jit_subprogs() for other sub-programs;
- modifies bpf_check_attach_btf_id() to check changes_pkt_data flag;
- moves call to check_attach_btf_id() after the call to check_cfg(),
because it needs changes_pkt_data flag to be set:
bpf_check:
... ...
- check_attach_btf_id resolve_pseudo_ldimm64
resolve_pseudo_ldimm64 --> bpf_prog_is_offloaded
bpf_prog_is_offloaded check_cfg
check_cfg + check_attach_btf_id
... ...
The following fields are set by check_attach_btf_id():
- env->ops
- prog->aux->attach_btf_trace
- prog->aux->attach_func_name
- prog->aux->attach_func_proto
- prog->aux->dst_trampoline
- prog->aux->mod
- prog->aux->saved_dst_attach_type
- prog->aux->saved_dst_prog_type
- prog->expected_attach_type
Neither of these fields are used by resolve_pseudo_ldimm64() or
bpf_prog_offload_verifier_prep() (for netronome and netdevsim
drivers), so the reordering is safe.
Suggested-by: Alexei Starovoitov <[email protected]>
Signed-off-by: Eduard Zingerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>1 parent 3f23ee5 commit 81f6d05
2 files changed
+13
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1527 | 1527 | | |
1528 | 1528 | | |
1529 | 1529 | | |
| 1530 | + | |
1530 | 1531 | | |
1531 | 1532 | | |
1532 | 1533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16872 | 16872 | | |
16873 | 16873 | | |
16874 | 16874 | | |
| 16875 | + | |
16875 | 16876 | | |
16876 | 16877 | | |
16877 | 16878 | | |
| |||
20361 | 20362 | | |
20362 | 20363 | | |
20363 | 20364 | | |
| 20365 | + | |
20364 | 20366 | | |
20365 | 20367 | | |
20366 | 20368 | | |
| |||
22225 | 22227 | | |
22226 | 22228 | | |
22227 | 22229 | | |
| 22230 | + | |
| 22231 | + | |
| 22232 | + | |
| 22233 | + | |
| 22234 | + | |
| 22235 | + | |
22228 | 22236 | | |
22229 | 22237 | | |
22230 | 22238 | | |
| |||
22690 | 22698 | | |
22691 | 22699 | | |
22692 | 22700 | | |
22693 | | - | |
22694 | | - | |
22695 | | - | |
22696 | | - | |
22697 | 22701 | | |
22698 | 22702 | | |
22699 | 22703 | | |
| |||
22708 | 22712 | | |
22709 | 22713 | | |
22710 | 22714 | | |
| 22715 | + | |
| 22716 | + | |
| 22717 | + | |
| 22718 | + | |
22711 | 22719 | | |
22712 | 22720 | | |
22713 | 22721 | | |
| |||
0 commit comments