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 4BE411EB9F7 for ; Mon, 21 Oct 2024 12:03:49 +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=1729512229; cv=none; b=M22/nZUmh4z/cTNCqy60JP0LBjUJwaumw1y9kY7J45ANBI66LKB8c9bMUsXx21LaLPTMUCVc7beyQEswMWXDfBFVMw3DUicwiA9zwa1OlqmHq3p3AhaPiDlaSdDcTfgXuU+HumgdWxMfSvxYsFe4TDN9/Umv/K+RUDxZied69Jg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729512229; c=relaxed/simple; bh=IOc8MiiDCwwAtnEmc22/CMuW1hSbRWzjJpI/HGZkwDo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=q6PtWla6gj0Xq/STXmWVvA7Q7mg2yiYIfy4/oUL0wjQnNXx7Qz03xLcv1+4KzFIJLGZPyLoi4IkUbhuj7k0jAHX81eOWMewmW/hndjphesefNPk3DTa8FWhWDEGHZWF6/ooZKg2EPDmWutyzv0g/Zoz/c8TzVSE62KRMd/ocnMY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Az9lVoxV; 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="Az9lVoxV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82392C4CEC3; Mon, 21 Oct 2024 12:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729512228; bh=IOc8MiiDCwwAtnEmc22/CMuW1hSbRWzjJpI/HGZkwDo=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Az9lVoxVBRm8QXBpQXoUxiX195HY3/mzDLfV1+RvDOq9jkXlGRYcbH8O5W0DW0g/e y4GMfaYQZJAj+iVIakW6vuG52ysnvVJEvMEIwMOgvaqRrwCJuNXG8s7tWbI0xudzKR HaP830FNmrPFV2cy119Nmtv8NEXwIcQwGR+Gg3Yo= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-47719: iommufd: Protect against overflow of ALIGN() during iova allocation Date: Mon, 21 Oct 2024 14:00:47 +0200 Message-ID: <2024102121-CVE-2024-47719-09a2@gregkh> X-Mailer: git-send-email 2.47.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=4499; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=IOc8MiiDCwwAtnEmc22/CMuW1hSbRWzjJpI/HGZkwDo=; b=owGbwMvMwCRo6H6F97bub03G02pJDOliTqHiniVfLxtdz2GNFzIue21VXD+Tq/hrqUsvR0kAS 1+/SlhHLAuDIBODrJgiy5dtPEf3VxxS9DK0PQ0zh5UJZAgDF6cATOT1Uoa5shOncL8tccqyOSS9 5z1T9dU/a3iTGBa0zl63bpu71br6UA9tO2WbzxW305oA 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: iommufd: Protect against overflow of ALIGN() during iova allocation Userspace can supply an iova and uptr such that the target iova alignment becomes really big and ALIGN() overflows which corrupts the selected area range during allocation. CONFIG_IOMMUFD_TEST can detect this: WARNING: CPU: 1 PID: 5092 at drivers/iommu/iommufd/io_pagetable.c:268 iopt_alloc_area_pages drivers/iommu/iommufd/io_pagetable.c:268 [inline] WARNING: CPU: 1 PID: 5092 at drivers/iommu/iommufd/io_pagetable.c:268 iopt_map_pages+0xf95/0x1050 drivers/iommu/iommufd/io_pagetable.c:352 Modules linked in: CPU: 1 PID: 5092 Comm: syz-executor294 Not tainted 6.10.0-rc5-syzkaller-00294-g3ffea9a7a6f7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 RIP: 0010:iopt_alloc_area_pages drivers/iommu/iommufd/io_pagetable.c:268 [inline] RIP: 0010:iopt_map_pages+0xf95/0x1050 drivers/iommu/iommufd/io_pagetable.c:352 Code: fc e9 a4 f3 ff ff e8 1a 8b 4c fc 41 be e4 ff ff ff e9 8a f3 ff ff e8 0a 8b 4c fc 90 0f 0b 90 e9 37 f5 ff ff e8 fc 8a 4c fc 90 <0f> 0b 90 e9 68 f3 ff ff 48 c7 c1 ec 82 ad 8f 80 e1 07 80 c1 03 38 RSP: 0018:ffffc90003ebf9e0 EFLAGS: 00010293 RAX: ffffffff85499fa4 RBX: 00000000ffffffef RCX: ffff888079b49e00 RDX: 0000000000000000 RSI: 00000000ffffffef RDI: 0000000000000000 RBP: ffffc90003ebfc50 R08: ffffffff85499b30 R09: ffffffff85499942 R10: 0000000000000002 R11: ffff888079b49e00 R12: ffff8880228e0010 R13: 0000000000000000 R14: 1ffff920007d7f68 R15: ffffc90003ebfd00 FS: 000055557d760380(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000005fdeb8 CR3: 000000007404a000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: iommufd_ioas_copy+0x610/0x7b0 drivers/iommu/iommufd/ioas.c:274 iommufd_fops_ioctl+0x4d9/0x5a0 drivers/iommu/iommufd/main.c:421 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Cap the automatic alignment to the huge page size, which is probably a better idea overall. Huge automatic alignments can fragment and chew up the available IOVA space without any reason. The Linux kernel CVE team has assigned CVE-2024-47719 to this issue. Affected and fixed versions =========================== Issue introduced in 6.2 with commit 51fe6141f0f6 and fixed in 6.6.54 with commit cd6dd564ae7d Issue introduced in 6.2 with commit 51fe6141f0f6 and fixed in 6.10.13 with commit a6e9f9fd1477 Issue introduced in 6.2 with commit 51fe6141f0f6 and fixed in 6.11.2 with commit 72b78287ce92 Issue introduced in 6.2 with commit 51fe6141f0f6 and fixed in 6.12-rc1 with commit 8f6887349b2f 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-2024-47719 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/iommu/iommufd/io_pagetable.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/cd6dd564ae7d99967ef50078216929418160b30e https://git.kernel.org/stable/c/a6e9f9fd14772c0b23c6d1d7002d98f9d27cb1f6 https://git.kernel.org/stable/c/72b78287ce92802e8ba678181a34b84ae844a112 https://git.kernel.org/stable/c/8f6887349b2f829a4121c518aeb064fc922714e4