-
Notifications
You must be signed in to change notification settings - Fork 84
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
Reload config on SELinux policy load #379
base: main
Are you sure you want to change the base?
Conversation
53ea1c4
to
f17d94e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Sadly, we cannot rely on the broker to have its controller as parent PID. So this either needs channeling via the controller interface, or we simply make the launcher listen for these events and trigger the reload from there (which I think is preferable).
Thanks for the feedback, I am not very familiar with the broker code, so any input is more than welcome. I have tried to move the callback registration into launcher itself, but the actual callback method never seems to run. I am still digging into this but not making great progress. Could you possibly point me in the correct direction when you say "channeling via the controller interface" if setting up the callback in the launcher doesn't work out? |
I have dug more and have come up with the following: The reason why the launcher was not seeing the callback run and the broker was, is that the broker will call selinux_check_access which intern calls selinux_status_updated, which triggers the callback. The launcher has no such logic. As such I have come up with a few options for folks who know more than me to consider:
|
@dvdhrm Hi just a gentle ping about the proposed paths I laid out in my last comment. |
Thanks for the investigation. I still believe that monitoring operations like this belong into the launcher, especially if they are asynchronous and do not necessarily require tight ordering with other calls. Sadly, the kernel does not support wait-queues on /selinux/status, so we cannot Anyway, in the meantime I see 2 solutions:
Does that sound feasible? |
Btw., your A very simple solution would be to call This generic "sighup" could then be used by other parts of the infrastructure as well, to basically say "something changed, the launcher should check any status pages". It would even allow manually sending SIGHUP to the process, for debugging/introspection to trigger the update. |
When a new SELinux policy is loaded the dbus config file it carries may have been updated as well. As such, we should reload the dbus configuration to catch any changes.
f17d94e
to
6ee5a67
Compare
@dvdhrm Thanks for the input, and sorry this took me so long to get back around to. I have pushed some changes to align with your last suggestion, but I think I am messing things up in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the followup, see my inline comments.
@@ -37,6 +41,10 @@ static int broker_dispatch_signals(DispatchFile *file) { | |||
|
|||
c_assert(l == sizeof(si)); | |||
|
|||
if (si.ssi_signo == SIGHUP) { | |||
broker_propagate_sighup(broker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to propagate the return value of this call via error_fold(). You currently fall-through to DISPATCH_EXIT, which will terminate the broker (which likely is what you are seeing in your tests).
* we need to reload the configuration in the launcher. | ||
*/ | ||
static int policy_reload_callback(int seqno) { | ||
return raise(SIGHUP); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does SELinux do with return values from this callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our case nothing. If the callback returns non-zero selinux_status_updated
returns -1, but the dbus-broker code isn't calling selinux_status_updated
directly. Its calling it through selinux_check_access
which ignores the return.
@@ -24,6 +24,10 @@ | |||
#include "util/sockopt.h" | |||
#include "util/user.h" | |||
|
|||
static int broker_propagate_sighup(Broker *broker) { | |||
return controller_dbus_send_sighup(&broker->controller); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return controller_dbus_send_sighup(&broker->controller); | |
int r; | |
r = controller_dbus_send_sighup(&broker->controller); | |
return error_fold(r); |
When a new SELinux policy is loaded, the dbus config file it carries may have been updated as well. As such, we should reload the dbus configuration to catch any changes. This logic already exists in the dbus-daemon code and this change is largely based off of that code.