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 6FD9F1BDCD for ; Wed, 6 Mar 2024 06:47:10 +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=1709707630; cv=none; b=nd/H76eDlrLqJttPIQh4s9V7LT7xI3hjO6j4y1Y21SosTaIKlNe0BB5hsRKWsxIB4mok9dv+Eba2oRkAmohxeMm0lLsc/qbb/7IHu+Jkp4t/AOK0s6OCgPl1yuv4gCLBHR6+ipRjpYBQx6U+4gatdjWaRqfBz0DuNCyBosyIQRM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709707630; c=relaxed/simple; bh=j52VRwwOSDVFllWfh2lfDtZO3l+3HyHaVZc8jtWYZiQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KVY5Kqs2pGmp3kdXqC5V/ZRcwzaB4Pk8oILKpzZYfcnoMTFesAWQ572u9zDpAl85M6K/MFn4421tN3LjLl77AQxWfsfT4QIwk38tQP/+/LbIe5m0AiLQ01VslyRJuaxT4jIrq1kThaQLc2+vxJnRKt62gbDTN3iNYD5AaAGW2jg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nt01wCAP; 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="nt01wCAP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02C60C433F1; Wed, 6 Mar 2024 06:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709707630; bh=j52VRwwOSDVFllWfh2lfDtZO3l+3HyHaVZc8jtWYZiQ=; h=From:To:Cc:Subject:Date:Reply-to:From; b=nt01wCAP0vqhBkKM2Zf9up/eEnRnbIInZomhEwH8kCDH37yvDuGb/aMQRLNmTAj9z 3wnbT4UiSQnI9911tVvuLh3eyybVoSzcJg7rsua/C+0jjrKNweOjmqqlPXQSVxlqp3 jsQAnCqDu9Xuxw+06tZFApGQ1ITWQTKG1j6NCKLg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26628: drm/amdkfd: Fix lock dependency warning Date: Wed, 6 Mar 2024 06:46:11 +0000 Message-ID: <2024030649-CVE-2024-26628-f6ce@gregkh> X-Mailer: git-send-email 2.44.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=4720; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=j52VRwwOSDVFllWfh2lfDtZO3l+3HyHaVZc8jtWYZiQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDKkvBGVfTXzbtKFH287p0nPppV+E385KX1d5533i0/Utf oxqvI8lOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiWxYzzNPiqg7ZKHHXXvOb +om+x6Jq907e+M8wPzdh531fdXmNCuO/e4vfh018/qpaAQA= 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: drm/amdkfd: Fix lock dependency warning ====================================================== WARNING: possible circular locking dependency detected 6.5.0-kfd-fkuehlin #276 Not tainted ------------------------------------------------------ kworker/8:2/2676 is trying to acquire lock: ffff9435aae95c88 ((work_completion)(&svm_bo->eviction_work)){+.+.}-{0:0}, at: __flush_work+0x52/0x550 but task is already holding lock: ffff9435cd8e1720 (&svms->lock){+.+.}-{3:3}, at: svm_range_deferred_list_work+0xe8/0x340 [amdgpu] which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&svms->lock){+.+.}-{3:3}: __mutex_lock+0x97/0xd30 kfd_ioctl_alloc_memory_of_gpu+0x6d/0x3c0 [amdgpu] kfd_ioctl+0x1b2/0x5d0 [amdgpu] __x64_sys_ioctl+0x86/0xc0 do_syscall_64+0x39/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #1 (&mm->mmap_lock){++++}-{3:3}: down_read+0x42/0x160 svm_range_evict_svm_bo_worker+0x8b/0x340 [amdgpu] process_one_work+0x27a/0x540 worker_thread+0x53/0x3e0 kthread+0xeb/0x120 ret_from_fork+0x31/0x50 ret_from_fork_asm+0x11/0x20 -> #0 ((work_completion)(&svm_bo->eviction_work)){+.+.}-{0:0}: __lock_acquire+0x1426/0x2200 lock_acquire+0xc1/0x2b0 __flush_work+0x80/0x550 __cancel_work_timer+0x109/0x190 svm_range_bo_release+0xdc/0x1c0 [amdgpu] svm_range_free+0x175/0x180 [amdgpu] svm_range_deferred_list_work+0x15d/0x340 [amdgpu] process_one_work+0x27a/0x540 worker_thread+0x53/0x3e0 kthread+0xeb/0x120 ret_from_fork+0x31/0x50 ret_from_fork_asm+0x11/0x20 other info that might help us debug this: Chain exists of: (work_completion)(&svm_bo->eviction_work) --> &mm->mmap_lock --> &svms->lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&svms->lock); lock(&mm->mmap_lock); lock(&svms->lock); lock((work_completion)(&svm_bo->eviction_work)); I believe this cannot really lead to a deadlock in practice, because svm_range_evict_svm_bo_worker only takes the mmap_read_lock if the BO refcount is non-0. That means it's impossible that svm_range_bo_release is running concurrently. However, there is no good way to annotate this. To avoid the problem, take a BO reference in svm_range_schedule_evict_svm_bo instead of in the worker. That way it's impossible for a BO to get freed while eviction work is pending and the cancel_work_sync call in svm_range_bo_release can be eliminated. v2: Use svm_bo_ref_unless_zero and explained why that's safe. Also removed redundant checks that are already done in amdkfd_fence_enable_signaling. The Linux kernel CVE team has assigned CVE-2024-26628 to this issue. Affected and fixed versions =========================== Fixed in 5.15.149 with commit 7a70663ba02b Fixed in 6.1.77 with commit 8b25d397162b Fixed in 6.6.16 with commit 28d2d623d2fb Fixed in 6.7.4 with commit cb96e492d72d Fixed in 6.8-rc1 with commit 47bf0f83fc86 Please see https://www.kernel.org or 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-26628 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/gpu/drm/amd/amdkfd/kfd_svm.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/7a70663ba02bd4e19aea8d70c979eb3bd03d839d https://git.kernel.org/stable/c/8b25d397162b0316ceda40afaa63ee0c4a97d28b https://git.kernel.org/stable/c/28d2d623d2fbddcca5c24600474e92f16ebb3a05 https://git.kernel.org/stable/c/cb96e492d72d143d57db2d2bc143a1cee8741807 https://git.kernel.org/stable/c/47bf0f83fc86df1bf42b385a91aadb910137c5c9