4 ms·
The kernel provides quite a few string processing helpers; I'm not sure why they're not documented. Perhaps the purpose of the document is to highlight bpf spe
by monocasa 3y ago
The kernel provides quite a few string processing helpers; I'm not sure why they're not documented. Perhaps the purpose of the document is to highlight bpf specific functionality rather than underlying runtime helpers?
You can see them listed here: https://elixir.bootlin.com/linux/latest/source/kernel/bpf/helpers.c#L439 https://elixir.bootlin.com/linux/latest/source/kernel/bpf/he...
And my point in highlighting them in this discussion was to get one to consider how of trap outs to the kernel are sort of fundamental. You get 4096 instructions to execute before you're cut off by the kernel (albeit statically). Given that, say, PATH_MAX is 32768, then you simply don't have enough compute time available to process certain strings you'd expect some bpf filters to be able to handle.
So basically I just wanted to hit home that some raw computation expected of bpf is incompatible with it's current verification model and at the very least extremely deep changes to bpf would need to occur to get rid of helpers.
- tptacek 3y agoThis a link to string->integer conversion and comparison, and nothing else.
- monocasa 3y agoSo "generic string processing helpers" provided by the kernel?
- insanitybit 3y ago"quite a few" tho
- ongy 3y agothat's what GP said. They are semantically simple string operations whose computational complexity scales with string length. Near unbound string lengths would exhaust the time (somewhat aproximated by instruction) budget of eBPF applications doing even a single one.
- tptacek 3y agoThat's all that's there. String-integer conversion and comparison.
- bandrami 3y agoI think the point was not to show "there are a lot of helper functions" but rather to point out "the (undocumented) helper functions that exist are problematic"
- tptacek 3y agoThat's not "quite a few" string helpers.
- monocasa 3y agoThere are others too, for instance string formatting: https://elixir.bootlin.com/linux/latest/source/kernel/bpf/helpers.c#L1064 https://elixir.bootlin.com/linux/latest/source/kernel/bpf/he...
- tptacek 3y agoWrite an eBPF program that actually needs to do any kind of meaningful string manipulation, and you'll quickly get a sense of just how rich the BPF helper inventory is in string processing functions. It'll be sharply obvious, because bounded loop enforcement will keep you from writing even the simplest string functions yourself.
- 3y ago