home-assistant / home-assistant/supervisor
Support Plug&Play Permission updates on CGroupv2
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 806
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 55
Description
### Describe the issue
Currently, hotplugging a USB device like `/dev/ttyUSB0` or `/dev/ttyACM0` (using `uart: true` add-on configuration) does not update the permissions correctly if CGroupsV2 is used (HAOS 9.x).
Permissions are correctly set when the device, or a device of that same major, is plugged in at boot.
From what I understand, the reason is that systemd crgroup support (which runc calls) requires an existing device with that major for it to be able to resolve the major from `/proc/devices`. This is at least true when using `:*` type of rules (which Supervisor is using).
https://github.com/opencontainers/runc/blob/v1.1.4/libcontainer/cgroups/systemd/common.go#L236-L256
**Possible solution:** Add the `:*` rules not at start but when the first device of that major is being plugged-in.
### Steps to reproduce
1. Use add-on with `uart: true`
2. Start the add-on
3. Plug-in USB to UART adapter after starting the add-on
### Environment details
- **Operating System:**: 9.0
- **Supervisor version:**: 2022.09.0
- **Home Assistant version**:
### Supervisor logs
Supervisor logs
```
Sep 15 20:39:04 ha-fujitsu os-agent[101]: INFO: 2022/09/15 20:39:04 cgroup.go:66: Successfully called runc for '6eda7993251104ee747d13f205a8f776fd7468c0ce8bbfa3774569535547621c', output time="2022-09-15T20:39:04Z" level=warning msg="could not find device group for '99/204' in /proc/devices -- temporarily ignoring rule: {99 204 -1 rwm true}"
```
### System Information
System Information
```
Paste system info here
```
Contributor guide
Research direction
Start with the Supervisor handling of add-ons using `uart: true` and the runc systemd cgroup path linked in the report. Reproduce the hotplug case on CGroupv2, then verify that a USB-to-UART device plugged in after the add-on starts receives the expected permissions without the reported `/proc/devices` warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, linux, python
- Domain
- infrastructure, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100