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 219E12749F2 for ; Wed, 1 Oct 2025 07:47:27 +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=1759304848; cv=none; b=GJEbKgFG3o43g6MGebBvuskmhzV+7egYQk3p/mER7Bs7/d4ENOJ/j5qXhxjCRN2hSxMZPLho4CI0mAtamPpqhPpJeC853bbmtyKyTjex667F9gnkz2MLUAfE5AfjhIlCLGFKiMeP0uJubJPmb5o+75O0MMlcVtiAnTXsPWRyv+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759304848; c=relaxed/simple; bh=+TF7imgS2gyy9q+QHWbPJVl9Q49G4s6FKYq8iA0MHNY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CMSlEWe+wiE5NkH2gqEboo0NZMKXgk9bVJs2gZ7qObvN34J36YA4+pwJ6cqfCrE+BsmEVvRK77CGOVfcuGEn3W9LStu47L6oBxrrmWc5bbl743wQws7p3uLmHobdHvX5cKLrGRV0+XSxeUcDHiHfR0EVjktKr8ZNiyRytDfq/eM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dLMcs56c; 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="dLMcs56c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3659AC4CEF4; Wed, 1 Oct 2025 07:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759304847; bh=+TF7imgS2gyy9q+QHWbPJVl9Q49G4s6FKYq8iA0MHNY=; h=From:To:Cc:Subject:Date:Reply-to:From; b=dLMcs56cJKiK8sPSXhNsDC0yjnhjVCRT1OPYgmo2qxGZ7B4hdL+tU83X1KeoBdwfj Xw4Y3qNoa9P+LBGPNBSYKyA4T/jkbu3q9Cy9Hr1BTXxNXNVi3vLYJAs07Iiq+veNEX rjMQtugHCEVQV7c2Aua0/Oxf+TIugxf2GauvmSRs= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-39915: net: phy: transfer phy_config_inband() locking responsibility to phylink Date: Wed, 1 Oct 2025 09:47:20 +0200 Message-ID: <2025100111-CVE-2025-39915-7a9f@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=6321; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Vkwmw88/vcuGcX1HAVNqHV/XgEcA3SVax9EUYa6SDeE=; b=owGbwMvMwCRo6H6F97bub03G02pJDBl37tQ/vSN3Q2WP9d+uve8uGi3bseTmuZ+Prs7hW9nml bfmdK5kaUcsC4MgE4OsmCLLl208R/dXHFL0MrQ9DTOHlQlkCAMXpwBMJJ2XYX5t2/SFaofCNFfX b/9Y2+d9Qm5xqDTD/NLdZ146diS+Lryn4jLvk+nR3XdDXwEA 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: net: phy: transfer phy_config_inband() locking responsibility to phylink Problem description =================== Lockdep reports a possible circular locking dependency (AB/BA) between &pl->state_mutex and &phy->lock, as follows. phylink_resolve() // acquires &pl->state_mutex -> phylink_major_config() -> phy_config_inband() // acquires &pl->phydev->lock whereas all the other call sites where &pl->state_mutex and &pl->phydev->lock have the locking scheme reversed. Everywhere else, &pl->phydev->lock is acquired at the top level, and &pl->state_mutex at the lower level. A clear example is phylink_bringup_phy(). The outlier is the newly introduced phy_config_inband() and the existing lock order is the correct one. To understand why it cannot be the other way around, it is sufficient to consider phylink_phy_change(), phylink's callback from the PHY device's phy->phy_link_change() virtual method, invoked by the PHY state machine. phy_link_up() and phy_link_down(), the (indirect) callers of phylink_phy_change(), are called with &phydev->lock acquired. Then phylink_phy_change() acquires its own &pl->state_mutex, to serialize changes made to its pl->phy_state and pl->link_config. So all other instances of &pl->state_mutex and &phydev->lock must be consistent with this order. Problem impact ============== I think the kernel runs a serious deadlock risk if an existing phylink_resolve() thread, which results in a phy_config_inband() call, is concurrent with a phy_link_up() or phy_link_down() call, which will deadlock on &pl->state_mutex in phylink_phy_change(). Practically speaking, the impact may be limited by the slow speed of the medium auto-negotiation protocol, which makes it unlikely for the current state to still be unresolved when a new one is detected, but I think the problem is there. Nonetheless, the problem was discovered using lockdep. Proposed solution ================= Practically speaking, the phy_config_inband() requirement of having phydev->lock acquired must transfer to the caller (phylink is the only caller). There, it must bubble up until immediately before &pl->state_mutex is acquired, for the cases where that takes place. Solution details, considerations, notes ======================================= This is the phy_config_inband() call graph: sfp_upstream_ops :: connect_phy() | v phylink_sfp_connect_phy() | v phylink_sfp_config_phy() | | sfp_upstream_ops :: module_insert() | | | v | phylink_sfp_module_insert() | | | | sfp_upstream_ops :: module_start() | | | | | v | | phylink_sfp_module_start() | | | | v v | phylink_sfp_config_optical() phylink_start() | | | phylink_resume() v v | | phylink_sfp_set_config() | | | v v v phylink_mac_initial_config() | phylink_resolve() | | phylink_ethtool_ksettings_set() v v v phylink_major_config() | v phy_config_inband() phylink_major_config() caller #1, phylink_mac_initial_config(), does not acquire &pl->state_mutex nor do its callers. It must acquire &pl->phydev->lock prior to calling phylink_major_config(). phylink_major_config() caller #2, phylink_resolve() acquires &pl->state_mutex, thus also needs to acquire &pl->phydev->lock. phylink_major_config() caller #3, phylink_ethtool_ksettings_set(), is completely uninteresting, because it only calls phylink_major_config() if pl->phydev is NULL (otherwise it calls phy_ethtool_ksettings_set()). We need to change nothing there. Other solutions =============== The lock inversion between &pl->state_mutex and &pl->phydev->lock has occurred at least once before, as seen in commit c718af2d00a3 ("net: phylink: fix ethtool -A with attached PHYs"). The solution there was to simply not call phy_set_asym_pause() under the &pl->state_mutex. That cannot be extended to our case though, where the phy_config_inband() call is much deeper inside the &pl->state_mutex section. The Linux kernel CVE team has assigned CVE-2025-39915 to this issue. Affected and fixed versions =========================== Issue introduced in 6.14 with commit 5fd0f1a02e750e2db4038dee60edea669ce5aab1 and fixed in 6.16.8 with commit 052ac41c379c8b87629808be612a482b2d0ae283 Issue introduced in 6.14 with commit 5fd0f1a02e750e2db4038dee60edea669ce5aab1 and fixed in 6.17 with commit e2a10daba84968f6b5777d150985fd7d6abc9c84 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-39915 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/phy/phy.c drivers/net/phy/phylink.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/052ac41c379c8b87629808be612a482b2d0ae283 https://git.kernel.org/stable/c/e2a10daba84968f6b5777d150985fd7d6abc9c84