Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1449047 > unrolled thread

Relax kern_version constraints on bpf kprobes?

Started bySargun Dhillon <sargun@sargun.me>
First post2016-07-24 06:10 +0200
Last post2016-07-24 06:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  Relax kern_version constraints on bpf kprobes? Sargun Dhillon <sargun@sargun.me> - 2016-07-24 06:10 +0200
    Re: Relax kern_version constraints on bpf kprobes? Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-07-24 06:40 +0200

#1449047 — Relax kern_version constraints on bpf kprobes?

FromSargun Dhillon <sargun@sargun.me>
Date2016-07-24 06:10 +0200
SubjectRelax kern_version constraints on bpf kprobes?
Message-ID<rYiTM-37U-15@gated-at.bofh.it>
In kernel/bpf/syscall.c we restrict programs loading bpf kprobe programs so 
attr.kern_version must be exactly equal to what the user is running at the 
moment. This makes a lot of sense because kprobes can touch lots of
unstable bits of the kernel ABI. 

Unfortunately, this makes it really difficult to ship binary bpf programs
for debugging, and most customers don't want to go through all the steps
of preparing for compilation and installation of bpf programs for their 
specific kernel that was shipped by their vendor. 

This is especially problematic when the probe is touching only stable ABIs
(syscalls), or alternatively is just logging performance events. I realize
that we can change this section pretty easily by reading the version at
load time and modifying it, but it's kind of a pain.

For programs that we know are safe, is there a mechanism by which we can
bypass this check, and tell the loader that we know what we're doing
since these programs are only accessible to CAP_SYS_ADMIN?

[toc] | [next] | [standalone]


#1449049

FromAlexei Starovoitov <alexei.starovoitov@gmail.com>
Date2016-07-24 06:40 +0200
Message-ID<rYjmN-3jU-1@gated-at.bofh.it>
In reply to#1449047
On Sat, Jul 23, 2016 at 09:01:39PM -0700, Sargun Dhillon wrote:
> In kernel/bpf/syscall.c we restrict programs loading bpf kprobe programs so 
> attr.kern_version must be exactly equal to what the user is running at the 
> moment. This makes a lot of sense because kprobes can touch lots of
> unstable bits of the kernel ABI. 
> 
> Unfortunately, this makes it really difficult to ship binary bpf programs
> for debugging, and most customers don't want to go through all the steps
> of preparing for compilation and installation of bpf programs for their 
> specific kernel that was shipped by their vendor. 
> 
> This is especially problematic when the probe is touching only stable ABIs
> (syscalls), or alternatively is just logging performance events. I realize
> that we can change this section pretty easily by reading the version at
> load time and modifying it, but it's kind of a pain.
> 
> For programs that we know are safe, is there a mechanism by which we can
> bypass this check, and tell the loader that we know what we're doing
> since these programs are only accessible to CAP_SYS_ADMIN?

The proper alternative is to always compile programs on the fly
for the given kernel like iovisor/bcc does. Integrated clang/llvm
has other advantages, like being able to search/replace in bpf C program
before installing it in the kernel. So different command line flags
come with zero overhead when not in use.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web