From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410191; b=z8a4BMZ6HI4F68GvqK6LffSTC/sMOvizP35XDN+jVZrgZ9ipkOKWocOlAN3ZDJUrRbVS u8P7Z/puHsQVqqwuwqQVWxNuLLStCqXWjgGxZhg/f7ejh4o7NVTWj5quPmYLZNY/AKxSu vXZUxLZjewAQjMXs6WPZwFmkLEZMkGMou5GDtTNI0e39ys1Hiruz7EJmxy0oefojDpYby V2HOS3WyG71YvPvWAH1eFmU5YiVsjrVtP2LGDU3IPU/3EQG05hdskRBFEugkc7G0qp33w ZfpsVDGKyAquKGZIxtkv7Sq9gFzHOy6RwJR3aX9Hz0Z1OdUE5KNKpJzGCYaHcCkOpDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410191; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=jbpkT2DME7pJRvLdnsaQg9oX/+NyPZ+MCkYdeUxNjW4=; b=VR2/PmaxJaUAole4tSePmNpW7lMUC5nCN1D9YCn1O1Lnki8MXq1uBk6+RsJvBNw82kye ttdrljq122KPVOPrO8jftvDDMg0npR7S649b26zL4DbwhnXr/qJA1SD721gSa/pfWIiGs yJLZxvr7jc3wJ82ahxSlMCP8Mcqn+WU06f6puDblTjPDczCtOquGuib1IOyBIuLV9jeR6 7TU8VgjdfjovsQn4EoE4h4DvHMGcpgUhZz7/XMqKOcGiewGooS3b9pnxWrwvrXn7IDMr5 gpha0QsXycp2In9iQxFJyMd1TXysogsVC2W0G07laGi+bCuNMv2NOpbcUjzYECqbrNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0JLquSWn; arc=none smtp.remote-ip=74.125.82.176 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E9D1606A32C for ; Fri, 4 Dec 2026 18:49:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4E9D1606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0JLquSWn Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-3866a784546so1819213eec.0 for ; Fri, 04 Dec 2026 10:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796410190; x=1797014990; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=jbpkT2DME7pJRvLdnsaQg9oX/+NyPZ+MCkYdeUxNjW4=; b=0JLquSWnZADYjNaFH/IttNSFB6Hm9jXMtSbUPK9BjyqKMVWyUKwzkLogKMEWuXrrWH 81VQWfgZOXFPrGTs6Ej4jEzArL6CymTqPdo9zD1kvs6uJaXfjkomImmeZ5IoN5Rs7bpZ R/Jl8TvAG1BhEuqvkt2qfsiIYPrkEfEXweUffFc1gs+53pAtdojnR4SWgu0Ha31Ph9v0 PmD0wcZA1QYbHFIQW2NOuyLAPHtVwgJd3m02ZQYcIjlabZcyy2qYHGtzyIlX+ev/608o SWmfrlICGYVUGBsFdeShtSwK4ECz9vyO/ZCqUUVE5KVpOgvKp1qkZsC8sZmvp6XLYkIU t9yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796410190; x=1797014990; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jbpkT2DME7pJRvLdnsaQg9oX/+NyPZ+MCkYdeUxNjW4=; b=Yk2AgyaBRpJ114WIXOFPDKLocTL7pPjJJe5NP/CZ4Mu8E06MzGqVnvtMpooGlZwEJg 9i3XNxhi0lUius7xWl8frVxEj0ZG7zTbt75JTNuPggSihucm+tCt0Qvqi9/ScZugQ/bl FvHxyrEY5f+4EVmxzrMhF9y/HBk7mn8fhPCNEMQAaM4+z1NNz+tn8ZsrBZ/phiwTmDoc o1ynCdsV68WDF4SaHoGR74+l4O/7c9pjekRfhSo9lgu16KEStOtHjkwoyvGL4doWW4z6 s8PNjfY2hRBKX5X3bmzKyxkYO+yp5Xy701dXA3GtjKoZzBcdqxIr+3YMRRLI7tJP4DwK DBWw== X-Forwarded-Encrypted: i=1; AL+hErHaqZoQKuZ+MW7udt+Kl5kyd9WPg9NoWF+jM+Q5my0alS0fSYIR0tYq/csRmp5yAgJbd5XNI6s=@vger.kernel.org X-Gm-Message-State: AB4q+uH4J9a6i60gNm6k3rR1qL+T1+i4xXFWxwJeO2Pr75E3ynmOm5dX gGsOzebc5O3fCCtHZh5aU+IEyhpII7E/DYh4q+9TXgSqRN2w7J5h18Lb X-Gm-Gg: AZFdTZcylnTOGR3U1FK0Kva/j7CwO8OrJWcnmP80fBqA555IGYeXsY4iJApLQk1hOV7 2YPZqu67Uf+uyH7bgPWE3ZV3w9l7n8iZ0zqAfyS6vMZP7SNy8Y3WKzXme/dN2k+86ZhBcyvwjfj FRDBROqy3q8FnMRIQL76bYNlia8HOTMdkixbvpXbm69hyL7jErC3OSe+f3QpK/CKpgvOQJ25GI2 9F0XzZoJEP+/FZQRjOwwzqsNIGVQ3x1uWavsX41sfylQqlMfN1L3QvYgDqqUF9+J2NtRVh705Tf shv/wiBumyMkp26kZz2/hycaugVNZKtPfWl9OU839ZpTtvi+OMeNG9pb5ySuVn5LGWScq7rtynk ljl6bDH3DuSRjzSk+bOu8PYjiACOSMMjplgTev27Awe4xa6dJZHw/p74b6jiXEPAnhPOsIofIMD ICZ0ucX3yoNCBWXqU7wg65utGS282ORQ4ZmjxnqS2BOsP5j0qe90o15xLxp3GXzuiPPzXj+y2AX rshnxd+0F/6IDQqIuR3rTC+1XhYKakW4BTf59EOTT3chOmIlqnKBF66ab0IG2lthWAnhOJl0Dag YJR8rn18z196hOLhodYCSs/oishmlB7P76l1V0nYz6q9x4mfZEoClJtFEEzDYUmjQBcQtgzD3Br 33+/DZxSQKlp0 X-Received: by 2002:a05:7300:cf0f:b0:387:4e5c:397d with SMTP id 5a478bee46e88-387520afa0emr2718310eec.11.1796410190387; Fri, 04 Dec 2026 10:49:50 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218c6a6sm10321963eec.5.2026.12.04.10.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 10:49:50 -0800 (PST) From: Praneeth Balasubramanian To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Frank , Jijie Shao , Chukun Pan , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Praneeth Balasubramanian , stable@vger.kernel.org Subject: [PATCH net] net: phy: motorcomm: Take the MDIO bus lock in the YT8521 LED callbacks Date: Fri, 4 Dec 2026 10:49:45 -0800 Message-Id: <20261204184945.1687040-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ytphy_read_ext() and ytphy_write_ext() access an extended register by writing its number to YTPHY_PAGE_SELECT and then reading or writing YTPHY_PAGE_DATA. Their comments say that the caller must hold the MDIO bus lock, so that no other access to the PHY lands between the two steps. yt8521_led_hw_control_set() and yt8521_led_hw_control_get() call them without it: phy_led_hw_control_set() and phy_led_hw_control_get() only hold phydev->lock. Another user of the bus, for example a WoL query through ytphy_read_ext_with_lock() or a register access from the MAC driver, can then change the selected extended register in between. The LED configuration is then written to a different register, or read from one. Use ytphy_read_ext_with_lock() and ytphy_write_ext_with_lock(), as the rest of the driver does outside locked sections. This was discovered by a static analysis tool: Clang context analysis checking the locking rule in the comments of ytphy_read_ext() and ytphy_write_ext() (an LLM was used to turn the comments into rules). The netdev AI review later pointed out the same problem as pre-existing on the YT8521 led_brightness_set series. The issue was not triggered, and the fix was only build-tested. Fixes: 355b82c54c12 ("net: phy: motorcomm: Add support for PHY LEDs on YT8521") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested; I do not have this hardware, and I have not observed the race myself. drivers/net/phy/motorcomm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index a87e83fdf590..b109b160d681 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -1836,7 +1836,8 @@ static int yt8521_led_hw_control_set(struct phy_device *phydev, u8 index, if (test_bit(TRIGGER_NETDEV_RX, &rules)) val |= YT8521_LED_RXACT_BLK_EN; - return ytphy_write_ext(phydev, YT8521_LED0_CFG_REG + index, val); + return ytphy_write_ext_with_lock(phydev, YT8521_LED0_CFG_REG + index, + val); } static int yt8521_led_hw_control_get(struct phy_device *phydev, u8 index, @@ -1847,7 +1848,7 @@ static int yt8521_led_hw_control_get(struct phy_device *phydev, u8 index, if (index >= YT8521_MAX_LEDS) return -EINVAL; - val = ytphy_read_ext(phydev, YT8521_LED0_CFG_REG + index); + val = ytphy_read_ext_with_lock(phydev, YT8521_LED0_CFG_REG + index); if (val < 0) return val; -- 2.25.1