Skip to contentSkip to conversation

CVE-2022-50530: blk-mq: fix null pointer dereference in blk_mq_clear_rq_mapping()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Oct 7, 2025

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

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().

The Linux kernel CVE team has assigned CVE-2022-50530 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.16 with commit 63064be150e4b1ba1e4af594ef5aa81adf21a52d and fixed in 6.0.6 with commit 6a440e6d04431e774dc084abe88c106e2a474c1a
	Issue introduced in 5.16 with commit 63064be150e4b1ba1e4af594ef5aa81adf21a52d and fixed in 6.1 with commit 76dd298094f484c6250ebd076fa53287477b2328

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2022-50530

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
block/blk-mq.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/6a440e6d04431e774dc084abe88c106e2a474c1a
	https://git.kernel.org/stable/c/76dd298094f484c6250ebd076fa53287477b2328