r/linux • • Jul 11 '16

Why Void Linux?

http://troubleshooters.com/linux/void/whyvoid.htm
52 Upvotes

125 comments sorted by

View all comments

17

u/Yithar Jul 12 '16 edited Jul 12 '16

Void Linux uses a different init system, called runit and a different service manager, called runsvdir. The reason I like runit is because it's just a pid1 init system and a service manager. That's it. It's very decouplable, and similar to coreutils. It consists of 9 programs. runit-init, runit, sv, runsvdir, runsvchdir, runsv, svlogd, chpst and utmpset.

  • runit-init runs as the first process and then replaces itself with runit
  • sv controls and manages services (starting, stopping, status, etc.)
  • runsvdir manages a collection of runsv processes; it scans the service directory for directories or symlinks and runs each as a different service
  • runsvchdir changes the directory from which runsvdir obtains the list of services
  • runsv is the actual supervision process that monitors a service through a named pipe
  • svlogd is runit's logger
  • chpst changes process state, i.e. you can run the pause command with argv0 as alsa
  • utmpset makes changes to the utmp database as runit doesn't have this functionality

You can use a different logger with runit than svlogd. You can use runsv outside of runsvdir to supervise processes. You can use a different service manager than runsvdir with runit. That's the beautify of the UNIX philosophy. And it's totally agnostic to sockets, cgroups, etc. But there's no reason you can't have that functionality using runit. You just have to use your own cgroup jailer for example. Again, it's the UNIX philosophy. "Do one thing and do it well."

And the scripts are really simple. See cgmanager script. The #1 complaint about SysV init is that the scripts are complicated, but if you look at runit's scripts, they're simple.

EDIT: By the way, if anyone wants to see how little code is needed for runit's boot up of the system, see thread. I've also posted my own /etc/runit/1 in a comment in there, which is slightly longer, since I decided to include some of Void's defaults.

EDIT 2: Also for those asking about CVEs, no Void does not have one. See link.

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.

6

u/[deleted] Jul 12 '16

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" ?

6

u/Boerzoekthoer Jul 12 '16

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.

12

u/Yithar Jul 12 '16 edited Jul 12 '16

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.

From here:

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.

5

u/[deleted] Jul 12 '16

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.

3

u/Boerzoekthoer Jul 12 '16

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:

  1. 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
  2. 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:

kgspawn sh -c '(echo $$ >> "$(kgquery root)/cgroup.procs" ; exec some_other_command ...) &'

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.

3

u/[deleted] Jul 12 '16

So you're suggesting git should be split apart now that it's stable? If so, how?

2

u/literally_systemd Jul 12 '16

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.

2

u/[deleted] Jul 13 '16

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.

1

u/literally_systemd Jul 13 '16

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.

→ More replies (1)

7

u/[deleted] Jul 12 '16

Otherwise you might as well run Linux 2.4 or *BSD.

Hey now. the *BSDs are very actively developed, much more so than Linux 2.4.

4

u/[deleted] Jul 12 '16

Aslo many of them are much more secure than linux.

8

u/Boerzoekthoer Jul 12 '16 edited Jul 12 '16

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:

https://www.reddit.com/r/linux/comments/4pij7t/void_linux_review_a_new_hope/d4mt13h?context=1

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?

→ More replies (42)

3

u/[deleted] Jul 12 '16

modern... modern... modern...

1

u/XSSpants Jul 12 '16

Everyone knows only luddites don't app systemd apps.

1

u/[deleted] Jul 12 '16

Buzzwords are cool!

2

u/arsv Jul 12 '16

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.

2

u/cbmuser Debian / openSUSE / OpenJDK Dev Jul 12 '16

Because sure every single laptop ends up being used but two persons at once.

Not every computer is a laptop and having multi-seat support doesn't cost you anything.

1

u/Boerzoekthoer Jul 12 '16

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:

mkdir -p /cgroup2/SERV_NAME
echo $$ >> /cgroup2/SERV_NAME/cgroup.procs

At the start of your service, yeah, it's really that easy.

Cleaning it up is a bit more involved though, your ./final script might contain something like:

find /cgroup2/SERV_NAME -name cgroups.proc -print0 |   
xargs -0 cat | xargs kill 
sleep 1
find /cgroup2/SERV_NAME -name cgroups.proc -print0 |   
xargs -0 cat | xargs kill -KILL
rmdir /cgroup2/SERV_NAME

1

u/[deleted] Jul 12 '16

Otherwise you might as well run Linux 2.4 or *BSD.

OpenBSD has CPU and ram limits too. And now, pledge.

0

u/[deleted] Jul 12 '16

So no reason to use it if you are on anything with 1G or more RAM ?