From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7582D198E6F for ; Thu, 1 May 2025 14:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746109163; cv=none; b=nqJIvQR39yJHoX88ePWW3dMyY+SpNyVF+/7SzZ9JTPEr3ZF+NXOJJLHiJXR6sn7X8odESecQMiDKzxLXKfOcYHD3z2vntUSVi2leU3n1G00WMxKenwE2CfE3o5WN0pp/TH07P/MiTQ6FBOSOCdgeqEA1uK6Xeg4oUeysxFK6DRg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746109163; c=relaxed/simple; bh=qGMeUdwEo4fyvIzL5q74sHUokBA2jDpMEOdrJ+Le77M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DqwMCrCCOYMR7rFlQFEYVcY4t8+JFN2juKknNsZDFfbkg0TWcmBNic98HzGUD+htIgmG69P5U5tg5B8eJ1V7XSX5uqhoBgN8hYYTFjxXDKinkmpo8Okhv2aQ5T3QKyKrih64Q3L3G2ecYOxcxa+qONXLmPeVL53XMwAsEm/0LTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Kg0fmYsU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Kg0fmYsU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2A8FC4CEE3; Thu, 1 May 2025 14:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746109163; bh=qGMeUdwEo4fyvIzL5q74sHUokBA2jDpMEOdrJ+Le77M=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Kg0fmYsUD6znv9o8/gUN4mzTCD2Ktjq93DdDFz/FV595kjgWCZxcTjSymrJSev4vU PEqoKpoCQh5g17obeDpj11AN0nafJslraOIXOufqmRgT56Wzwu/SZu8NnPpRiElPnB Icwt7pAPyU+CXdQcWhqYkHKE8srlHCRHYAPhQaH0= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49901: blk-mq: Fix kmemleak in blk_mq_init_allocated_queue Date: Thu, 1 May 2025 16:11:31 +0200 Message-ID: <2025050101-CVE-2022-49901-1130@gregkh> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3914; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=9Bhr7UhPDRlNKTNcKN++npMLSysIlWcGOby1DNaaGR0=; b=owGbwMvMwCRo6H6F97bub03G02pJDBnCDbtyN0qGL1HWlZ9Tzquy9MlLZdP+MAfByY/CtS4+W 3x0whObjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIwg8M8ysXn8vfeCjbZtuC PY91pQJzW35EnmWYZzS3t7h99tM5IlE2/gUGi9beeOxRAwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: blk-mq: Fix kmemleak in blk_mq_init_allocated_queue There is a kmemleak caused by modprobe null_blk.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>] kmalloc_node_trace+0x22/0x60 [<00000000648f7950>] blk_mq_alloc_and_init_hctx+0x289/0x350 [<00000000af06de0e>] blk_mq_realloc_hw_ctxs+0x2fe/0x3d0 [<00000000e00c1872>] blk_mq_init_allocated_queue+0x48c/0x1440 [<00000000d16b4e68>] __blk_mq_alloc_disk+0xc8/0x1c0 [<00000000d10c98c3>] 0xffffffffc450d69d [<00000000b9299f48>] 0xffffffffc4538392 [<0000000061c39ed6>] do_one_initcall+0xd0/0x4f0 [<00000000b389383b>] do_init_module+0x1a4/0x680 [<0000000087cf3542>] load_module+0x6249/0x7110 [<00000000beba61b8>] __do_sys_finit_module+0x140/0x200 [<00000000fdcfff51>] do_syscall_64+0x35/0x80 [<000000003c0f1f71>] entry_SYSCALL_64_after_hwframe+0x46/0xb0 That is because q->ma_ops is set to NULL before blk_release_queue is called. blk_mq_init_queue_data blk_mq_init_allocated_queue blk_mq_realloc_hw_ctxs for (i = 0; i < set->nr_hw_queues; i++) { old_hctx = xa_load(&q->hctx_table, i); if (!blk_mq_alloc_and_init_hctx(.., i, ..)) [1] if (!old_hctx) break; xa_for_each_start(&q->hctx_table, j, hctx, j) blk_mq_exit_hctx(q, set, hctx, j); [2] if (!q->nr_hw_queues) [3] goto err_hctxs; err_exit: q->mq_ops = NULL; [4] blk_put_queue blk_release_queue if (queue_is_mq(q)) [5] blk_mq_release(q); [1]: blk_mq_alloc_and_init_hctx failed at i != 0. [2]: The hctxs allocated by [1] are moved to q->unused_hctx_list and will be cleaned up in blk_mq_release. [3]: q->nr_hw_queues is 0. [4]: Set q->mq_ops to NULL. [5]: queue_is_mq returns false due to [4]. And blk_mq_release will not be called. The hctxs in q->unused_hctx_list are leaked. To fix it, call blk_release_queue in exception path. The Linux kernel CVE team has assigned CVE-2022-49901 to this issue. Affected and fixed versions =========================== Issue introduced in 5.2 with commit 2f8f1336a48bd5186de3476da0a3e2ec06d0533a and fixed in 6.0.8 with commit 2dc97e15a54b7bdf457848aa8c663c98a24e58a6 Issue introduced in 5.2 with commit 2f8f1336a48bd5186de3476da0a3e2ec06d0533a and fixed in 6.1 with commit 943f45b9399ed8b2b5190cbc797995edaa97f58f 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-49901 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/2dc97e15a54b7bdf457848aa8c663c98a24e58a6 https://git.kernel.org/stable/c/943f45b9399ed8b2b5190cbc797995edaa97f58f