freenode
Kernel & Low-Level

Kernel patch would block forced driver binds by default

Uwe Kleine-König wants driver_override opt-in only, after mismatched binds crash drivers that never expected them; VFIO and PCI stubs would have to declare themselves safe.

A proposed change to the Linux driver core would stop the kernel from honoring a forced driver bind unless the driver has explicitly opted in. Uwe Kleine-König argues that driver_override is useful only for a small set of drivers written to accept it, and that binding others anyway often ends in a NULL pointer exception.

Today, userspace can name a driver and force it onto a device even when the driver's ID table would never have matched. That is the usual, non-racy way to hand a device to VFIO, a userspace I/O driver, or a PCI stub that exists only to keep a real driver off the hardware. It is also how people accidentally attach a driver that assumes resources, callbacks, or device state it will never see. The patch would refuse those matches unless the driver sets a new flag, or the machine is booted with allow_driver_override=1. A forced match that still goes through under that parameter would taint the kernel, so a later oops is easier to attribute.

Kleine-König listed the drivers he knows must opt in if the change lands: SPI's userspace driver, PCI stub, several UIO drivers, and the VFIO drivers used for device assignment, including s390's. The userspace I2C driver does not need the flag. Alex Williamson, who maintains VFIO, followed with patches marking the PCI stub drivers and the VFIO drivers, including the s390 ones, as safe for override. He described override as the standard way those stubs and VFIO drivers are associated with a device.

Danilo Krummrich asked that those opt-in changes travel with the core patch, rather than landing later in separate trees and leaving binds broken in between.

Michael Kelley, citing an earlier note from Williamson, asked whether PCI's new_id interface should get the same treatment. It can also force a bogus match and the same class of crash. Kleine-König said it probably should, but that he would not take it on: his PCI experience and test coverage are limited, and he would rather leave that to someone better placed.

The change is still a proposal. Reviewers including Bradley Morgan and Armin Wolf have signed off on the core patch; the practical question left is how the legitimate override users get flagged before the default flips.