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 DAE072777E1 for ; Thu, 4 Sep 2025 15:35:11 +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=1757000111; cv=none; b=p34MTNkc8uvV9oWy0x75aQm+oDT5xZb5c6teERUMKhO68oOMQ239lGUWxMeWe3tMNKm5cl8WlvFIBjP9btZZeMFLPyZFYgIWcXNJkpjflAjkAtV9at1QCZztIJI8FGDE9riJkVEs5upE4orHSa9KNBQyd65/+qFp2ZxajNomskU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757000111; c=relaxed/simple; bh=ns93wstqsP7ts9re2HvTKSxeo/YLdBIZ6CcR8VqWpww=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=o4CUolydpxo1/OFO3UUniaqihP81wbDpJVitkvgzqZepWBb2P1LcqiIWzvv6SadbiVUkyBd7FXOoRQFgVAeb8qlxGPx/5DoHXUBux4hW1TTlJmIgx/OapfqmRB4epNims6CZX8lYbS5J/RF51+1bZeh6BWenlZBVxpT2l3S6gBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tlG0SNQt; 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="tlG0SNQt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D38BC4CEF0; Thu, 4 Sep 2025 15:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757000111; bh=ns93wstqsP7ts9re2HvTKSxeo/YLdBIZ6CcR8VqWpww=; h=From:To:Cc:Subject:Date:Reply-to:From; b=tlG0SNQtjVIZYAM/UGhV9QHw5fVBqSZTb0uYTW3vC8dhtPtCW8C20a2TuvtPZpOcW e4VX9DgNT9jU7GVQ8gdmizoG3vTi+VlFGywajLBS/ntuqZlER/yAwdM2y4A75g5IIQ m23lEjaIFrZdUcc1swjCA/kvTrB+qAD/A4Qr875A= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38722: habanalabs: fix UAF in export_dmabuf() Date: Thu, 4 Sep 2025 17:33:27 +0200 Message-ID: <2025090400-CVE-2025-38722-de5f@gregkh> X-Mailer: git-send-email 2.51.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=3382; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=+DmKG5TkWdwD2zCh+j85G+MsPYbAkLBL9H8HDBB64gU=; b=owGbwMvMwCRo6H6F97bub03G02pJDBk7N+oEHBcQDFftnhXWfn5nUeMu4Ta5T2YBh0776n/mt 52yaO+JjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiI4S6GucJ+54T/XP+7SGxq kLxBxJRLXw/M82KYnxvIMCmouCeqjmvBbTlTIRaVSdoGAA== 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: habanalabs: fix UAF in export_dmabuf() As soon as we'd inserted a file reference into descriptor table, another thread could close it. That's fine for the case when all we are doing is returning that descriptor to userland (it's a race, but it's a userland race and there's nothing the kernel can do about it). However, if we follow fd_install() with any kind of access to objects that would be destroyed on close (be it the struct file itself or anything destroyed by its ->release()), we have a UAF. dma_buf_fd() is a combination of reserving a descriptor and fd_install(). habanalabs export_dmabuf() calls it and then proceeds to access the objects destroyed on close. In particular, it grabs an extra reference to another struct file that will be dropped as part of ->release() for ours; that "will be" is actually "might have already been". Fix that by reserving descriptor before anything else and do fd_install() only when everything had been set up. As a side benefit, we no longer have the failure exit with file already created, but reference to underlying file (as well as ->dmabuf_export_cnt, etc.) not grabbed yet; unlike dma_buf_fd(), fd_install() can't fail. The Linux kernel CVE team has assigned CVE-2025-38722 to this issue. Affected and fixed versions =========================== Issue introduced in 5.16 with commit db1a8dd916aac986871f6b873a3aefad906f383a and fixed in 6.12.43 with commit c07886761fd6251db6938d4e747002e3d150d231 Issue introduced in 5.16 with commit db1a8dd916aac986871f6b873a3aefad906f383a and fixed in 6.15.11 with commit 40deceb38f9db759772d1c289c28fd2a543f57fc Issue introduced in 5.16 with commit db1a8dd916aac986871f6b873a3aefad906f383a and fixed in 6.16.2 with commit 55c232d7e0241f1d5120b595e7a9de24c75ed3d8 Issue introduced in 5.16 with commit db1a8dd916aac986871f6b873a3aefad906f383a and fixed in 6.17-rc2 with commit 33927f3d0ecdcff06326d6e4edb6166aed42811c 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-2025-38722 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/accel/habanalabs/common/memory.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/c07886761fd6251db6938d4e747002e3d150d231 https://git.kernel.org/stable/c/40deceb38f9db759772d1c289c28fd2a543f57fc https://git.kernel.org/stable/c/55c232d7e0241f1d5120b595e7a9de24c75ed3d8 https://git.kernel.org/stable/c/33927f3d0ecdcff06326d6e4edb6166aed42811c