Update SELinuxfs out of tree and then swapover
Status from this message: Merged into selinux/next, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest4 patches 8 repliesApplied
- v24 patches 6 repliesSuperseded
- v14 patches 2 repliesSuperseded
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | selinux: Create function for selinuxfs directory cleanupsecurity/ | +25 | 2 replies | |
| 2/4 | selinux: Refactor selinuxfs directory populating functionssecurity/ | +25 | 2 replies | |
| 3/4 | selinux: Standardize string literal usage for selinuxfs directory namessecurity/ | +6 | 2 replies | |
| 4/4 | selinux: Create new booleans and class dirs out of treesecurity/ | +90 | 2 replies |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Stephen Smalley |
|---|---|
| 1/4 | A-b |
| 2/4 | A-b |
| 3/4 | A-b |
| 4/4 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/4] Update SELinuxfs out of tree and then swapover
v2: Clean up commit messages to accurately reflect current scope of changes
v3: Remove all policy_capabilities directory manipulation. Switch from vfs_rename() to d_exchange() for directory exchanging. Use appropriate comment style. Reuse inodes for temporary directories.
In the current implementation, on policy load /sys/fs/selinux is updated by deleting the previous contents of /sys/fs/selinux/{class,booleans} and then recreating them. This means that there is a period of time when the contents of these directories do not exist which can cause race conditions as userspace relies on them for information about the policy. In addition, it means that error recovery in the event of failure is challenging.
This patch series follows the design outlined by Al Viro in a previous e-mail to the list[1]. This approach is to first create the new directory structures out of tree, then to perform the swapover, and finally to delete the old directories. Not handled in this series is error recovery in the event of failure.
Error recovery in the selinuxfs recreation is unhandled in the current code, so this series will not cause any regression in this regard. Handling directory recreation in this manner is a prerequisite to make proper error handling possible.
In order to demonstrate the race condition that this series fixes, you can use the following commands:
while true; do cat /sys/fs/selinux/class/service/perms/status
Quoted 1 line
/dev/null; done &
while true; do load_policy; done;
In the existing code, this will display errors fairly often as the class lookup fails. (In normal operation from systemd, this would result in a permission check which would be allowed or denied based on policy settings around unknown object classes.) After applying this patch series you should expect to no longer see such error messages.
This series is relative to https://patchwork.kernel.org/patch/11705743/,
Stephen Smalley's series to split policy loading into a prep and commit.
[1] https://lore.kernel.org/selinux/[email protected]/
Daniel Burgener (4):
selinux: Create function for selinuxfs directory cleanup
selinux: Refactor selinuxfs directory populating functions
selinux: Standardize string literal usage for selinuxfs directory
names
selinux: Create new booleans and class dirs out of tree
security/selinux/selinuxfs.c | 190 +++++++++++++++++++++++++++-------- 1 file changed, 148 insertions(+), 42 deletions(-)
Signature · 1 line
2.25.4