Driver stack

On this page 7

A driver stack is the ordered set of layered drivers that together handle input and output requests for a single hardware device, with each layer adding, transforming or forwarding the request before it reaches the hardware. In the area of Drivers & devices within operating systems, the term is most closely tied to the Windows Driver Model, where every device is represented by a device stack of device objects created by a bus driver, a function driver and optional filter drivers.

Layering lets an operating system separate responsibilities: one driver knows the bus, another knows the device, and others add encryption, monitoring or compatibility fixes without rewriting the core driver. The same idea appears in Linux and macOS, where storage, USB and network subsystems pass requests through several cooperating driver layers.

How a driver stack is built and traversed

In Windows, the stack is assembled during device enumeration by the Plug and Play manager. The bus driver detects the device and creates the physical device object (PDO) at the bottom. The system then loads the function driver, which creates the functional device object (FDO) above it, and any registered filter drivers, which attach their own filter device objects above or below the FDO.

An application request enters at the top. The I/O manager builds an I/O request packet (IRP) and sends it to the highest device object. Each driver handles the request, completes it or passes it down with IoCallDriver. Completion travels back up the stack in reverse order, so drivers can inspect results through completion routines.

The following table lists the layers from top to bottom.

LayerDevice objectResponsibility
Upper filter driverFilter DOAdds features or inspects requests above the device logic
Function driverFDOImplements device behavior and power policy
Lower filter driverFilter DOAdjusts requests before they reach the bus
Bus driverPDOEnumerates the device and controls bus access
Layers of a typical Windows device stack

Device stacks, driver stacks and device trees

Microsoft documentation distinguishes a device stack, the chain of device objects for one device node, from a driver stack, the chain of drivers that serve a request. In practice the two terms are often used interchangeably. A single request can cross several device stacks: a file read passes through the file system stack, the volume stack, the disk stack and the storage controller stack.

The table compares related structures that are easy to confuse.

ConceptScopeWhat it describes
Driver stackOne request pathDrivers that process a request in order
Device stackOne device nodeDevice objects attached to one PDO
Device treeWhole systemParent-child relationships among all devices
Hardware abstraction layerPlatformKernel layer hiding chipset and firmware details
Driver modelOperating systemRules for writing and stacking drivers
Driver stack compared with related concepts

The device tree links stacks together: the bus driver of a child device is the function driver of its parent bus. A USB storage device, for example, sits under the USB hub, which sits under the USB host controller, which sits under the PCI bus.

Driver stacks across operating systems

Every major operating system uses layered I/O paths, though the vocabulary differs. Windows formalizes stacking through device objects and IRPs, while Linux composes layers through subsystem interfaces and function pointers.

PlatformLayering mechanismExample stack
Windows (WDM, KMDF)Device objects and IRPsVolume, disk class, storport miniport
LinuxSubsystem cores and operations tablesFile system, block layer, SCSI, USB storage, host controller
macOS (IOKit)Provider and client objects in the I/O RegistryMedia, block storage, USB device, controller
FreeBSD (CAM, GEOM)Transformation classes and peripheral driversFile system, GEOM partition, CAM disk, controller
Layered driver architectures by platform

Linux has no formal filter driver type, but device mapper, netfilter hooks and stackable block devices fulfill similar roles. On macOS, Apple increasingly moves drivers out of the kernel into DriverKit system extensions, which still form layered provider-client chains.

Filter drivers and their uses

Filter drivers are the main reason driver stacks exist. They let vendors extend device behavior without modifying the function driver, which may belong to another company. The trade-off is that every filter adds latency, complexity and a new failure point.

RoleTypical positionExample purpose
EncryptionAbove the volume or diskFull-disk encryption of sectors
Antivirus file filteringFile system minifilterScanning files on open and write
Input remappingAbove keyboard or mouse classRemapping keys or filtering gestures
Hardware workaroundLower filterCorrecting device firmware errors
Backup and snapshotsAbove the volumeTracking changed blocks
Common filter driver roles

Failure modes and troubleshooting

Because every layer runs in kernel mode in most stacks, one faulty driver can crash the whole system. Diagnosing stack problems usually means identifying which layer mishandled the request.

  • Orphaned filter entries: a filter listed in the registry after its software is removed can prevent a device from starting.
  • Incorrect completion handling: a driver that completes an IRP twice or never completes it causes crashes or hung I/O.
  • Filter ordering conflicts: two security products filtering the same stack may deadlock or double-scan data.
  • Diagnostic tools: Device Manager, the !devstack debugger command and Driver Verifier reveal stack composition and errors.

In simple terms

When a program saves a file, the request does not jump straight to the disk. It passes through several helpers stacked on top of each other. Each helper does one job.

Think of a letter in a mail system. A clerk checks it. A sorter routes it. A courier drives it to the right street. The driver stack is that chain of helpers for one device. Extra helpers can join the chain to add things like encryption.

A practical example

An IT department rolls out full-disk encryption to 400 Windows laptops. After the rollout, about 30 machines fail to boot and show a storage-related stop error. The other laptops work normally.

A support engineer attaches a kernel debugger to one failed laptop and inspects the disk device stack. It shows two lower filter drivers: the new encryption filter and an older backup agent filter that was never fully uninstalled. The old filter attaches in the wrong order and passes unencrypted requests below the encryption layer. The engineer removes the stale filter entry from the registry with a deployment script. All 30 laptops boot normally on the next restart, and the team adds a filter inventory check to its rollout procedure.