init: relabel UBLK devices during snapuserd transition
During the SELinux transition for `snapuserd`, device nodes are
re-created, and their SELinux contexts must be restored. While this
was handled for device-mapper devices, it was missing for the devices
created and used by the UBLK backend.
This change introduces a new `RelabelUblkDevices()` helper function
that is responsible for restoring the SELinux context for all
UBLK-related devices :
- The global control node (`/dev/ublk-control`)
- Per-device control nodes (`/dev/ublkcN`)
- Per-device block nodes (`/dev/block/ublkbN`)
This new function is called at two key points:
1. In `FinishTransition()`, to relabel any UBLK devices that may have
existed before the transition.
2. In `RelaunchFirstStageSnapuserd()`, after `init` has finished
assisting `snapuserd` with creating new device nodes via the socket.
This ensures that these newly created devices also receive their
correct SELinux labels.
Bug: 362683283
Test: Manually verified that UBLK devices have the correct SELinux
labels after an OTA update that involves a snapuserd transition.
Check for avc denials.
Change-Id: Ia704608288477c63a1db74d5f67db07001e535f1
Signed-off-by:
Sandeep Dhavale <dhavale@google.com>
Loading
Please register or sign in to comment