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 92F9B446B4 for ; Tue, 21 May 2024 15:38:33 +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=1716305913; cv=none; b=Veug5CcK9v9TFHcA2cGOEN7RooG187H7M9ppM8+Vvaa1YO+RHQsKQ83QKBe5UjUM25+2wYMor2cVLrJ419tdn0xizTc8bTc/ytredpmFHyUGLGubqCokQo2TKHsFGKE7qg3aXgUuWb7HVX2DoSAG+dU71CaMl+5gfmRAK72VjTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716305913; c=relaxed/simple; bh=GWmXUN2b4j7L5CMBHNZJeoy8i5PDM7ybustwENN08mk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PApsCnweF+gFV9Vp7eAhdpdlxLgMEwD7annghht/L/un4EDtl6aio77RM23R3YVs5V9gH22FtK/qFsBind6pjJEJPMH8icM3QVQKrOnri6P4Kg3XO8x8I/C7Vdmws4vLHXTqrtXYrEdgclkyuhBBhPT1ZBNq1QumKsxowcbF9yc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bha67twd; 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="bha67twd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C725C2BD11; Tue, 21 May 2024 15:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716305913; bh=GWmXUN2b4j7L5CMBHNZJeoy8i5PDM7ybustwENN08mk=; h=From:To:Cc:Subject:Date:Reply-to:From; b=bha67twdqnAmRf3MumStgq3GieixiRsKydaCwdgyzH2DK8MvbZnaet6ZJ30UnrvwY 4tDwwksti+aaz+VpDYaeeReyjvwu5YMyHB9RJ+rHguci48hQKrfSJ6SRD1FNSV2zEg hTduXsXYw/EAWR2P65Qhcgw2UM7i5OxvMnxCpfoU= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-52851: IB/mlx5: Fix init stage error handling to avoid double free of same QP and UAF Date: Tue, 21 May 2024 17:32:27 +0200 Message-ID: <2024052114-CVE-2023-52851-b53c@gregkh> X-Mailer: git-send-email 2.45.1 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=4329; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=GWmXUN2b4j7L5CMBHNZJeoy8i5PDM7ybustwENN08mk=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk++5xK3z1hkHKPuOVwooxz9tXZL+fPf110d8IqWebp8 8WPtqx+2RHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQAT2XOaYcGenh3es2xuKyul cb0PkmmYeXzilbsM89OdAt+5qTJesX8RsuKu0Oanx9imqwEA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: IB/mlx5: Fix init stage error handling to avoid double free of same QP and UAF In the unlikely event that workqueue allocation fails and returns NULL in mlx5_mkey_cache_init(), delete the call to mlx5r_umr_resource_cleanup() (which frees the QP) in mlx5_ib_stage_post_ib_reg_umr_init(). This will avoid attempted double free of the same QP when __mlx5_ib_add() does its cleanup. Resolves a splat: Syzkaller reported a UAF in ib_destroy_qp_user workqueue: Failed to create a rescuer kthread for wq "mkey_cache": -EINTR infiniband mlx5_0: mlx5_mkey_cache_init:981:(pid 1642): failed to create work queue infiniband mlx5_0: mlx5_ib_stage_post_ib_reg_umr_init:4075:(pid 1642): mr cache init failed -12 ================================================================== BUG: KASAN: slab-use-after-free in ib_destroy_qp_user (drivers/infiniband/core/verbs.c:2073) Read of size 8 at addr ffff88810da310a8 by task repro_upstream/1642 Call Trace: kasan_report (mm/kasan/report.c:590) ib_destroy_qp_user (drivers/infiniband/core/verbs.c:2073) mlx5r_umr_resource_cleanup (drivers/infiniband/hw/mlx5/umr.c:198) __mlx5_ib_add (drivers/infiniband/hw/mlx5/main.c:4178) mlx5r_probe (drivers/infiniband/hw/mlx5/main.c:4402) ... Allocated by task 1642: __kmalloc (./include/linux/kasan.h:198 mm/slab_common.c:1026 mm/slab_common.c:1039) create_qp (./include/linux/slab.h:603 ./include/linux/slab.h:720 ./include/rdma/ib_verbs.h:2795 drivers/infiniband/core/verbs.c:1209) ib_create_qp_kernel (drivers/infiniband/core/verbs.c:1347) mlx5r_umr_resource_init (drivers/infiniband/hw/mlx5/umr.c:164) mlx5_ib_stage_post_ib_reg_umr_init (drivers/infiniband/hw/mlx5/main.c:4070) __mlx5_ib_add (drivers/infiniband/hw/mlx5/main.c:4168) mlx5r_probe (drivers/infiniband/hw/mlx5/main.c:4402) ... Freed by task 1642: __kmem_cache_free (mm/slub.c:1826 mm/slub.c:3809 mm/slub.c:3822) ib_destroy_qp_user (drivers/infiniband/core/verbs.c:2112) mlx5r_umr_resource_cleanup (drivers/infiniband/hw/mlx5/umr.c:198) mlx5_ib_stage_post_ib_reg_umr_init (drivers/infiniband/hw/mlx5/main.c:4076 drivers/infiniband/hw/mlx5/main.c:4065) __mlx5_ib_add (drivers/infiniband/hw/mlx5/main.c:4168) mlx5r_probe (drivers/infiniband/hw/mlx5/main.c:4402) ... The Linux kernel CVE team has assigned CVE-2023-52851 to this issue. Affected and fixed versions =========================== Issue introduced in 5.19 with commit 04876c12c19e and fixed in 6.1.63 with commit 437f033e30c8 Issue introduced in 5.19 with commit 04876c12c19e and fixed in 6.5.12 with commit 4f4a7a7d1404 Issue introduced in 5.19 with commit 04876c12c19e and fixed in 6.6.2 with commit 6387f269d84e Issue introduced in 5.19 with commit 04876c12c19e and fixed in 6.7 with commit 2ef422f063b7 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-2023-52851 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: drivers/infiniband/hw/mlx5/main.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/437f033e30c897bb3723eac9e9003cd9f88d00a3 https://git.kernel.org/stable/c/4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9 https://git.kernel.org/stable/c/6387f269d84e6e149499408c4d1fc805017729b2 https://git.kernel.org/stable/c/2ef422f063b74adcc4a4a9004b0a87bb55e0a836