New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ListenStream doesn't honor SELinux policy changes until restart #9997
Comments
I haven't looked at the details, but I wonder if |
@sourcejedi I can confirm that Is this by design or documented anywhere? This seems to be an OK workaround but shouldn't there be a less overkill way of forcing systemd to re-read policies? |
I don't know myself. All I can say is that this difference is not mentioned in the most obvious place :). |
Please disregard the automatic reference above, I accidentally pasted the wrong link in a PR and GitHub doesn't seem to honor the fact I fixed it in the comment. |
My selinux-fu is limited. We don't reload the selinux database/policy ever during runtime. "systemctl daemon-reexec" does that however as a side-effect (simply because it reexeces PID 1, i.e. flushes out all memory and starts fresh and thus has to reload it) I am not sure we should reload the database/policy automatically, when it changes, i.e. i don#t know what the intended mode of operation of selinux is there: should consumers of the db/policy automatically flush the old one out after stat-mtime or inotify change detection or should this remain an explicit step? If the latter then there's nothing to do I think from our side, except maybe we could flush out the selinux db/policy during "systemctl daemon-reload" too. But for that we'd need some input from the selinux folks. In fact, for selinux support we usually rely on patches from the selinux community. @mgrepl @rhatdan any input on this? if we should flush out the db/policy during daemon-reload, what's the right series of libselinux calls to make for that? any chance you can prep a patch if this is desirable? |
SELinux policy update should only be done during the semodule -i phase. Never done to daemon-reload. systemctl restart service Is what is needed. I don't see where |
@rhatdan The example problem is a denial of file operations performed by PID 1. Specifically, mkdir() followed by bind() of a unix socket file. The newly installed policy is not about changing the label of PID 1. Instead, the example changes the "file context mapping definitions" (as in We're asking about when and how we need to reload the "file context mapping definitions". (Edit: It sounds like SELinux-aware packages need to trigger such a reload at install time, around the same time they trigger systemd to load their new unit files. Maybe it hasn't been needed in most cases... I guess it wouldn't have been needed here if the socket directory was instead created by running |
The file context should probably be checked on each access to the socket. Since it could change at any time. chcon -t foobar_socket_t /run/foobar.sock |
I guess this should work now that a9dfac2 is merged. |
systemd version the issue has been seen with
Used distribution
Expected behaviour you didn't see
Unexpected behaviour you saw
Steps to reproduce the problem
Context: Creating sockets outside
/var/run
is required to support the new, distribution-independent Nix multi-user installer which uses its own hierarchy under/nix
but requires integration with the host's own init system.The text was updated successfully, but these errors were encountered: