libinput, seatd and libseat; sockets from accept() can pass descriptors
Alpine's libinput, libseat, seatd, xf86-input-libinput and usbutils join the image, and seatd runs from schinit. libinput lists the keyboard and pointer as an ordinary user, Xorg now drives both through libinput, and a program linked to libseat running as schos opens seat0 through seatd, is handed /dev/input/event0 and reads its name through the descriptor. Two kernel bugs stood in the way, and both would have stopped a Wayland compositor too. The socket connect() queues for a listener was allocated with its domain at zero, so sendmsg refused SCM_RIGHTS on the accepted end: a server could receive descriptors and never send one. And sendmsg treated a control buffer longer than its messages as an error, where Linux takes a following header too short to be one as the end; seatd passes a zeroed CMSG_SPACE array with one descriptor at the front. Found with /proc/strace and a temporary kinfo in sendmsg's EINVAL sites. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EVRhxi9zpdW2uDUN4FVcao
This commit is contained in:
parent
8d836c66b2
commit
b411836478
8 changed files with 94 additions and 11 deletions
|
|
@ -14,10 +14,10 @@ Wayland needs — udev, `/sys/devices`, libinput, a DRM device — is in [../pla
|
|||
Every Wayland compositor worth running — labwc, and everything built on wlroots — needs
|
||||
DRM/KMS, libinput, udev and libseat. DRM/KMS is the largest of them by far: a kernel graphics
|
||||
subsystem, and in practice a great deal taken from Linux. Xorg runs on a plain framebuffer
|
||||
through `fbdev` and reads input through `evdev`, both interfaces SchOS already had. That is
|
||||
the shorter road to a desktop by a long way, and it brings the window managers with it.
|
||||
DRM/KMS is not planned; libinput, udev and libseat are worth having for their own sake and
|
||||
may come later.
|
||||
through `fbdev`, which SchOS already had. That is the shorter road to a desktop by a long way,
|
||||
and it brings the window managers with it. udev, libinput and libseat are now in the image
|
||||
([udev.md](udev.md)); DRM/KMS is the part still missing, and it is the GPU plan
|
||||
([../plan/gpu.md](../plan/gpu.md)).
|
||||
|
||||
## What it stands on
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,32 @@ and regular files in `/dev` are refused.
|
|||
A queue that is full drops the message, as Linux does, and `udevadm trigger`
|
||||
is how a reader recovers.
|
||||
|
||||
## libinput and libseat
|
||||
|
||||
`libinput` (Alpine) reads the evdev nodes udev tagged and `xf86-input-libinput`
|
||||
gives Xorg the same library; `libinput list-devices` as an ordinary user shows
|
||||
`SchOS keyboard` and `SchOS pointer`. Xorg's `40-libinput.conf` now claims both,
|
||||
and the log says `Using input driver 'libinput'`.
|
||||
|
||||
`seatd` (job `etc/schinit/seatd.job`, socket `/run/seatd.sock`, group `video`)
|
||||
and `libseat` let a program that is not root take devices from the system. The
|
||||
client asks seatd for `seat0`; seatd takes the VT (`VT_SETMODE`, `KDSETMODE`,
|
||||
`KDSKBMODE`, all there already), opens the device as root and passes the
|
||||
descriptor back over the socket with `SCM_RIGHTS`. Checked as `schos` against
|
||||
`/dev/input/event0` and `event1` with a small program linked to libseat, reading
|
||||
the device's name through the descriptor it was handed.
|
||||
|
||||
Getting there found two kernel bugs, both in descriptor passing:
|
||||
|
||||
- **A socket returned by `accept()` was not an `AF_UNIX` socket as far as
|
||||
`sendmsg` was concerned.** The end `connect()` queues for the listener was
|
||||
allocated with its domain left at zero, and `sendmsg` refuses `SCM_RIGHTS` on
|
||||
anything else. So a *server* could receive descriptors and never send one:
|
||||
seatd, and equally a Wayland compositor handing a client a buffer.
|
||||
- **A control buffer longer than its messages was an error.** seatd passes a
|
||||
zeroed array with one descriptor at the front; Linux treats a following header
|
||||
too short to be one as the end. `sendmsg` now does too.
|
||||
|
||||
## What is not there
|
||||
|
||||
- USB interfaces (`1-3:1.0`), `/dev/bus/usb` nodes, and PCI bridges as parents.
|
||||
|
|
@ -89,7 +115,7 @@ and regular files in `/dev` are refused.
|
|||
image, so `60-input-id` logs "returned non-zero" for the hwdb import. The
|
||||
properties that matter come from `input_id`.
|
||||
- Block device partitions, `by-id` / `by-uuid` links, and a `/sys/block`.
|
||||
- `libinput` and `libseat` (next; see [../plan/roadmap.md](../plan/roadmap.md)).
|
||||
- A compositor. libinput and libseat are in place, DRM is not; see [../plan/roadmap.md](../plan/roadmap.md).
|
||||
|
||||
## Testing
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue