This group is locked. No changes can be made to the group while it is locked.
Re: bpf_probe_read() split: bpftrace RFC
Matheus Marchini <mat@...>
How will bpf_probe_read_user/bpf_probe_read_kernel be enforced in the
Kernel? In other words, how bpf_probe_read_user will detect and report when it get's a Kernel address as parameter, and vice-versa? Will it be accomplished by the verifier (is it even possible to do this reliably with the verifier) or only on runtime? If the kernel will only test it during runtime, and it returns an unique error code (different than errors that probe_read can return today, we might need to create a new error code) , we could do the following for the dereference operands (*/str()): typedef int (probe_read_t)(void *dst, int size, void *src); // Assuming bpf_probe_read_[user,kernel] will return EINVALADDRSPC // if the user tires to access an address with the wrong function int err; // space_ctx is defined according to Brendan's email probe_read_t default_probe_read; = space_ctx == KERNEL ? bpf_probe_read_kernel : bpf_probe_read_user; probe_read_t fallback_probe_read; if (addr_space_ctx == KERNEL) { default_probe_read = bpf_probe_read_kernel; fallback_probe_read = bpf_probe_read_user; } else { default_probe_read = bpf_probe_read_user; fallback_probe_read = bpf_probe_read_kernel; } if (err = (*default_probe_read)(dst, size, src) == EINVALADDRSPC) { err = (*fallback_probe_read)(dst, size, src); } if (err < 0) { bpf_trace_printk("Error while reading address %x\n", src); return; } With this approach we can avoid breaking any scripts. The only difference is that it will add more overhead when the fallback probe_read is used (and if the user is affected by this overhead, they can still use kptr/uptr/kstr/ustr). We could also: print to stdout/syslog when the fallback method is used if bpftrace is running in verbose mode, and provide a "strict" mode which would not try to run the fallback probe_read. On Thu, Jun 13, 2019 at 11:32 AM Brendan Gregg <brendan.d.gregg@...> wrote:
|