BPF List
 help / color / mirror / Atom feed
* Packet pointer invalidation and subprograms
@ 2024-12-03 16:26 Nick Zavaritsky
  2024-12-03 20:19 ` Eduard Zingerman
  0 siblings, 1 reply; 26+ messages in thread
From: Nick Zavaritsky @ 2024-12-03 16:26 UTC (permalink / raw)
  To: bpf

Hi,

Calls to helpers such as bpf_skb_pull_data, are supposed to invalidate
all prior checks on packet pointers.

I noticed that if I wrap a call to bpf_skb_pull_data in a function with
global linkage, pointers checked prior to the call are still considered
valid after the call. The program is accepted on 6.8 and 6.13-rc1.

I'm curious if it is by design and if not, if it is a known issue.
Please find the program below.

#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>

__attribute__((__noinline__))
long skb_pull_data(struct __sk_buff *sk, __u32 len)
{
    return bpf_skb_pull_data(sk, len);
}

SEC("tc")
int test_invalidate_checks(struct __sk_buff *sk)
{
    int *p = (void *)(long)sk->data;
    if ((void *)(p + 1) > (void *)(long)sk->data_end) return TCX_DROP;
    skb_pull_data(sk, 0);
    *p = 42;
    return TCX_PASS;
}

If I remove noinline or add static, the program is rejected as expected.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2024-12-06 19:32 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 16:26 Packet pointer invalidation and subprograms Nick Zavaritsky
2024-12-03 20:19 ` Eduard Zingerman
2024-12-03 21:41   ` Eduard Zingerman
2024-12-06  0:03     ` Andrii Nakryiko
2024-12-06  0:12       ` Kumar Kartikeya Dwivedi
2024-12-06  0:29       ` Eduard Zingerman
2024-12-06  1:44         ` Alexei Starovoitov
2024-12-06  4:07           ` Eduard Zingerman
2024-12-06  6:22             ` Andrii Nakryiko
2024-12-06 10:44               ` Eduard Zingerman
2024-12-06 16:08                 ` Andrii Nakryiko
2024-12-06 17:29                   ` Eduard Zingerman
2024-12-06 17:46                     ` Andrii Nakryiko
2024-12-06 17:58                       ` Eduard Zingerman
2024-12-06 18:10                         ` Andrii Nakryiko
2024-12-06 18:29                           ` Eduard Zingerman
2024-12-06 16:07               ` Alexei Starovoitov
2024-12-06 16:12                 ` Andrii Nakryiko
2024-12-06 16:20                   ` Alexei Starovoitov
2024-12-06 17:42                     ` Andrii Nakryiko
2024-12-06 18:23                       ` Kumar Kartikeya Dwivedi
2024-12-06 18:30                         ` Alexei Starovoitov
2024-12-06 19:31                           ` Kumar Kartikeya Dwivedi
2024-12-06 18:26                       ` Alexei Starovoitov
2024-12-06 18:30                         ` Kumar Kartikeya Dwivedi
2024-12-06 18:32                           ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox