On Thu, Oct 04, 2018 at 03:50:38PM +0200, Daniel Borkmann wrote: > Allow for audit messages to be emitted upon BPF program load and > unload for having a timeline of events. The load itself is in > syscall context, so additional info about the process initiating > the BPF prog creation can be logged and later directly correlated > to the unload event. > > The only info really needed from BPF side is the globally unique > prog ID where then audit user space tooling can query / dump all > info needed about the specific BPF program right upon load event > and enrich the record, thus these changes needed here can be kept > small and non-intrusive to the core.
The above description is correct, but the commit log doesn't explain _why_ this audit logging is needed and _why_ for load/unload. My understanding of audit subsystem that it's very heavy weight and absolutely not suitable for high frequency events. Audit suppose to log the events that alter security of the system. I don't see how loading/unloading bpf program influences security at the time of the load. The actions that program may take later (like dropping a packet in XDP due to firewalling reasons) can be considered security related, but not at the time of prog load. Classic bpf for sockets and seccomp has been around for long time, but seccomp audit messages don't trigger on bpf load/unload, but rather on events like killing a process due to seccomp bpf return value. If the purpose of the patch is to give user space visibility into bpf prog load/unload as a notification, then I completely agree that some notification mechanism is necessary. I've started working on such mechanism via perf ring buffer which is the fastest mechanism we have in the kernel so far. See long discussion here: https://patchwork.ozlabs.org/patch/971970/ Essentially we need perf binary to see bpf prog load/unload events with single argument bpf_prog_id to be able to do its job. I think from bpf kernel side there should be only one mechanism for user space notifications and perf ring buffer fits the best, since amount of load/unload in the system can be very large. Anything but ring buffer will likely choke under volume of events. Audit is not suitable for such notifications. If in the future we have something other than seccomp killing task via bpf return values, such code points would be good candidates for audit logging.