Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d80a5693 authored by Sandeep Dhavale's avatar Sandeep Dhavale
Browse files

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: default avatarSandeep Dhavale <dhavale@google.com>
parent 453ab913
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment