🎓 BookMCQ
← Back to 18. The Linux System

📝 Driver registration of Linux system (10 MCQs)

Connecting Device Drivers to the Linux Device Model

Driver registration is the process by which Linux makes a device driver available to the kernel's device model. Drivers register with an appropriate bus or subsystem and provide operations for matching, probing, and managing supported devices. This mechanism connects hardware discovery with driver functionality, allowing the kernel to associate devices with software capable of controlling them.

Why Drivers Need a Standard Registration Framework

Different hardware buses and device classes require different discovery and communication procedures. Without a common driver model, every driver would need to implement unrelated registration and lifecycle handling. Linux provides structures and callbacks that organise devices, drivers, buses, and classes while preserving device-specific operations.

Matching, Probe and Device Registration

A driver registers its supported identifiers and callback operations with the relevant bus. When a matching device is discovered, the driver core invokes its probe function. The driver checks the hardware, allocates resources, and registers usable interfaces. When the device is removed, its removal callback releases resources and unregisters associated services.

Example of Registering a PCI Device Driver

A PCI network adapter is discovered during system enumeration. The kernel compares its vendor and device identifiers with registered driver tables. When a match is found, the driver's probe routine initialises the adapter and registers a network interface. The networking subsystem can then use that interface for communication.

Lifecycle Management and Driver Compatibility

Driver registration supports modular hardware discovery, consistent device management, and reuse of common kernel infrastructure. Incorrect identifier matching or failed probe routines can leave devices unavailable. Registration also does not guarantee that hardware operates correctly; the driver must handle interrupts, memory, power management, and device-specific errors safely.

Misconceptions About Driver Registration

'Registering a driver automatically guarantees that every device works' ignores probe failures and hardware differences. 'A driver registers only with a global device list' overlooks bus and subsystem frameworks. 'The probe routine is called for every device regardless of match' is false because matching rules determine candidate drivers.

Exam Focus: Driver Matching and Probe Lifecycle

Trace device discovery, identifier matching, driver registration, probe execution, and device removal. Identify the roles of bus, device, driver, and callback structures. Questions may ask how a PCI device is matched or why successful registration can still be followed by a probe failure.

Key Terms of Linux Driver Registration

  • Driver core - Framework coordinating Linux device drivers.
  • Bus - Framework connecting devices and drivers.
  • Probe - Callback initialising a matched device.
  • Device ID - Identifier used for driver matching.
  • Remove callback - Releases resources when a device is removed.
2
Easy
5
Medium
3
Hard

📝 All Driver registration of Linux system MCQs

Q1. What command directly inserts a compiled kernel module file into the running Linux kernel without resolving dependencies?

A.insmod ✅
B.lsmod
C.rmmod
D.modprobe
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The correct answer is A because insmod loads a .ko file exactly as it is, placing it into kernel memory without checking for required symbols or other modules. lsmod only lists currently loaded modules, so it cannot load anything. rmmod removes modules, not adds them. modprobe does load modules but first resolves dependencies, which insmod does not. Understanding the difference helps a developer choose the right tool when testing a single module in isolation.

Q2. A new USB device appears but the system reports “unknown device”. Which command should you run to automatically locate and load the appropriate driver module?

A.insmod
B.modprobe ✅
C.rmmod
D.lsmod
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The correct answer is B because modprobe searches the module directory, determines the needed driver based on device IDs, resolves any dependent modules, and loads them, making the device functional. insmod requires the exact filename and does not handle dependencies, so it would likely fail. rmmod removes modules, and lsmod only displays loaded modules. Using modprobe mirrors typical real‑world troubleshooting when a driver is missing.

Q3. Why does the GPL license requirement affect the distribution of third‑party kernel modules?

A.It forces all code to be open source, preventing proprietary drivers from being added to the kernel.
B.It allows proprietary modules to be loaded without source disclosure.
C.It requires that any module linked against the kernel must also be released under the GPL, ensuring source code availability. ✅
D.It has no impact on module distribution because modules run in user space.
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The correct answer is C because the Linux kernel is GPL‑licensed, and any code that links directly with kernel symbols is considered a derivative work, which must also be GPL‑licensed and provide source. This prevents proprietary drivers from being bundled with the kernel without releasing their source. Option A misstates the effect; the kernel itself is open source, but modules can be separate. Option B is false because GPL does not permit closed‑source linking. Option D is incorrect because kernel modules execute in kernel space, not user space.

Q4. How do loadable kernel modules simplify driver development compared to recompiling the entire kernel?

A.Modules allow developers to test a driver by loading it into the running kernel, avoiding a full rebuild and reboot. ✅
B.Modules replace the need for any kernel source code changes.
C.Modules automatically update hardware firmware when loaded.
D.Modules prevent any need for kernel configuration changes.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The correct answer is A because a loadable module can be compiled independently and inserted into a live kernel, so developers can iterate quickly without rebuilding the whole kernel image or rebooting. Option B is wrong; while modules reduce recompilation, kernel source may still need changes for core features. Option C is unrelated; modules do not manage firmware. Option D is inaccurate because kernel configuration (e.g., enabling module support) may still be required.

Q5. What is a primary security concern when loading a third‑party kernel module into a production system?

A.The module may consume excessive CPU resources, slowing the system.
B.The module runs with full kernel privileges, so bugs or malicious code can compromise the entire OS. ✅
C.The module can only access its own allocated memory, limiting impact.
D.The module is sandboxed by the kernel, preventing any security issues.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The correct answer is B because a kernel module operates in privileged kernel mode, giving it unrestricted access to hardware, memory, and core data structures; any flaw or malicious intent can lead to system compromise. Option A describes a performance issue, not a security risk. Option C is false because kernel modules are not confined to their own memory. Option D incorrectly suggests sandboxing, which does not exist for kernel code. This highlights why administrators must verify module provenance before loading.

Q6. A driver module depends on another module that provides required symbols. Which command should you use to ensure all dependencies are loaded automatically?

A.insmod
B.modprobe ✅
C.rmmod
D.depmod
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The correct answer is B because modprobe looks up the module’s dependency list (generated by depmod) and loads any required supporting modules before loading the target module. insmod loads only the specified file and will fail if dependencies are missing. rmmod removes modules, and depmod only creates the dependency database; it does not load modules. In practice, using modprobe prevents missing‑symbol errors when a driver relies on other kernel components.

Q7. After finishing work with a newly loaded driver, you need to unload it safely. Which command is the preferred method?

A.rmmod
B.modprobe -r ✅
C.insmod
D.lsmod
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The correct answer is B because modprobe ‑r removes a module while also handling reference counts and automatically unloading any dependent modules, ensuring a clean state. rmmod can remove a module but will refuse if other modules depend on it, risking instability. insmod adds modules, not removes them, and lsmod only lists loaded modules. Using modprobe ‑r mirrors typical system administration practice for safe module removal.

Q8. A kernel module fails to load because its version does not match the running kernel. What is the most appropriate corrective action?

A.Recompile the module against the current kernel headers and install it. ✅
B.Ignore the warning and force the load with insmod -f.
C.Load an older kernel that matches the module version.
D.Disable module loading entirely.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The correct answer is A because recompiling the module with the headers of the currently running kernel ensures binary compatibility, allowing the symbols to match. Option B (insmod ‑f) forces loading but can cause crashes due to mismatched interfaces. Option C avoids the problem but is impractical for a production environment. Option D eliminates the benefit of modular drivers. Rebuilding the module is the safe, standard solution taught in driver development.

Q9. When building a custom driver as a kernel module, which make target should you invoke to compile the .ko file?

A.make modules ✅
B.make install
C.make clean
D.make all
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The correct answer is A because make modules is the standard target that compiles source files into loadable kernel object (.ko) files, ready for insertion with insmod or modprobe. make install copies files to system locations but does not build them. make clean removes build artifacts, and make all typically builds the entire kernel, not just modules. Knowing the proper make target streamlines the development workflow for driver authors.

Q10. Why is driver registration performed inside the module’s init function?

A.It informs the kernel about the device and registers file operations so the driver can be called. ✅
B.It allocates user‑space memory for the driver’s buffers.
C.It starts a background daemon that monitors hardware events.
D.It mounts a temporary filesystem for driver configuration files.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The correct answer is A because the init function is executed when the module is loaded; registering the driver there tells the kernel which devices the driver handles and sets up the necessary callbacks. Option B describes memory allocation, which may occur but is not the primary purpose of registration. Option C is unrelated to kernel driver initialization. Option D describes filesystem actions, not driver registration. Proper registration is essential for the kernel to route I/O requests to the new driver.

🔗 Related Topics (MCQs)