falco: Cannot run falco "Least Privileged", pmu_fd: operation not permitted
Describe the bug
Falco container fails to start with error:
Error: pmu_fd: Operation not permitted
See Logs section below for more info.
How to reproduce it
- Install falco on AKS (1.25.6) using helm chart version 3.1.3 and following values:
podAnnotations:
container.apparmor.security.beta.kubernetes.io/falco: unconfined
tty: false
controller:
kind: daemonset
driver:
enabled: true
kind: ebpf
ebpf:
hostNetwork: true
leastPrivileged: true
collectors:
enabled: true
- Notice the error in the logs and the crashing pods
Expected behaviour
Falco runs without error
Logs
Logs of the starting pod, Falco:
Tue Apr 11 21:41:52 2023: Falco version: 0.34.1 (x86_64)
Tue Apr 11 21:41:52 2023: Falco initialized with configuration file: /etc/falco/falco.yaml
Tue Apr 11 21:41:52 2023: Loading rules from file /etc/falco/falco_rules.yaml
Tue Apr 11 21:41:52 2023: Loading rules from file /etc/falco/rules.d/custom.local.yaml
Tue Apr 11 21:41:52 2023: The chosen syscall buffer dimension is: 8388608 bytes (8 MBs)
Tue Apr 11 21:41:52 2023: gRPC server threadiness equals to 4
Tue Apr 11 21:41:52 2023: Starting health webserver with threadiness 4, listening on port 8765
Tue Apr 11 21:41:52 2023: Enabled event sources: syscall
Tue Apr 11 21:41:52 2023: Opening capture with BPF probe. BPF probe path: /root/.falco/falco-bpf.o
Tue Apr 11 21:41:52 2023: Starting gRPC server at unix:///run/falco/falco.sock
Tue Apr 11 21:41:52 2023: An error occurred in an event source, forcing termination...
Tue Apr 11 21:41:52 2023: Shutting down gRPC server. Waiting until external connections are closed by clients
Tue Apr 11 21:41:52 2023: Waiting for the gRPC threads to complete
Tue Apr 11 21:41:52 2023: Draining all the remaining gRPC events
Tue Apr 11 21:41:52 2023: Shutting down gRPC server complete
Error: pmu_fd: Operation not permitted
Events detected: 0
Rule counts by severity:
Triggered rules by rule name:
Logs of the driver loader
* Setting up /usr/src links from host
* Running falco-driver-loader for: falco version=0.34.1, driver version=4.0.0+driver, arch=x86_64, kernel release=5.15.0-1034-azure, kernel version=41
* Running falco-driver-loader with: driver=bpf, compile=yes, download=yes
* Mounting debugfs
mount: /sys/kernel/debug: cannot mount nodev read-only.
* Filename 'falco_ubuntu-azure_5.15.0-1034-azure_41.o' is composed of:
- driver name: falco
- target identifier: ubuntu-azure
- kernel release: 5.15.0-1034-azure
- kernel version: 41
* Trying to download a prebuilt eBPF probe from https://download.falco.org/driver/4.0.0%2Bdriver/x86_64/falco_ubuntu-azure_5.15.0-1034-azure_41.o
* Skipping compilation, eBPF probe is already present in /root/.falco/4.0.0+driver/x86_64/falco_ubuntu-azure_5.15.0-1034-azure_41.o
* eBPF probe located in /root/.falco/4.0.0+driver/x86_64/falco_ubuntu-azure_5.15.0-1034-azure_41.o
* Success: eBPF probe symlinked to /root/.falco/falco-bpf.o
Environment
-
Falco version: Falco version: 0.34.1 (x86_64)
-
Cloud provider or hardware configuration: AKS (1.25.6)
-
OS: PRETTY_NAME=“Ubuntu 22.04.2 LTS” NAME=“Ubuntu” VERSION_ID=“22.04” VERSION=“22.04.2 LTS (Jammy Jellyfish)” VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL=“https://www.ubuntu.com/” SUPPORT_URL=“https://help.ubuntu.com/” BUG_REPORT_URL=“https://bugs.launchpad.net/ubuntu/” PRIVACY_POLICY_URL=“https://www.ubuntu.com/legal/terms-and-policies/privacy-policy” UBUNTU_CODENAME=jammy
-
Kernel:
5.15.0-1034-azure #41-Ubuntu SMP Fri Feb 10 19:59:45 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux -
Installation method: Helm chart version version: 3.1.3
Additional context
I tested with both no AppArmor configuration and with unconfined given the notice mentioned in the doc : https://falco.org/docs/getting-started/running/#docker-least-privileged. However, both configurations provide the same error.
Also, falco works fine if using leastPrivileged: false, here is an example of normal logs:
Tue Apr 11 22:04:35 2023: Falco version: 0.34.1 (x86_64)
Tue Apr 11 22:04:35 2023: Falco initialized with configuration file: /etc/falco/falco.yaml
Tue Apr 11 22:04:35 2023: Loading rules from file /etc/falco/falco_rules.yaml
Tue Apr 11 22:04:35 2023: The chosen syscall buffer dimension is: 8388608 bytes (8 MBs)
Tue Apr 11 22:04:35 2023: Starting health webserver with threadiness 4, listening on port 8765
Tue Apr 11 22:04:35 2023: Enabled event sources: syscall
Tue Apr 11 22:04:35 2023: Opening capture with BPF probe. BPF probe path: /root/.falco/falco-bpf.o
22:05:19.262671245: Notice Unexpected connection to K8s API Server from container (command=python -u /app/sidecar.py pid=9171 k8s.ns=monitoring k8s.pod=kube-prometheus-stack-grafana-684679fcd6-gpn2b container=541747452f5f image=quay.io/kiwigrid/k8s-sidecar:1.19.2 connection=10.176.16.103:44470->192.168.0.1:443)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 42 (28 by maintainers)
yep, that was intentional because the modern probe was an experimental feature in Falco 0.34 and we were not sure about the least privileged support, but it seems to work well so we will update the helm chart for Falco 0.35 since the modern probe will be an officially supported driver 😃!
Related to the initial issue here with
CAP_PERFMONandCAP_BPF:Recent kernels (>=5.8) introduced new capabilities to split
CAP_SYS_ADMINinto several capabilities (for exampleCAP_PERFMONandCAP_BPF). So if you have a recent enough kernel you should be able to run the old probe and the modern probe with new capabilities. Unfortunately, this is not as simple as it sounds… There is a second variable to take into consideration:kernel.perf_event_paranoid. Reading the manual it seems thatperf_event_paranoidinfluences only the behavior of unprivileged users, if you have the right capabilities all should work fineBut under the hood, some distros like Debian and Ubuntu introduce other
perf_event_paranoidlevels, see Ubuntu here: https://kernel.ubuntu.com/git/ubuntu-stable/ubuntu-stable-jammy.git/tree/kernel/events/core.c#n11991where
perf_paranoid_any()isAs you can easily notice if your
kernel.perf_event_paranoidis >2CAP_PERFMONwill be not enough, you will needCAP_SYS_ADMIN! that’s the reason why the old probe could work withCAP_PERFMON + CAP_BPFonly on some nodes, probably in these nodeskernel.perf_event_paranoidis <= 2Supposing that kernel 5.8 is the first one with
CAP_BPFandCAP_PERFMONavailable (this could be not true it really depends on you kernel patches/backports):old probe:
CAP_SYS_ADMINkernel.perf_event_paranoid <= 2-> can useCAP_BPFandCAP_PERFMONkernel.perf_event_paranoid > 2-> it really depends on your distro but usually needsCAP_SYS_ADMINmodern probe:
CAP_SYS_ADMINCAP_BPFandCAP_PERFMON(the modern probe use theBPF ring-bufferso no need ofkernel.perf_event_paranoid@Andreagit97 I just tested it and it works like a charm! Thank you for the hard and good work!!
Sounds about right:
Works great on the Ubuntu AKS cluster as well. Replied to the other issue about AzureLinux @tspearconquest
Feel free to close this one
Thank you for the update I’m working on that!
thanks!