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 7A7271D54A for ; Wed, 19 Jun 2024 14:58: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=1718809113; cv=none; b=rT+y2B8p93t7W0sy2sShoZz5wjLKYmWc0UG1CXrCHcXX2wTsssvgx6AdxRf+6vd0lBmTd+9XKKKhmQVxbI3ObFqHECmiG43inlQJhcul3vDKgK0O9bPWWgarY1BjGYdYTWzpaFTHfdjBRhxsOizj6paccsX9Z+Oy4GV8CbYgG3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718809113; c=relaxed/simple; bh=l5q7emsD6csBxuGMylbFbwkd1siqvuZmrD/mXtrif88=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZnVQ9ZzckSupVlKu7Z8gWdvimvkNiJmjY8J3qzS09kuevDCwkBUQM8szvxbTiiZNgG3WVJh5F/7mC5PeocQgwEDL4pniV8DhBrPmeXyw2FNt8+WlvolNk6t3Qww1xfeWiEudIWBPXqx5on2N9sKksTCD0r1z70TA/8bQ+0R5eC0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k+hX0gh6; 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="k+hX0gh6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01FC9C2BBFC; Wed, 19 Jun 2024 14:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718809113; bh=l5q7emsD6csBxuGMylbFbwkd1siqvuZmrD/mXtrif88=; h=From:To:Cc:Subject:Date:Reply-to:From; b=k+hX0gh6dX3BlaVIz81krBFWFQABPta+eVNbSBlt/XWByWK5hwikpkW49gqiw7Ce1 vGkn6gOIljvKJ025tnxfOrl127+zL7S1mU+d2DaCCHO/9OJW77S/kjJPwwd3X6VhhF UaA/aQN89eSl7dAwFsJJykankZoMv13rrStN8ryw= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47615: RDMA/mlx5: Fix releasing unallocated memory in dereg MR flow Date: Wed, 19 Jun 2024 16:58:14 +0200 Message-ID: <2024061909-CVE-2021-47615-3c6a@gregkh> X-Mailer: git-send-email 2.45.2 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=3501; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=l5q7emsD6csBxuGMylbFbwkd1siqvuZmrD/mXtrif88=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlFnxh3HxdOn2V0Pbxz3q6fzMkB+cUHuA5NKtr9fsH8R 4/veS151RHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQATifvOMD+3qufPn7++d7rk 76d9Dbdd8MBZazfDgqXTw3Yy/C/7rtsoNKGlz0+bKXHaDwA= 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: RDMA/mlx5: Fix releasing unallocated memory in dereg MR flow For the case of IB_MR_TYPE_DM the mr does doesn't have a umem, even though it is a user MR. This causes function mlx5_free_priv_descs() to think that it is a kernel MR, leading to wrongly accessing mr->descs that will get wrong values in the union which leads to attempt to release resources that were not allocated in the first place. For example: DMA-API: mlx5_core 0000:08:00.1: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=0 bytes] WARNING: CPU: 8 PID: 1021 at kernel/dma/debug.c:961 check_unmap+0x54f/0x8b0 RIP: 0010:check_unmap+0x54f/0x8b0 Call Trace: debug_dma_unmap_page+0x57/0x60 mlx5_free_priv_descs+0x57/0x70 [mlx5_ib] mlx5_ib_dereg_mr+0x1fb/0x3d0 [mlx5_ib] ib_dereg_mr_user+0x60/0x140 [ib_core] uverbs_destroy_uobject+0x59/0x210 [ib_uverbs] uobj_destroy+0x3f/0x80 [ib_uverbs] ib_uverbs_cmd_verbs+0x435/0xd10 [ib_uverbs] ? uverbs_finalize_object+0x50/0x50 [ib_uverbs] ? lock_acquire+0xc4/0x2e0 ? lock_acquired+0x12/0x380 ? lock_acquire+0xc4/0x2e0 ? lock_acquire+0xc4/0x2e0 ? ib_uverbs_ioctl+0x7c/0x140 [ib_uverbs] ? lock_release+0x28a/0x400 ib_uverbs_ioctl+0xc0/0x140 [ib_uverbs] ? ib_uverbs_ioctl+0x7c/0x140 [ib_uverbs] __x64_sys_ioctl+0x7f/0xb0 do_syscall_64+0x38/0x90 Fix it by reorganizing the dereg flow and mlx5_ib_mr structure: - Move the ib_umem field into the user MRs structure in the union as it's applicable only there. - Function mlx5_ib_dereg_mr() will now call mlx5_free_priv_descs() only in case there isn't udata, which indicates that this isn't a user MR. The Linux kernel CVE team has assigned CVE-2021-47615 to this issue. Affected and fixed versions =========================== Issue introduced in 5.13 with commit f18ec4223117 and fixed in 5.15.10 with commit e3bc4d4b50ca Issue introduced in 5.13 with commit f18ec4223117 and fixed in 5.15.14 with commit c44979ace49b Issue introduced in 5.13 with commit f18ec4223117 and fixed in 5.16 with commit f0ae4afe3d35 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-2021-47615 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/mlx5_ib.h drivers/infiniband/hw/mlx5/mr.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/e3bc4d4b50cae7db08e50dbe43f771c906e97701 https://git.kernel.org/stable/c/c44979ace49b4aede3cc7cb5542316e53a4005c9 https://git.kernel.org/stable/c/f0ae4afe3d35e67db042c58a52909e06262b740f