IO(4)
β¨ io(4) β I/O privilege file β¨
okay so bestie, welcome to the Kernel Interfaces Manual page for the io device. It's giving controlled security hole energy β and yes, that's literally the vibe. This file lets a process gain I/O privileges that are normally reserved for kernel-internal code, so userland programs can handle some hardware directly. Iconic, slightly terrifying, we love that for us π
π NAME π
io β I/O privilege file
πΈ SYNOPSIS πΈ
device io
#include <sys/types.h>
#include <sys/ioctl.h>
#include <dev/io/iodev.h>
#include <machine/iodev.h>
struct iodev_pio_req {
u_int access;
u_int port;
u_int width;
u_int val;
};
π¦ DESCRIPTION π¦
The special file /dev/io is a controlled security hole that allows a process to gain I/O privileges (which are normally reserved for kernel-internal code). This can be useful in order to write userland programs that handle some hardware directly. no cap, that's the whole point π«Ά
The usual operations on the device are to open it via the open(2) interface and to send I/O requests to the file descriptor using the ioctl(2) syscall.
The ioctl(2) requests available for /dev/io are mostly platform dependent, but there are also some in common between all of them. The IODEV_PIO is used by all the architectures in order to request that an I/O operation be performed. It takes a struct iodev_pio_req argument that must be previously setup. β¨
The access member specifies the type of operation requested. It may be:
IODEV_PIO_READβ The operation is an "in" type. A value will be read from the specified port (retrieved from theportmember) and the result will be stored in thevalmember. πIODEV_PIO_WRITEβ The operation is a "out" type. The value will be fetched from thevalmember and will be written out to the specified port (defined as theportmember). π
Finally, the width member specifies the size of the operand to be read/written, expressed in bytes.
In addition to any file access permissions on /dev/io, the kernel enforces that only the super-user may open this device. periodt.
π LEGACY π
The /dev/io interface used to be very i386 specific and worked differently. The initial implementation simply raised the IOPL of the current thread when open(2) was called on the device. This behaviour is retained in the current implementation as legacy support for both i386 and amd64 architectures. history is history, bestie π
π SEE ALSO π
π HISTORY π
The io file appeared in FreeBSD 1.0.
Debian, June 1, 2010 β mwah, go be iconic and maybe don't poke the wrong port π β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1996 Joerg Wunsch
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms