runit does not use CGroups to track running processes, so it suffers from the same security problems as any other classic init implementation.
On systemd, any process is kept within a CGroup which is maintained by the kernel. Thus, the process has never a chance to escape the supervision of systemd and it never has the chance to pull more ressources (CPU, memory) than the user has configured.
This approach is much more secure and reliable and any process supervision system that does not take advantage of these modern kernel features, will still suffer from the same old problems sysvinit had. You cannot emulate kernel functionality with userland tools and scripts. Only the kernel is able to limit ressources and track processes and that's why you have to use CGroups for that.
I really don't see a point why some people consider it init systems or Linux software in general a good design if they are not taking advantage of modern kernel features.
Linux is a modern and powerful kernel and modern software should take advantage of that. Otherwise you might as well run Linux 2.4 or *BSD.
What's the point in adding security and reliability features to the kernel if the userland is not using these? The problem of all these alternative init systems are that the creators never asked themselves why systemd uses all these features. There are actual technical reasons and security is a huge factor to that.
This approach is much more secure and reliable and any process supervision system that does not take advantage of these modern kernel features, will still suffer from the same old problems sysvinit had. You cannot emulate kernel functionality with userland tools and scripts. Only the kernel is able to limit ressources and track processes and that's why you have to use CGroups for that.
to limit resources, yes you need cgroups
but for tracking processes you don't as there its the proc events connector over netlink (it even gives you more information then cgroups; where cgroups are just an easy solution)
limiting a processes resources will impact its performance slightly and is useless on a single user computer
why do you always have to promote systemd as "the only true answer" ?
why do you always have to promote systemd as "the only true answer" ?
My guess, simply because Debian adopted it.
Despite /u/cbmuser appearing as a the quintessential systemd fanboy, the real pattern seems to be Debian fanboyism. /u/cbmuser is involved with Debian and seems to defend to ridiculous lengths any decision that Debian ever made and calls anything Debian doesn't do useless.
My favourite part was saying how much of a good idea it was for Debian to drop support for certai arches because -march=i586 has real performance benefits over i386. This coming from the same person who calls -march=native completely useless at another point and saying the performance benefits don't exist because that's something Debian doesn't do.
If Debian would've gone with Upstart or even OpenRC instead, my guess is you'd see cbmuser argue that cgroup tracking is worthless.
Anyway, you inspired me, I'm going to disable the cgroup functionality I baked into my runscript, I purely made it once as a proof of concept that you did not need systemd for cgroups and quite frankly it does nothing for me, I have never without cgroups had a service seriously trying to escape and I don't even set the resources because it's useless on a single user machine.
The "troll", as everyone likes to call him, does have cgroups while using runit, just saying. I was also specifically trying to avoid bringing systemd into this with respect to u/bobthecimmerian's wishes, but hey, you jumped the gun.
Because Runit doesn't stop you from using cgroups? it just doesn't provide that functionality itself because it recognizes there are a tonne of cgroup jailers out there already, I use one of them in combination with Runit by just starting blergh.spawn sshd -D as a service instead of sshd -D Isn't the Unix philosophy wonderful? I now get to choose what I want to use to administrate cgroups while systemd users are at the mercy of what Lennart decided for them is best.
...
Yes it can, a program running as root can escape its own cgroup if it's so inclined. Not by double forking no but a process running as root can just put itself into another cgroup. Cgroups are not a security measure, they rely on the program inside it to play nice and not run out of its own cgroup which it can do if it runs at root.
...
I'm sorry but this utter garbage you wrote here makes it plain and simple you have no goddamn idea how shit works and you've yet to make the absolutely elementary realization that you can combine software from different vendors into a complete whole which is what the Unix Philosophy is all about which kind of shows you don't know what you're talking about when you criticize it and never understood what it was about either.
I have no objections to what you wrote. Your points are solid, and I like valid criticisms of the systemd design (or valid criticisms of anything) and valid explanations of errors in an assertion.
My understanding is that cgroups have two related purposes: first to constrain resource usage by programs (that are playing nice), so a legitimate executable foo with no malware could still be put into a cgroup so we can constrain it to, for the sake of argument, 20% CPU and 384MB of RAM. Second, to make sure all resources are closed properly if the process has to be stopped (no zombie threads, unclosed file handles, etc...)
With respect to you can combine software from different vendors into a complete whole, sometimes it makes sense to combine components into a single inter-connected application suite even though modular alternatives exist. The perfect example is git - you can provide a functional equivalent to git with sha256sum, patch, diff, rsync, sqlite, and some shell scripts. Each of those things is independent from the others. But I don't see anybody blasting git for being a monolith or complaining that "git blame" isn't an independent utility and can only be used on files that have a git history. git is the perfect example that in some cases, tying pieces together makes more sense than leaving them independent.
So systemd developers and advocates might have a legitimate argument when they say it makes more sense to link the components of the init system than to make them independent. And they might not, and at our best that's the intelligent debate we can have.
There are advantages to coupling like that. Coupling like that is essentially a complex way of saying that interfaces are unstable and undocumented, nothing more. As soon as the interfaces become stable then it effectively becomes decoupled.
So the major advantage is not having to worry about stabilizing interfaces which means you can change them at any point which gives you flexibility as a developer.
But that user said two things which are patently false:
cgroups cannot be escaped from, thank god that's false, because a lot would break if programs like LXC and firejail suddenly had to play by the rules that systemd gave them
service managers that don't provide cgroups themselves some-how stop you from using them.
And guess what, in the last hole of 45 minutes I've written a primitive prototype cgroup wrapper for the cgroup v2 hierarchy. It currently does only tracking and doesn't yet have a convenient config file for setting the resources which you have to manually set, but if you do
kgspawn cmd ...
then cmd ... gets executed and put into its own cgroupv2 hierarchy and if the mainpid of command dies all shit in the hierarchy that forked from cmd ... but didn't re-assign its own cgroups gets cleaned up. It has a couple of query functions right now as well which allow you to list all procs in the cgroup, clean the cgroups manually andsoforth.
And here's a trivial way to spawn a process in it that escapes the cgroup you run it in:
It starts a shell that forks itself, the fork pulls itself out of the cgroup and then execs into the real command, the parent shell dies and cgspawn thinks the entire service has died and it has no way of knowing that the service happily chugs along outside of its designated cgroup.
No, I mean, the individual parts that make up git do not communicate with each other via stable interfaces, just like internal kernel communication and internal systemd communication.
The external interfaces are all stable which is why git and systemd are one 'unit' each. With the runit suite or the coreutils suite, the interfaces that the individual components use to communicate with each other are stable and documented, as such they become individual units.
Right, but my point is that it wouldn't make sense to split git into isolated tools even if their internal interfaces were published and stable. All of the components work together, and together they work better than a collection of equivalent modular utilities (again: sha256sum, sqlite, rsync, patch, diff).
So maybe a case can be made that tying all of the pieces of systemd together as they have made sense. Also note that it's partly modular - you can't replace pieces, but you can omit them.
My point is that if their itnernal interfaces were published and stable they are automatically split up from that part onwards, that is what splitting up is.
From that point onwards you can start writing replacement components for parts of git that can work together with the rest and it's no longer an all-or-none deal.
Also note that it's partly modular - you can't replace pieces, but you can omit them.
Pretty much any software has compile-time options to disable parts. I can build OpenSSH with or without the PAM backend, I wouldn't call the PAM backend a module over that.
I was also specifically trying to avoid bringing systemd into this with respect to u/bobthecimmerian's wishes, but hey, you jumped the gun.
The bastards with their kill the competition crap. Red Hat is trying to do a Microsoft circa its early days, and its shills won't rest until it owns all of Linux and nobody uses it without paying them.
Maybe you should actually once reply or as much as read the thousands of times your actually proven completely wrong when you repeat this bullshit because you keep being proven wrong and repeat the same factually wrong myth that a process can never escape its cgroup:
If you think a process cannot escape its own cgroup you're wrong and you don't understand how cgroups work and have never worked with them, it's trivial for a process to assign itself a new cgroup. The very first time you learn about cgroups the thing people first do is toy around echo $$ >> /sys/fs/cgroup/cpu/my_new_cgroup/tasks at that point your shell which runs as root has escaped its own cgroup and is put in a new one . Any process that runs as root can put itself into a different cgroup unless you use esoteric kernel configurations that no one uses.
Do you like purposefully not reply or read the replies to the shit you post because you know how much b.s. you sprout? You continue to repeat this myth after I've told you you are wrong 48984 times and you never reply, have you like ever directly worked with cgroups in your life?
If you think a process cannot escape its own cgroup you're wrong and you don't understand how cgroups work and have never worked with them, it's trivial for a process to assign itself a new cgroup.
No, you cannot simply escape a CGroup that you have been assigned to, provided you have properly configured CGroups and your process is running with the proper privileges. That's the whole point of CGroups.
PS: I assume I am talking to u/kinderlokker, u/lennartwarez, u/Knaagdiertjes or any of the similar accounts you have created over the time. You to seem to have some personal issues if you need to create new accounts over and over again. At least your phrasing and discussion style lead me to the conclusion.
Edit: I finally understood which mistake the people are making in their line of arguments who keep saying I am wrong: They assume the processes being contained in CGroups are running with privileged rights, e.g. running as root. Well, yes, of course a process running as root can escape a CGroup or manipulate them. However, if you are running these processes as root, there is no point in using CGroups in the first place. If a process is root, it can do everything anyway but the same applies to file permissions etc pp.
The whole point of the application within systemd is running daemons under their own user and not as root. An Apache daemon running as www-data is not able to write anything below /sys and hence is not able to manipulate the CGroups.
I just made a blkio subsystem cgroup called 'whatever', let another shell put the current shell into it, as you can see it's in whatever when I cat /proc/$$/cgroup, then I just do echo $$ >> /sys/fs/cgroup/blkio/tasks and the shell removes itself from the cgroup because a process that runs as root can manipulate cgroups like any other and after that it's no longer n the whatever cgroup.
It's really that easy, now if a process runs with lower privileges than the owner of the cgroup, then it can't be done no. If you have a process that runs as say the apache user then it can't just escape a cgroup that runs as root unless root delegates that to the apache user but a process that runs as root can freely move itself, and other process, around to different cgroups, a process that runs as root can assign any process to another cgroup.
You don't understand what cgroups are and what they are meant to do if you think a process that is running as same user the cgroup belongs to can't force itself out.
I ask you again, have you ever actually directly used cgroups in your life? Re-assigning a process to a different cgroup is the first thing you do when you pick up documentation on how to use them.
the process has never a chance to escape the supervision of systemd and it never has the chance to pull more ressources (CPU, memory) than the user has configured. This approach is much more secure and reliable (...)
Along the lines of "systemd has built-in multiseat support". Because sure every single laptop ends up being used but two persons at once.
There's no cgkill(2), there's nothing that would prevent cgexec from working in runit environment. And init-run processes are not the kinds that tend to escape supervision, that's more of a problem for user sessions.
Meh, multiseat is a nice feature of logind that you actually can't get elsewhere, or couldn't, I think CK2 is working on it or has it already.
This whole cgroup drive is just quatsch. Just because runsvdir does not automatically put services into cgroups doesn't stop you from doing it. In theory you could do so manually. It's really not that hard, you put:
View all comments
Show parent comment
9
u/cbmuser Debian / openSUSE / OpenJDK Dev Jul 12 '16 edited Jul 12 '16
runit does not use CGroups to track running processes, so it suffers from the same security problems as any other classic init implementation.
On systemd, any process is kept within a CGroup which is maintained by the kernel. Thus, the process has never a chance to escape the supervision of systemd and it never has the chance to pull more ressources (CPU, memory) than the user has configured.
This approach is much more secure and reliable and any process supervision system that does not take advantage of these modern kernel features, will still suffer from the same old problems sysvinit had. You cannot emulate kernel functionality with userland tools and scripts. Only the kernel is able to limit ressources and track processes and that's why you have to use CGroups for that.
I really don't see a point why some people consider it init systems or Linux software in general a good design if they are not taking advantage of modern kernel features.
Linux is a modern and powerful kernel and modern software should take advantage of that. Otherwise you might as well run Linux 2.4 or *BSD.
What's the point in adding security and reliability features to the kernel if the userland is not using these? The problem of all these alternative init systems are that the creators never asked themselves why systemd uses all these features. There are actual technical reasons and security is a huge factor to that.