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 E3C865B68B for ; Wed, 6 Mar 2024 06:46:41 +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=1709707602; cv=none; b=uos+MK3cfaJAot5PSeHa4CyoH4RH7mgaTFpvCrxvheYbsc3suUL16TdyU3r9UrvRVROFlNjJTklBA5TxTFvqioTSYudM97lDkAAsirUykf9WNYmOysU4TTYAugzijeJ5Y8y2KA14Y5zcvSQudGbsaK2b9acHRFK0FonEzUUNdLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709707602; c=relaxed/simple; bh=vYiT4ENDZ9LNLfggE+K3SSbt5v6NuQ7cfgnwdnnLy4I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=r4z1cP9uBQEdaAXjkkGuNPInbNvIQshhfZRFo9kSv6NHGI6UQ8NnmpcUS7o88C3vHe86ESTXSOsRof3QFHgaS0SJlC/mObzUeR3yeM4WFF5L/WbaP3TXyigGI60DatsxfNGhqaRdYpTx+AoSRX1lyH4ZEVmGXCrQhQuc/GOqhLo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RjbqMLXO; 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="RjbqMLXO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76857C433C7; Wed, 6 Mar 2024 06:46:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709707601; bh=vYiT4ENDZ9LNLfggE+K3SSbt5v6NuQ7cfgnwdnnLy4I=; h=From:To:Cc:Subject:Date:Reply-to:From; b=RjbqMLXObnbNz5W6oQNq/cQMWwlghIODnpD8IjKIGJ0802Cx1lxuv/z/Xpdcy77MQ O6P3aP+eUk8l+HfacdawAXo8ouEJhciwFlIxn5szoUvxkZqgE2tpltzqRreBH8R2+M F5EbsM3ZLThG2J6AvqGQeLhW8gfx55Kdn22UpFWE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26623: pds_core: Prevent race issues involving the adminq Date: Wed, 6 Mar 2024 06:46:06 +0000 Message-ID: <2024030648-CVE-2024-26623-ee77@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=3508; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=vYiT4ENDZ9LNLfggE+K3SSbt5v6NuQ7cfgnwdnnLy4I=; b=owGbwMvMwCRo6H6F97bub03G02pJDKkvBGW+7r151vH5l91xdbJpAa7hC2ulfxj1SC/qCJ9yT f7Bz47ujlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIhmcMCyZp7Dqqd2r5/v8R gYVvz9ZxNLZfY2WYK7bH/lZffGz95ZeSRb86rGb9jGfRAwA= 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: pds_core: Prevent race issues involving the adminq There are multiple paths that can result in using the pdsc's adminq. [1] pdsc_adminq_isr and the resulting work from queue_work(), i.e. pdsc_work_thread()->pdsc_process_adminq() [2] pdsc_adminq_post() When the device goes through reset via PCIe reset and/or a fw_down/fw_up cycle due to bad PCIe state or bad device state the adminq is destroyed and recreated. A NULL pointer dereference can happen if [1] or [2] happens after the adminq is already destroyed. In order to fix this, add some further state checks and implement reference counting for adminq uses. Reference counting was used because multiple threads can attempt to access the adminq at the same time via [1] or [2]. Additionally, multiple clients (i.e. pds-vfio-pci) can be using [2] at the same time. The adminq_refcnt is initialized to 1 when the adminq has been allocated and is ready to use. Users/clients of the adminq (i.e. [1] and [2]) will increment the refcnt when they are using the adminq. When the driver goes into a fw_down cycle it will set the PDSC_S_FW_DEAD bit and then wait for the adminq_refcnt to hit 1. Setting the PDSC_S_FW_DEAD before waiting will prevent any further adminq_refcnt increments. Waiting for the adminq_refcnt to hit 1 allows for any current users of the adminq to finish before the driver frees the adminq. Once the adminq_refcnt hits 1 the driver clears the refcnt to signify that the adminq is deleted and cannot be used. On the fw_up cycle the driver will once again initialize the adminq_refcnt to 1 allowing the adminq to be used again. The Linux kernel CVE team has assigned CVE-2024-26623 to this issue. Affected and fixed versions =========================== Issue introduced in 6.4 with commit 01ba61b55b20 and fixed in 6.6.16 with commit 22cd6046eb21 Issue introduced in 6.4 with commit 01ba61b55b20 and fixed in 6.7.4 with commit 5939feb63ea1 Issue introduced in 6.4 with commit 01ba61b55b20 and fixed in 6.8-rc3 with commit 7e82a8745b95 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-26623 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/net/ethernet/amd/pds_core/adminq.c drivers/net/ethernet/amd/pds_core/core.c drivers/net/ethernet/amd/pds_core/core.h 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/22cd6046eb2148b18990257505834dd45c672a1b https://git.kernel.org/stable/c/5939feb63ea1f011027576c64b68b681cbad31ca https://git.kernel.org/stable/c/7e82a8745b951b1e794cc780d46f3fbee5e93447