Re: [PATCH bpf] bpf: tail calls do not modify packet data

Teichmann, Martin
2025-11-03T08:56:18Z

Dear Eduard,

thanks for the review!

> I don't think this is safe to do, consider the following example:
>
> main:
> p = pkt
> foo()
> use p
>
> foo: // assume that 'foo' is a static function (local subprogram)
> if (something) do tail call
> don't modify packet data

You are absolutely right, this would not work. This should actually be covered by tests... I'll write a test. I also already have an idea how to fix also this problem, and will come back to you once I'm done.

> Alexei vaguely remembers discussion about using decl_tag's to mark
> maps containing programs that don't modify packet pointers.

I am actually against that, I think this would be the wrong way to go. In my use case, I have written a dispatcher for packets that tail call other programs depending on the content of the packet processed. These programs do change during runtime. Until now I had no restrictions on those programs, they could modify the packet or not, as they wished, as the code does not return at all anyways. Tagging the programs would only limit their usefulness, without giving any benefits.

I know that what I am doing is a bit crazy, I actually do motion control with EBPF, and all the EPBF programs are generated directly from Python, so I am not protected by any checking that compilers like LLVM might do. So I am kindof stress testing the EBPF subsystem... (if there is any interest, my code is at https://github.com/tecki/ebpfcat)

Cheers

Martin