Skip to content

Commit

Permalink
feat: add uinput driver extension
Browse files Browse the repository at this point in the history
Adds an extension to enable the `uinput` kernel module which makes it
possible to emulate input devices from userspace.

Signed-off-by: Judah Rand <[email protected]>
Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
judahrand authored and frezbo committed Aug 30, 2024
1 parent 4563de5 commit d33d428
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ spec:
- stargz-snapshotter
- tailscale
- thunderbolt
- uinput
- usb-modem-drivers
- util-linux-tools
- v4l-uvc-drivers
Expand All @@ -59,7 +60,7 @@ spec:
- name: EXTENSIONS_IMAGE_REF
defaultValue: $(REGISTRY_AND_USERNAME)/extensions:$(TAG)
- name: PKGS
defaultValue: v1.8.0-alpha.0-52-g4fd2541
defaultValue: v1.8.0-alpha.0-54-g4ce5bc6
- name: PKGS_PREFIX
defaultValue: ghcr.io/siderolabs
useBldrPkgTagResolver: true
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ If the field is marked as `Needs Maintainer`, it means that the package is curre
| stargz-snapshotter | Sidero Labs | NA |
| tailscale | Beau Trepp | [btrepp](https://github.com/btrepp) |
| thunderbolt | Igor Rzegocki | [ajgon](https://github.com/ajgon) |
| uinput | Judah Rand | [judahrand](https://github.com/judahrand) |
| usb-modem-drivers | Sidero Labs | NA |
| util-linux-tools | Sidero Labs | NA |
| v4l-uvc-drivers | Jacob McSwain | [USA-RedDragon](https://github.com/USA-RedDragon) |
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-08-29T14:13:04Z by kres b5ca957.
# Generated on 2024-08-30T11:52:57Z by kres b5ca957.

# common variables

Expand Down Expand Up @@ -48,7 +48,7 @@ COMMON_ARGS += --build-arg=PKGS_PREFIX="$(PKGS_PREFIX)"
# extra variables

EXTENSIONS_IMAGE_REF ?= $(REGISTRY_AND_USERNAME)/extensions:$(TAG)
PKGS ?= v1.8.0-alpha.0-52-g4fd2541
PKGS ?= v1.8.0-alpha.0-54-g4ce5bc6
PKGS_PREFIX ?= ghcr.io/siderolabs

# targets defines all the available targets
Expand Down Expand Up @@ -89,6 +89,7 @@ TARGETS += spin
TARGETS += stargz-snapshotter
TARGETS += tailscale
TARGETS += thunderbolt
TARGETS += uinput
TARGETS += usb-modem-drivers
TARGETS += util-linux-tools
TARGETS += v4l-uvc-drivers
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ cosign verify --certificate-identity-regexp '@siderolabs\.com$' --certificate-oi
| [mei](drivers/mei/) | [ghcr.io/siderolabs/mei](https://github.com/siderolabs/extensions/pkgs/container/mei) | Driver for Intel Management Engine | `talos version` |
| [nvidia](nvidia-gpu/nvidia-modules/) | [ghcr.io/siderolabs/nvidia-open-gpu-kernel-modules](https://github.com/siderolabs/extensions/pkgs/container/nvidia-open-gpu-kernel-modules) | NVIDIA OSS Driver | `nvidia driver upstream version`-`talos version` |
| [thunderbolt](drivers/thunderbolt/) | [ghcr.io/siderolabs/thunderbolt](https://github.com/siderolabs/extensions/pkgs/container/thunderbolt) | Thunderbolt drivers | `talos version` |
| [uinput](drivers/uinput/) | [ghcr.io/siderolabs/uinput](https://github.com/siderolabs/extensions/pkgs/container/uinput) | uinput drivers | `talos version` |
| [usb-modem](drivers/usb-modem/) | [ghcr.io/siderolabs/usb-modem-drivers](https://github.com/siderolabs/extensions/pkgs/container/usb-modem-drivers) | USB Modem drivers | `talos version` |
| [v4l-uvc](drivers/v4l-uvc/) | [ghcr.io/siderolabs/v4l-uvc-drivers](https://github.com/siderolabs/extensions/pkgs/container/v4l-uvc-drivers) | USB Video Class (Webcam) drivers | `talos version` |

Expand Down
37 changes: 37 additions & 0 deletions drivers/uinput/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# uinput extension

## Installation

See [Installing Extensions](https://github.com/siderolabs/extensions#installing-extensions).

## Usage

Enable the `uinput` module in Talos machine config.

```yaml
machine:
kernel:
modules:
- name: uinput
```
## Verifiying
You can verify the modules are enabled by the `/proc/modules` where it _should_ show the module is live.

For example:

```
❯ talosctl -n 192.168.42.15 read /proc/modules
uinput 24576 - - Live 0xffffffffc0414000
```

In addition, the `/dev/uinput` device should be present.

For example:

```
❯ talosctl -n 192.168.42.15 ls /dev/uinput'
NODE NAME
192.168.42.15 uinput
```
4 changes: 4 additions & 0 deletions drivers/uinput/files/modules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
modules.order
modules.builtin
modules.builtin.modinfo
kernel/drivers/input/misc/uinput.ko
14 changes: 14 additions & 0 deletions drivers/uinput/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: v1alpha1
metadata:
name: uinput
version: "$VERSION"
author: Judah Rand
description: |
This system extension provides the uinput kernel module built against a specific Talos version.
This kernel module makes it possible to emulate input devices from userspace. By writing to
/dev/uinput (or /dev/input/uinput) device, a process can create a virtual input device with
specific capabilities. Once this virtual device is created, the process can send events through it,
that will be delivered to userspace and in-kernel consumers.
compatibility:
talos:
version: ">= v1.4.5"
34 changes: 34 additions & 0 deletions drivers/uinput/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: uinput
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
# The pkgs version for a particular release of Talos as defined in
# https://github.com/siderolabs/talos/blob/<talos version>/pkg/machinery/gendata/data/pkgs
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
steps:
- prepare:
- |
sed -i 's#$VERSION#{{ .VERSION }}#' /pkg/manifest.yaml
- install:
- |
export KERNELRELEASE=$(find /lib/modules -type d -name "*-talos" -exec basename {} \+)
mkdir -p /rootfs
xargs -a /pkg/files/modules.txt -I {} install -D /lib/modules/${KERNELRELEASE}/{} /rootfs/lib/modules/${KERNELRELEASE}/{}
depmod -b /rootfs ${KERNELRELEASE}
- test:
- |
# https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html#signed-modules-and-stripping
find /rootfs/lib/modules -name '*.ko' -exec grep -FL '~Module signature appended~' {} \+
- |
mkdir -p /extensions-validator-rootfs
cp -r /rootfs/ /extensions-validator-rootfs/rootfs
cp /pkg/manifest.yaml /extensions-validator-rootfs/manifest.yaml
/extensions-validator validate --rootfs=/extensions-validator-rootfs --pkg-name="${PKG_NAME}"
finalize:
- from: /rootfs
to: /rootfs
- from: /pkg/manifest.yaml
to: /
1 change: 1 addition & 0 deletions drivers/uinput/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION: "{{ .BUILD_ARG_TAG }}"
2 changes: 2 additions & 0 deletions reproducibility/pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ dependencies:

# thunderbolt can be ignored from reproducibility test since it's kernel modules copied from pkgs
# - stage: thunderbolt
# uinput can be ignored from reproducibility test since it's kernel modules copied from pkgs
# - stage: uinput
# usb-modem-drivers can be ignored from reproducibility test since it's kernel modules copied from pkgs
# - stage: usb-modem-drivers

Expand Down

0 comments on commit d33d428

Please sign in to comment.