Live data from Hacker News

SELinux is unmanageable; just turn it off if it gets in your way

ctrl.blog

61–70 of 461 posts

Re: SELinux is unmanageable; just turn it off if it gets in your way

#61
post #2

As an experienced RHEL admin, a few years ago I probably would have said this is very bad advice in any professional context, and you should spend the time to learn it because it will save you one day. Now, I think my advice would be: Put everything in a container, and learn how to run Docker or Podman (or k8s) in a secure way (ie no root containers, be very careful with volume mounts, etc). Yes, they aren’t as matur…

Container approach is not always feasible, for example when you need to stay on bare metal. There are Linux applications where selinux definitely gets in your way and there are legitimate reasons to turn it off completely. edit: I like how I'm getting down-voted for sharing factual information. No-one in high frequency trading employs containers because it doesn't help soft-realtime, low-latency goals. There are othe…

> when you need to stay on bare metal

What cases can linux containers not handle? Containers can access GPUs, /dev/kvm, block devices... I'm having trouble thinking of anything they can't do. After all, they're just processes in a glorified chroot, not that different from processes on the linux host.

Re: SELinux is unmanageable; just turn it off if it gets in your way

#62

After using CentOS for years, I have come to establish a debugging rule: If things just don't make sense, check if you're fighting SELinux policy. It's just one of those things that you beat your head on the desk after crashing into multiple brick walls that eventually works its way into your debugging process. I guess it just shows how effective SELinux is if it is preventing the admin from doing something. /s

Sysadmin Rule #1 - Is it SELinux?

Sysadmin Rule #2 - Is it systemd?

Sysadmin Rule #3 - Have you checked the logs?

Re: SELinux is unmanageable; just turn it off if it gets in your way

#63
I don't think I agree. I've been running things with SELinux enabled for more than a decade, haven't really had problems.

The issue with SELinux is that it's security, and security is a complex issue that requires understanding what you're doing and why. It's not a problem domain that's friendly to the approach of poking at random until somehow things start working.

It's not really different from filesystem permissions actually. Why not 'chmod 777 /etc/shadow' to get yourself out of a problem? That question can only be properly answered by knowing what /etc/shadow is for, and why it's a bad thing for everyone to read and write it.

SELinux just forces you to have to understand the system in terms of what operations a program should be able to do on what. Should Apache serve your ssh private key files? Should a random tool be able to listen on port 8080? There's really no instant answers to questions like that. You have to understand what Apache is, what ssh keys are, and who is supposed to access them.

If you have a compromise, you may need to do some forensics and figure out what happened, and that will require answering such questions anyway, at a most inconvenient time. Where did they get in? How did they escalate privileges? How did they get their hands on your data? Is there still a backdoor somewhere on the system? Why is that process listening on that port?

And by the way, audit2allow produces text files, which it proceeds to automatically compile for you. Right next to the binary blob there's a text file with the policy, you can read that.

Ok, let's look into this in more depth.

> At the heart of the problem is that the SELinux policies themselves are sort of magical. The policies have probably been provided by the maintainers of your Linux distribution, e.g., Fedora Linux. There’s nowhere on the system where you can view the policies and look up why something might or might not work.

Yeah there is, you can install the policy's source and look at it all you want. It's complex, granted, but it's very much there.

There's also tooling to examine the current one, like sesearch.

> The SELinux denial audit log messages are too vague. You’re told that a label was denied reading from another label. Okay, what do those labels mean? Which programs? Which files, sockets, or whatever?

You do have that information. It's specified as an inode number for performance reasons, which isn't terribly user friendly. Which is why there's tooling to turn those obscure log entries into something much more readable, such as the mentioned sealert. It's even mentioned in the logs.

> So, you run the audit2allow command as instructed, and end up with some policy blob files.

> God only knows what changes the blobs do; you can’t be expected to, nor are you given enough information to evaluate them.

Wrong, the information is right there in text. audit2allow compiled it into a binary, true. But right next to it you'll find the source, in the .te file. And for most cases, it's a short, quite understandable one.

> Then what do you do? You don’t know what the module did, where it was installed, or how to remove it.

That seems like a problem of not reading the docs. I mean, there's the semodule command for that.

The blog author's problem is that they're trying their best to do the absolutely minimum possible. Which in a way I understand, but doesn't make them informed on the subject matter. It's like writing code by randomly changing stuff without understanding until the compiler finally shuts up. Yeah, sometimes it gets your assignment a bit closer to done, but most of the time the result is crap because randomly messing with stuff isn't a replacement for understanding.

Most of what they complain about have tooling, documentation and solutions. They're just not using them.

Re: SELinux is unmanageable; just turn it off if it gets in your way

#64
post #12

Well, Android has it always turned on for several years now.

Mobile applications require various permissions which can be enforced via SELinux. SELinux policy can also be written to mitigate many vulnerabilities and vulnerability classes/vectors. Over 40% [1] of Android users may no longer be receiving important security updates, potentially putting them at risk of malware, data loss and cyber attacks. Seems to make sense to have it enabled on Android based on the above. [1] h…

> Mobile applications require various permissions which can be enforced via SELinux.

What do you mean by this? SELinux can only deny things that would otherwise be allowed; it can never allow required permissions that would otherwise be denied.

Re: SELinux is unmanageable; just turn it off if it gets in your way

#65

Like others here, I had a similar experience. I setup a simple minecraft server on a SELinux secured OS. So far, so good. I wanted to setup a systemd service to startup and shutdown the minecraft server. After ~1 hour of work later, I came to the conclusion that I was going to disable SELinux. Another hour later, I disabled SELinux. Much as the article mentions, there didn't seem to be much good help, especially w.r.…

Hey, a few years ago, but after the 1.0 release, even the Kubernetes docs mentioned to turn SELinux off.

It’s just that SELinux documentation (something like a cookbook) is (or was) very hard to find on the internet.

Re: SELinux is unmanageable; just turn it off if it gets in your way

#66
For anyone curious or learning about SELinux, I highly recommend the SELinux Coloring Book [1] as an overview of core concepts. It doesn't go into any of the commands or mechanics of interacting with SELinux, but it has some simple and clear examples of objects, labels, and enforcement types.

[1] https://people.redhat.com/duffy/selinux/selinux-coloring-boo...

Re: SELinux is unmanageable; just turn it off if it gets in your way

#67
post #2

As an experienced RHEL admin, a few years ago I probably would have said this is very bad advice in any professional context, and you should spend the time to learn it because it will save you one day. Now, I think my advice would be: Put everything in a container, and learn how to run Docker or Podman (or k8s) in a secure way (ie no root containers, be very careful with volume mounts, etc). Yes, they aren’t as matur…

As a lightweight alternative to Docker-based (or any container-based) solutions: Try firejail. You can set up a directory that will be the "home" of the sandboxed application you're running, then you can do something like `firejail --private="${HOME}/my_firefox_jail" firefox`. There are built-in profiles for many applications already, and you can customize them (by adding `.local` files, not editing the existing `.profile` files). See the following link for details.

https://wiki.archlinux.org/title/Firejail

Re: SELinux is unmanageable; just turn it off if it gets in your way

#68

For anyone curious or learning about SELinux, I highly recommend the SELinux Coloring Book [1] as an overview of core concepts. It doesn't go into any of the commands or mechanics of interacting with SELinux, but it has some simple and clear examples of objects, labels, and enforcement types. [1] https://people.redhat.com/duffy/selinux/selinux-coloring-boo...

I've always found that the concepts are not the difficult part of SELinux. Instead it's the complexity of the configuration and tooling which is always a headache.
Post reply on HN