]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: add BPF LSM functions
authorIago Lopez Galeiras <iagol@microsoft.com>
Tue, 13 Jul 2021 07:51:06 +0000 (09:51 +0200)
committerIago Lopez Galeiras <iagol@microsoft.com>
Wed, 6 Oct 2021 08:52:14 +0000 (10:52 +0200)
commit184b4f78cfbded54a6e06bbe1152256c204a7a73
treec2ba69bab7524fe384aece04684a2cec64e13d7f
parent510cdbeb5ba841c9e9d9fa62303ecb2673b77b9e
core: add BPF LSM functions

This adds 6 functions to implement RestrictFileSystems=

* lsm_bpf_supported() checks if LSM BPF is supported. It checks that
  cgroupv2 is used, that BPF LSM is enabled, and tries to load the BPF
  LSM program which makes sure BTF and hash of maps are supported, and
  BPF LSM programs can be loaded.
* lsm_bpf_setup() loads and attaches the LSM BPF program.
* lsm_bpf_unit_restrict_filesystems() populates the hash of maps BPF map with the
  cgroupID and the set of allowed or denied filesystems.
* lsm_bpf_cleanup() removes a cgroupID entry from the hash of maps.
* lsm_bpf_map_restrict_fs_fd() is a helper function to get the file
  descriptor of the BPF map.
* lsm_bpf_destroy() is a wrapper around the destroy function of the BPF
  skeleton file.
src/core/bpf-lsm.c [new file with mode: 0644]
src/core/bpf-lsm.h [new file with mode: 0644]
src/core/cgroup.c
src/core/manager.h
src/core/meson.build
src/core/unit.h