CVE-2022-49901: blk-mq: Fix kmemleak in blk_mq_init_allocated_queue
In the Linux kernel, the following vulnerability has been resolved:
blk-mq: Fix kmemleak in blkmqinitallocatedqueue
There is a kmemleak caused by modprobe nullblk.ko
unreferenced object 0xffff8881acb1f000 (size 1024): comm "modprobe", pid 836, jiffies 4294971190 (age 27.068s) hex dump (first 32 bytes): 00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N.......... ff ff ff ff ff ff ff ff 00 53 99 9e ff ff ff ff .........S...... backtrace: [<000000004a10c249>] kmallocnodetrace+0x22/0x60 [<00000000648f7950>] blkmqallocandinithctx+0x289/0x350 [<00000000af06de0e>] blkmqreallochwctxs+0x2fe/0x3d0 [<00000000e00c1872>] blkmqinitallocatedqueue+0x48c/0x1440 [<00000000d16b4e68>] blkmqallocdisk+0xc8/0x1c0 [<00000000d10c98c3>] 0xffffffffc450d69d [<00000000b9299f48>] 0xffffffffc4538392 [<0000000061c39ed6>] dooneinitcall+0xd0/0x4f0 [<00000000b389383b>] doinitmodule+0x1a4/0x680 [<0000000087cf3542>] loadmodule+0x6249/0x7110 [<00000000beba61b8>] dosysfinitmodule+0x140/0x200 [<00000000fdcfff51>] dosyscall64+0x35/0x80 [<000000003c0f1f71>] entrySYSCALL64afterhwframe+0x46/0xb0
That is because q->maops is set to NULL before blkreleasequeue is called.
blkmqinitqueuedata blkmqinitallocatedqueue blkmqreallochwctxs for (i = 0; i < set->nrhwqueues; i++) { oldhctx = xaload(&q->hctxtable, i); if (!blkmqallocandinithctx(.., i, ..)) [1] if (!oldhctx) break;
xaforeachstart(&q->hctxtable, j, hctx, j) blkmqexithctx(q, set, hctx, j); [2]
if (!q->nrhwqueues) [3] goto errhctxs;
errexit: q->mqops = NULL; [4]
blkputqueue blkreleasequeue if (queueismq(q)) [5] blkmqrelease(q);
[1]: blkmqallocandinithctx failed at i != 0. [2]: The hctxs allocated by [1] are moved to q->unusedhctxlist and will be cleaned up in blkmqrelease. [3]: q->nrhwqueues is 0. [4]: Set q->mqops to NULL. [5]: queueismq returns false due to [4]. And blkmqrelease will not be called. The hctxs in q->unusedhctxlist are leaked.
To fix it, call blkreleasequeue in exception path.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2022-49901?
CVE-2022-49901 has been classified with a medium severity due to the potential for kernel memory leaks.
How do I fix CVE-2022-49901?
To mitigate CVE-2022-49901, update your Linux kernel to the latest stable version that includes the fix.
What types of systems are affected by CVE-2022-49901?
CVE-2022-49901 affects systems running vulnerable versions of the Linux kernel that utilize the blk-mq IO scheduler.
What is the nature of the vulnerability in CVE-2022-49901?
CVE-2022-49901 involves a memory leak associated with the initialization of a block queue leading to unreferenced memory objects.
Is CVE-2022-49901 related to modprobe or any specific module?
Yes, CVE-2022-49901 is triggered during the loading of the null_blk module via modprobe.