You are viewing documentation for Falco version: v0.37.1

Falco v0.37.1 documentation is no longer actively maintained. The version you are currently viewing is a static snapshot. For up-to-date documentation, see the latest version.

Kernel Events

Events related to the Kernel tells us most of what happens above.

Falco uses different instrumentations to analyze the system workload and pass security events to userspace. We usually refer to these instrumentations as drivers since a driver runs in kernelspace. The driver provides the syscall event source since the monitored events are strictly related to the syscall context.

There are several supported drivers:

  • Kernel module (default)
  • Modern eBPF probe
  • Legacy eBPF probe
Kernel moduleLegacy eBPF probeModern eBPF probe
x86_64>= 2.6>= 4.14Minimal set of features
aarch64>= 3.4>= 4.17Minimal set of features

Kernel module

By default, the kernel module will be installed when installing the Falco debian/rpm package, when running the falcoctl driver tool shipped within the binary package, or when running the falcosecurity/falco-driver-loader docker image (that just wraps the aforementioned tool).

To install the kernel module, please refer to the installation page.

Least privileged mode

The kernel module requires full privileges and cannot run with Linux capabilities

Modern eBPF probe

The modern eBPF probe is an alternative driver for Falco. The main advantage it brings to the table is that it is embedded into Falco, which means that you don't have to download or build anything, if your kernel is recent enough Falco will automatically inject it!

What's new

The new probe is highly customizable, you are not obliged to use one buffer for each CPU you can also use just one huge buffer for all your CPUs! And obviously, also the buffer size is customizable! All this is possible thanks to new outstanding features like the CO-RE paradigm, the BPF ring buffer and many others, if you are curious you can read more about them in this blog post.

Requirements

The modern eBPF probe doesn't require a specific kernel version. Usually, all versions >=5.8 are enough but there are cases in which the required features could also be backported into older kernels, so it wouldn't be completely fair to define 5.8 as the first supported version. The 2 main required features are:

  1. BPF ring buffer support.
  2. A kernel that exposes BTF.

Falco can automatically detect if these features are available on the running machine and can notify you if something is missing. As an alternative, you could always use bpftool, you just need to type the following commands:

sudo bpftool feature probe kernel | grep -q "map_type ringbuf is available" && echo "true" || echo "false" 
sudo bpftool feature probe kernel | grep -q "program_type tracing is available" && echo "true" || echo "false" 

How to run it

Modern eBPF probe is bundled into the userspace binary and works out of the box, regardless of the kernel release, thanks to the eBPF feature called 'Compile Once Run Everywhere' (CO-RE). To enable it in Falco, just set the engine.kind configuration key to modern_ebpf.

It is supported in all the installation methods of other drivers:

Useful resources

Least privileged mode

The minimal set of capabilities required by Falco to run the modern eBPF probe is the following:

  • CAP_SYS_BPF
  • CAP_SYS_PERFMON
  • CAP_SYS_RESOURCE
  • CAP_SYS_PTRACE

Let's see them in detail:

  • CAP_SYS_RESOURCE: Falco needs this capability to be able to call the setrlimit syscall. The setrlimit syscall is used together with the RLIMIT_MEMLOCK flag to change the amount of memory that can be mlocked into RAM. The default value for this memory limit is very low, so even a very simple eBPF program would fail. The workaround is to increase the default value to something acceptable so eBPF maps can be correctly mlocked in memory.
  • CAP_SYS_PTRACE: Falco needs this capability because it accesses paths like /proc/<pid>/environ. From the userspace standpoint, the permission to do so is mapped to the CAP_SYS_PTRACE capability. For the curious reader, see environ_open implementation in the kernel.
  • CAP_SYS_ADMIN: Falco needs this capability to load eBPF programs and maps, and to interact with the system using the bpf syscall.

This set of capabilities should work most of the time but under some conditions, it is possible to replace the CAP_SYS_ADMIN with two more granular capabilities: CAP_SYS_BPF and CAP_SYS_PERFMON.

The only condition needed is a kernel version that supports these capabilities. The Linux Kernel version 5.8 is the first one that officially supports them but they could have been backported on older versions on some distributions.

Please note: we will try to do our best to keep this as the minimum required set but due to some issues with CO-RE relocations it is possible that this changes in the future.

Legacy eBPF probe

The legacy eBPF probe is an alternative source to the ones described above, leveraging greater compatibility than the modern eBPF one, since it requires older kernel versions.

To install the eBPF probe, please refer to the installation page.

To enable the eBPF support in Falco set the engine.kind configuration key to ebpf and eventually customize engine.ebpf.probe to the path where the eBPF probe resides; the default path is the location used by falcoctl driver tool to install the eBPF probe, ie: ${HOME}/.falco/falco-bpf.o, where ${HOME} will expand to the home dir of the user running Falco.

Least privileged mode

The minimal set of capabilities required by Falco to run the legacy eBPF probe is the following:

  • CAP_SYS_ADMIN
  • CAP_SYS_RESOURCE
  • CAP_SYS_PTRACE

The mentioned capabilities require no further explanation since they were already discussed in detail in the modern eBPF probe section. Moreover, for legacy eBPF probe the kernel.perf_event_paranoid sysctl value must also be double checked: reading the manual it is stated that perf_event_paranoid influences only the behavior of unprivileged users, but under the hood, some distributions like Debian or Ubuntu introduce additional perf_event_paranoid levels. Consider Ubuntu as an example:

if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
  return -EACCES;

// where perf_paranoid_any is defined as:
static inline bool perf_paranoid_any(void) {
  return sysctl_perf_event_paranoid > 2;
}

As you can notice, when your kernel.perf_event_paranoid is >2 the capability CAP_PERFMON won't suffice, you would still need CAP_SYS_ADMIN. So before disabling CAP_SYS_ADMIN check your perf_event_paranoid value with sysctl kernel.perf_event_paranoid and make sure their values are compatible with your distribution enforcement.