bpf-firewall: optimization for IPAddressXYZ="any" (and unprivileged users)
authorAnita Zhang <the.anitazha@gmail.com>
Mon, 20 May 2019 21:43:53 +0000 (14:43 -0700)
committerLennart Poettering <lennart@poettering.net>
Sat, 22 Jun 2019 17:56:06 +0000 (19:56 +0200)
commit4c1567f29aeb60a6741874bca8a8e3a0bd69ed01
treeee5208b59a919c35e36a5bb477ef708b75177bde
parente48fcfef06d81bf08607d3c1657fdc6aa1e9a6ee
bpf-firewall: optimization for IPAddressXYZ="any" (and unprivileged users)

This is a workaround to make IPAddressDeny=any/IPAddressAllow=any work
for non-root users that have CAP_NET_ADMIN. "any" was chosen since
all or nothing network access is one of the most common use cases for
isolation.

Allocating BPF LPM TRIE maps require CAP_SYS_ADMIN while BPF_PROG_TYPE_CGROUP_SKB
only needs CAP_NET_ADMIN. In the case of IPAddressXYZ="any" we can just
consistently return false/true to avoid allocating the map and limit the user
to having CAP_NET_ADMIN.
src/core/bpf-firewall.c
src/core/ip-address-access.c
src/core/ip-address-access.h