When programs written in BPF (the kernel’s hot-loadable virtual-machine bytecode) call kernel functions (kfuncs), it may be useful for those functions to have additional information about the context in which those BPF programs are executing. Rather than requiring it to supply that information, it would be convenient to let the BPF verifier pass that information to the called function automatically. That is already possible, but a recent patch set from Ihor Solodrai would make it more ergonomic. It allows kernel developers to specify that a kfunc should be passed additional parameters inferred by the verifier, invisibly to the BPF program. The discussion included concerns that Solodrai’s implementation was unnecessarily complex, however.
Currently, kfuncs that need access to a BPF program’s context information indicate this by adding the __prog annotation to one of their arguments. A BPF program calling the function passes NULL for that parameter, and the verifier automatically inserts a pointer to the program’s bpf_prog_aux structure (which can be used to find or manipulate a control group associated with a BPF program, for example). That is awkward because if a kfunc is updated to require a program’s context information, all of the BPF programs that call it need to be updated to pass the extra parameter.

