6 ms·
IP Accounting and Access Lists with Systemd
- freedomben 9y agoThe clarity and depth that Lennart writes with is always impressive to me. Another highly educational post from a master.
- alphaalpha101 9y agoAnother systemd release, another bloating of the attack surface of the now-standard init system. I'm sure this is useful but init is absolutely the wrong place for it.
- deleted 9y ago[deleted]
- jlgaddis 9y agoMany moons ago, support for TCP wrappers was removed from systemd -- and, a bit later, OpenSSH, IIRC. Fine, I understand. Personally, I still like tcpd (it's an extra layer) and I still use it... but I realize that not very many others do. Okay, I can live with this decision. Then, about two weeks ago, Red Hat decides they're gonna deprecate TCP wrappers, with a Red Hat employee saying: > TCP wrappers is a simple tool to block incoming connection on application level. This was very useful 20 years ago, when there were no firewalls in Linux. This is not the case for today and connection filtering should be done in network level or completely in application scope if it makes sense. Okay, fine. I still think it's useful as an extra layer but, nobody really uses it so, sure, let's get rid of it. I'm on board. Now, all of a sudden, this functionality shows up in systemd (announced yesterday)? Really!? This is (one of the) reason(s) why some of us greybeards loathe systemd (and just when I was starting to become "okay" with it, too).
- icebraining 9y agoWell, as the article points out, the systemd functionality is only a wrapper to the kernel's network filtering system (eBPF). It's not like they reimplemented TCPwrappers. You can also configure it without systemd. Julia Evans has a pretty good introduction to it: https://jvns.ca/blog/2017/04/07/xdp-bpf-tutorial/ https://jvns.ca/blog/2017/04/07/xdp-bpf-tutorial/
- Jasper_ 9y agoBecause, as the engineer says, this filtering should be done at the network level, not with a TCP wrapper, a leaky userspace abstraction. systemd does this at the network level, with kernel APIs.
- marios 9y agoOn the one hand, the user facing aspect of this feature as presented in this article seems really nice. On the other hand, it's another abstraction over rather new kernel APIs. Your average user may know of NetFilter kernel component, and the iptables userland counterpart. Some may even have heard of nftables. How many users know about eBPF/XDP ? More importantly, how many sysadmins know how to debug this when something goes wrong ? I'm aware there's a lot of development around eBPF and a number of players (Facebook, CloudFlare, ...) are already using XDP because of the ridiculous performance gain it provides for their use-cases. There's a myriad of frontends to iptables and yet they all suck. Each of them fail in mysterious ways and at that point the only way to debug what's wrong is to look at the ruleset with ... iptables. A package could ship with IP filtering in its service file, which may not match what the user expected. The symptom "service does not respond to TCP connections" is well known. In that case, it's common to check the process is alive (using ps), it has setup listening sockets (using netstat) and that the system firewall is not blocking it (using iptables/nftables or some frontend). Figuring out it's a eBPF/XDP misconfiguration is going to be painful IMHO. systemd attempts to cooperate with the system firewall. The subtlety is that there are now two facilities in the kernel that provide firewalling, and both can be on at the same time. To be honest, I don't even know which one has precedence. Why exactly does systemd need to mess with the networking services ? AFAIK, its primary function is that of a service manager; i.e: reliably bring services up and down. I feel all the rest should not be systemd's concern. After using systemd for quite some time, I've come to the conclusion that it works rather well when it sticks to starting/stopping services, assuming your service fits the systemd model. If it doesn't, debugging is extremely difficult and you often have to resort to dirty hacks to end up with a functionning system -- which is ironic considering one of systemd's motivations was to get rid of the dirty hacks in initscripts. An example of a buggy use case is when you need to pass environment variables to your executable and there's escaping involved. The systemd documentation suggests you can pass pretty much anything in the ExecStart lines. However, the reality is that it does not behave as other environments. The solution is to store the variables in a separate file, and not involve systemd at all. My takeaway is: why does systemd involve so many features ? It increases failure cases as well as the cognitive load required when dealing with it.
- binaryapparatus 9y agoI don't know if I am more amazed with systemd engineering incompetence or the wider community that doesn't seem to see what's going on. I went from wondering why/what is going on to switching all my home/work/server machines to FreeBSD. Common response from the systemd groupies is to focus on technical bits and be precise but you can't focus on them if the concept/ideas/execution smell. Also, number of wrongly planned or wrongly executed bits counts in hundreds by now. Like cooking a frog.
- prrls 9y ago> I went from wondering why/what is going on to switching all my home/work/server machines to FreeBSD. Can you develop on some of the reasons that convinced you to run away from systemd ? I'm really curious to know why (honestly). Thanks :).
- binaryapparatus 9y agoThis is not even the best source of information but it shows the same trend I was spotting: https://suckless.org/sucks/systemd https://suckless.org/sucks/systemd There are similar sources on the internet that claim the same thing in different forms. Every single bad systemd decision is not terribly bad on its own, but when observed as a process they result in a horribly wrong and very insecure system. With systemd, there i crawling revolution of bad ideas, bad implementation and taking over of everything that was great in linux. When you try discussing any of those items separately you'll be redirected to 'technical discussion' and you can't really technically discuss conceptually wrong system. With bad concept it doesn't really matter how technically good or bad implementation is. Maybe the best telling thread, in order to understand how pushy and deceptive whole systemd is, is watching how Greg Kroah-Hartman tried to sneak kdbus into a kernel: https://lkml.org/lkml/2015/4/13/645 https://lkml.org/lkml/2015/4/13/645 It is very long mailing list thread and GH is not officially part of the systemd team -- only that he is, unofficially. He claims that kdbus brings great benefits and speedup only that he can't prove it. Every questioning of a very wrong concept is met by requesting of 'technical discussion'. If you have patience just read that lkml thread and you'll see the same sneaky politics of pushing things the same way that systemd people do it all the time.
- poettering 9y ago> Really!? This is (one of the) reason(s) why some of us greybeards loathe systemd (and just when I was starting to become "okay" with it, too). I am not sure why you imply that there was some evil scheme behind all this. In reality, things are a bit different: one group at Red Hat decided to put an end to TCP wrappers (which btw is something other distros already did a while back, we are late at the party), and another group then offered to make a more modern replacement available, that could cover some of the uses, in order not leave users in the cold. I am not sure why you think that's an evil thing to do? Isn't it nicer to drop something with a suggestion how to replace it then to drop it without replacement? Also, let's not forget: this functionality is implemented in the kernel, systemd merely adds knobs to expose this kernel functionality to the user. Hence, no, this functionality didn't really "show up in systemd". It showed up in the kernel, and systemd just wraps it to make it usable. I mean, this is a dilemma, isn't it? Whatever we do you are unhappy, right? ;-) Lennart
- reacweb 9y agoI do not think he is unhappy about this feature in systemd. He complains about the process and communication: removing a feature arguing it is useless then providing a replacement. Personally, I am very pleased with systemd and thanks to its novelty, it puts me on a same level as all the "greybeards". Continue the good work and please, take special care of the man pages.
- thwarted 9y agoI am not sure why you imply that there was some evil scheme behind all this. He didn't imply or say there was some evil scheme, and this reads like an attempt to play the victim card on your part. If no one uses the functionality is the reason for getting rid of it, then why add it back in? I seems like a lot of useless busy work to explicitly claim that no one uses something only to replace it.
- throwme211345 9y agoLennart: you are a well paid tool and your designs and causes are not the causes of those of the prior generation of *nix users. When you understand that you will stop winking at us and understand that people will always be unhappy with your aggregations and the power that abets that aggregation. In the meantime we who can will look elsewhere and adopt and improve the model we understand and love because it is not broken and not improved by another design.
- lscotte 9y agoIt's well worth educating yourself about eBPF, how it's functionality provided in the kernel (not systemd), but has only fully landed in the kernel recently. Hence, this timing makes perfect sense once you understand it.
- thwarted 9y agoMany moons ago, support for TCP wrappers was removed from systemd -- and, a bit later, OpenSSH, IIRC. connection filtering should be done in network level or completely in application scope if it makes sense. So it was done at the application scope, with a common config file format, and then it was deprecated because it should be done at the application scope? I can barely make sense of this logic they are applying. The only place it wasn't done at the application scope (baring an invocation wrapper that handled it for applications that didn't directly support tcpwrappers on its own listeners) was in systemd, because systemd isn't the end application, so if the logic is that it should be in the application scope, systemd is the only place it should have been removed from.
- deleted 9y ago[deleted]
- jcrites 9y agoAnother great sandboxing capability added to systemd, and as easily employed as a single flag: IPAddressDeny=any What I enjoy about systemd is the fact that I can employ capabilities like this with any process on the system using only a line of configuration. FTA: > It's a simple way to lock down distribution/vendor supplied system services by default. For example, if you ship a service that you know never needs to access the network, then simply set IPAddressDeny=any (possibly combined with IPAddressAllow=localhost) for it, and it will live in a very tight networking sand-box it cannot escape from. systemd itself makes use of this for a number of its services by default now. For example, the logging service systemd-journald.service, the login manager systemd-logind or the core-dump processing unit systemd-coredump@.service all have such a rule set out-of-the-box, because we know that neither of these services should be able to access the network, under any circumstances.
- Tharre 9y agoIf you want to use this for sandboxing, it may be a good idea to also include RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 to block non-IP sockets.
- sandGorgon 9y agoWhat is the general direction of packet filtering in Linux - it seems that it is nftables vs ebpf/XDP at this point. In fact https://lwn.net/Articles/609571/ https://lwn.net/Articles/609571/ >There was "a brawl" at the workshop about possibly replacing the nftables virtual machine with eBPF, but there is one major show-stopper in any such plan: nftables allows partial replacement of a firewall configuration, while eBPF, in its current form, would not. Cloudflare, Netflix, Facebook, etc are all using eBPF via XDP https://www.iovisor.org/technology/ebpf https://www.iovisor.org/technology/ebpf eBPF and XDP are supported seamlessly on kernel 4.12 and later.
- XorNot 9y agoThis is really nice. It'd be nice to see port/protocol filtering included in this functionality some time in the future as well since it would fit the theme of sandboxing around processes - i.e. start a daemon up and have the kernel enforce which ports inbound/outbound can be accessed. This is something Docker accidentally provides that's fairly useful.
- mdimec4 9y agoWhat does the init system have to do with this?
- askz 9y agoIt is useful for sandboxing processes
- e12e 9y agoOne can certainly make that argument. But now you have two ways to run executables; via the shell / fork - and through the init system (with various capabilities etc). I guess I'd prefer a single api, so I could sandbox (or not) netcat and Firefox the same way as samba and openssh. It might not be a major point - but it would be nice if there was a single way to "run in env/with configuration" that didn't involve an extra (and somewhat opinionated and opaque) wrapper. It's a little like the dot.desktop-file approach to dress up cli tools/interfaces in a desktop gui - it's brittle and doesn't really work all that well. And the cross-platform story isn't great. On the other hand: attaching capabilities to process trees seems better that text-based matching etc. I suppose I think the bsd jail approach looks better - even though that to involves a "wrapper" - but it's a wrapper that's not artificially limited to "services". [ed: the fact that any kind of name lookup is left out is also a bit odd - as demonstrated by the curl example, for many uses of whitelisting name resolution is essential. And for ldap/kerberos/ad being able to work with named resources seems to be the only sane idea. That's why we use dns and catalog services in the first place! This even more clear in an ipv6 environment, as the addresses are generally longer, and auto-assignment is somewhat better than ipv6/DHCP.]
- bluetech 9y agosystemd should have a "whitelist" mode, where everything is locked down by default. Or at least, some /usr/share/doc/systemd/locked-down-example.service file with all of the relevant options set to "secure mode". It can be hard to follow all of the new features :)
- throwme211345 9y agoFuck this. freebsd is now the way forward. Linux has been compromised and in a way that is understandable to anyone conversant with the design philosophy of the underlying userspace tools.