Character Device Modules

Character device modules are KLDs that create or install a character device. In FreeBSD, a character device is the interface for accessing a specific device within the kernel. For example, data is read from and written to the system console via the character device /dev/console.


In Chapter 4 you'll be writing rootkits that hack the existing character devices on the system. Thus, this section serves as a primer.

There are three items that are unique to each character device module: a cdevsw structure, the character device functions, and a device registration routine. We'll discuss each in turn below.

The cdevsw Structure

A character device is defined by its entries in a character device switch table, struct cdevsw, which ...

Get Designing BSD Rootkits now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.