Conversation
53ea1c4 to
f17d94e
Compare
dvdhrm
left a comment
There was a problem hiding this comment.
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 |
dvdhrm
left a comment
There was a problem hiding this comment.
Thanks for the followup, see my inline comments.
| c_assert(l == sizeof(si)); | ||
|
|
||
| if (si.ssi_signo == SIGHUP) { | ||
| broker_propagate_sighup(broker); |
There was a problem hiding this comment.
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.
What does SELinux do with return values from this callback?
There was a problem hiding this comment.
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.
| #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.
| 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.