diff options
| author | Eduard Zingerman <[email protected]> | 2024-12-10 04:10:59 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2024-12-10 18:24:57 +0000 |
| commit | 1a4607ffba35bf2a630aab299e34dd3f6e658d70 (patch) | |
| tree | 535a9521c3936f6232e4199d8d6bbc63d928bc29 /tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c | |
| parent | selftests/bpf: freplace tests for tracking of changes_packet_data (diff) | |
| download | kernel-1a4607ffba35bf2a630aab299e34dd3f6e658d70.tar.gz kernel-1a4607ffba35bf2a630aab299e34dd3f6e658d70.zip | |
bpf: consider that tail calls invalidate packet pointers
Tail-called programs could execute any of the helpers that invalidate
packet pointers. Hence, conservatively assume that each tail call
invalidates packet pointers.
Making the change in bpf_helper_changes_pkt_data() automatically makes
use of check_cfg() logic that computes 'changes_pkt_data' effect for
global sub-programs, such that the following program could be
rejected:
int tail_call(struct __sk_buff *sk)
{
bpf_tail_call_static(sk, &jmp_table, 0);
return 0;
}
SEC("tc")
int not_safe(struct __sk_buff *sk)
{
int *p = (void *)(long)sk->data;
... make p valid ...
tail_call(sk);
*p = 42; /* this is unsafe */
...
}
The tc_bpf2bpf.c:subprog_tc() needs change: mark it as a function that
can invalidate packet pointers. Otherwise, it can't be freplaced with
tailcall_freplace.c:entry_freplace() that does a tail call.
Signed-off-by: Eduard Zingerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c')
0 files changed, 0 insertions, 0 deletions
