Commit Graph
53519 Commits
Author SHA1 Message Date
Yu Watanabe a73628e647 network: rename IPv6Token= in [Network] -> Token= in [IPv6AcceptRA]
The token is only used by received prefixes through RA.
2021-10-07 01:16:36 +09:00
Yu Watanabe 868bd1aa1c network: address-genereation: introduce generate_addresses()
Preparation for later commits. This does not change functionality.
2021-10-07 01:16:29 +09:00
Yu Watanabe d207581fc5 network: address-generation: use in6_addr_hash_ops_free
Also, downgrade error level, and caller logs the error.
2021-10-07 01:14:51 +09:00
Yu Watanabe 3bac5fe6c9 network: address-generation: modernize config_parse_address_generation_type()
- drop unused _NONE type,
- rename IPv6Token::prefix -> IPv6Token::address,
- clear unused part of IPv6Token::address,
- use Set, instead of OrderedSet.
2021-10-07 01:14:51 +09:00
Yu Watanabe ffb834cb87 network: address-generation: mask prefix with prefixlen for safety 2021-10-07 01:14:51 +09:00
Yu Watanabe 98692ff3b8 network: address-generation: always start DAD counter from zero
The token is stored in Network, and the .network file may be applied to
multiple links.
2021-10-07 01:14:51 +09:00
Yu Watanabe ac77e0b315 network: address-generation: always use the first 64 bits of the prefix
Hopefully, the prefix length is usually 64.

Previously, if the prefix length is smaller than 64, the result address
was undefined.
2021-10-07 01:14:51 +09:00
Yu Watanabe 151b8ea304 network: ndisc: ignore autonomous prefix with prefix length larger than 64 2021-10-07 01:14:47 +09:00
Yu Watanabe fcd7ad52d7 network: radv: ignore Assign= if prefixlen is larger than 64 2021-10-07 01:09:09 +09:00
Yu Watanabe 00f1261d39 network: make generate_ipv6_eui_64_address() take prefix
Also, rename the function.
2021-10-07 01:03:06 +09:00
Yu Watanabe 397c5418f0 network: fix prefixlen for reserved subnet anycast address
Then, the prefixlen is not a multiplier of 8, we need to use
in6_addr_prefix_covers().

This also constify the reserved addresses, and rename macros.
2021-10-07 01:03:06 +09:00
Yu Watanabe f09a474760 network: move address generation methods to network-address-generation.[ch] 2021-10-07 01:03:06 +09:00
Yu Watanabe e174b43fe4 in-addr-util: introduce in{4,6}_addr_prefix_covers() 2021-10-07 01:03:06 +09:00
Yu Watanabe 6df860f3a0 in-addr-util: do not shift 8 or more for uint8_t
See ISO/IEC 9899:TC3 § 6.5.7.3.
2021-10-07 01:03:06 +09:00
Yu Watanabe 333f7d8920 in-addr-util: introduce in{4,6}_addr_mask() 2021-10-07 01:03:06 +09:00
Yu Watanabe f1cb8933c3 in-addr-util: introduce in6_addr_hash_ops_free 2021-10-07 01:03:06 +09:00
Yu Watanabe 0943b3b7a4 network: radv: reorder functions
In other files, we usually (but not always) place functions in the following order:
- network_adjust_xxx(), which applies default or updates settings
  specified in .network files,
- link_xxx_enabled(), which checks if the functionality is enabled,
- xxx_new() and xxx_free(), allocator and deallocator for sections,
- functions which apply/update/remove configs
- validators of section,
- conf parsers.

This does not change each function, but just changes the order.
2021-10-07 01:02:59 +09:00
Lennart Poettering 9a1ddc8dee Merge pull request #18145 from kinvolk/iaguis/lsm-bpf
Add RestrictFileSystems= property using LSM BPF
2021-10-06 16:23:27 +02:00
Lennart Poettering 8b4f88d136 user-record: disable two pbkdf fields that don't apply for pkbdf2
Fixes: #20830
2021-10-06 16:21:09 +02:00
chlorophyll-zz 1d3d81cf01 Update 60-sensor.hwdb
#20287 was wrong. 
Y Axis was only reversed on Arch Linux because of a problem with iio-sensor-proxy
This restores before the patch.
2021-10-06 13:11:41 +01:00
Zbigniew Jędrzejewski-Szmek e5f093bf99 man: add discussion of read-only filesystem support in daemons
This is inspired by https://bugzilla.redhat.com/show_bug.cgi?id=1853293.  Let's
mention that applications should be prepared for /var being read-only.
2021-10-06 09:54:17 +01:00
Iago López Galeiras 20080622de man: document systemd-analyze filesystems 2021-10-06 10:52:15 +02:00
Iago López Galeiras b41711cd46 analyze: add filesystems command 2021-10-06 10:52:15 +02:00
Iago López Galeiras ec31dd5a98 README: document LSM BPF requirements 2021-10-06 10:52:15 +02:00
Iago López Galeiras 8216741cf9 test: add test-bpf-lsm 2021-10-06 10:52:15 +02:00
Iago López Galeiras d6d6f55d8e man: document EXIT_BPF status 2021-10-06 10:52:14 +02:00
Iago López Galeiras a6826f6b8e man: add RestrictFileSystems= documentation 2021-10-06 10:52:14 +02:00
Iago López Galeiras af11239196 mkosi: add libbpf dependency
For distros that ship libbpf >=0.2.0.
2021-10-06 10:52:14 +02:00
Iago López Galeiras cc86a278de core: add dbus RestrictFileSystems= properties 2021-10-06 10:52:14 +02:00
Iago López Galeiras e59ccd035c core: add RestrictFileSystems= fragment parser
It takes an allow or deny list of filesystems services should have
access to.
2021-10-06 10:52:14 +02:00
Iago Lopez Galeiras b1994387d3 core: use LSM BPF functions to implement RestrictFileSystems=
It attaches the LSM BPF program when the system manager starts up.

It populates the hash of maps BPF map when services that have
RestrictFileSystems= set start.

It cleans up the hash of maps when the unit cgroup is pruned.

To pass the file descriptor of the BPF map we add it to the keep_fds
array.
2021-10-06 10:52:14 +02:00
Iago Lopez Galeiras 184b4f78cf 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.
2021-10-06 10:52:14 +02:00
Iago López Galeiras 510cdbeb5b shared/bpf-dlopen: expose more libbpf functions
They're needed for the LSM BPF feature.
2021-10-06 10:52:14 +02:00
Iago López Galeiras d13b60d8af exit-status: add EXIT_BPF
It will be used later.
2021-10-06 10:52:14 +02:00
Iago López Galeiras 535e3dd091 cgroup-util: add cg_path_get_cgroupid()
It returns the cgroupID from a cgroup path.
2021-10-06 10:52:14 +02:00
Iago López Galeiras 021d1e9612 bpf: add restrict_fs BPF program
It hooks into the file_open LSM hook and allows only when the filesystem
where the open will take place is present in a BPF map for a particular
cgroup.

The BPF map used is a hash of maps with the following structure:

    cgroupID -> (s_magic -> uint32)

The inner map is effectively a set.

The entry at key 0 in the inner map encodes whether the program behaves
as an allow list or a deny list: if its value is 0 it is a deny list,
otherwise it is an allow list.

When the cgroupID is present in the map, the program checks the inner
map for the magic number of the filesystem associated with the file
that's being opened. When the program behaves as an allow list, if that
magic number is present it allows the open to succeed, when the program
behaves as a deny list, it only allows access if the that magic number
is NOT present. When access is denied the program returns -EPERM.

The BPF program uses CO-RE (Compile-Once Run-Everywhere) to access
internal kernel structures without needing kernel headers present at
runtime.
2021-10-06 10:52:14 +02:00
Iago López Galeiras 659d19243c basic: use filesystem database 2021-10-06 10:52:14 +02:00
Iago López Galeiras 1315ce3120 basic: add filesystem database
Stores filesystem_name -> magic_number(s).
2021-10-06 10:52:10 +02:00
Iago López Galeiras 3ef4e91abe missing_magic: add several filesystems
They were failing on CI.
2021-10-06 10:48:32 +02:00
Iago Lopez Galeiras 2ac5f90d59 basic: move CIFS magic number to missing_magic.h
It fits better there.
2021-10-06 10:48:32 +02:00
Lennart Poettering 95ef0eaf0d unit-file: tighten unit file discovery checks
Only accept DT_REG/DT_LNK/DT_DIR entries, ignore all others.

Only accpet DT_REG/DT_LNK for file names that are valid unit file names.

Only accept DT_DIR for filenames that are valid unit file names which
are suffixed by .d, .wants, .requires

This doesn't really fix any bugs, but tightens what we insert into the
lookup tables.
2021-10-06 12:28:19 +09:00
Yu Watanabe 1eb3ef78b4 Merge pull request #20937 from poettering/sync-split
split up a few files in src/basic/
2021-10-06 12:27:27 +09:00
Andrew Soutar 5ef97a7122 basic/env-util: correctly parse extended vars after non-extended vars (#20941) 2021-10-06 11:55:27 +09:00
Lennart Poettering 8ac04a6547 repart: use right error variable 2021-10-05 19:41:35 +01:00
Lennart Poettering 01bebba3de basic: move chase_symlinks_and_fopen_unlocked() → chase-symlinks.[ch] 2021-10-05 19:37:30 +01:00
Lennart Poettering f435195925 basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch] 2021-10-05 16:14:37 +02:00
Lennart Poettering 9e5fd71799 basic: split out inotify-related calls from fs-util.h → inotify-util.h 2021-10-05 16:14:37 +02:00
Lennart Poettering d8e32c471f basic: split out glyph/emoji related calls from locale-util.[ch] into glyph-util.[ch]
These functions are used pretty much independently of locale, i.e. the
only info relevant is whether th locale is UTF-8 or not. Hence let's
give this its own pair of .c/.h files.
2021-10-05 16:14:37 +02:00
Lennart Poettering bf819d3ac2 basic: split out sync() family of calls from fs-util.[ch] into new c/h file
No changes in code, just some splitting out.
2021-10-05 15:47:32 +02:00
Luca Boccassi e66ee1d7e6 Merge pull request #20893 from poettering/per-user-oom-score
default to higher oom scores for user sessions
2021-10-05 09:54:24 +01:00