From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410191; b=T7JB3W0lQ/sZhwO8ZiqPXvrwSi7yaYQ6CgwB3uyaDwllZvn4r6HMXcxVlWUcIwUaPw2Y QklniKL+q9Zi7CS6UgEViQk+YsuQeIy7YerhrKzph3sam667VCWKtF6feqjZ7v6oYmOj2 v6NWdsf5LXhYh3k0qC0fCWYxJ6CWu0fdX/PIkQ4yLxWMt+zshUpT+EGixp5ad8Mv1lo8U bt9pgTdcycqg7HoCJDwqmTxnI0R4dVQxmM2n/laikZxtXMCsYLhVfcTkwmXOInIvuTSCh +m0bImTEQ4Be0HC2WhwnuOgZZc+qZ3z29Dgf8iLyIcPVVAJTqXpc2nUWSvRdp8CUaoQ== 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=5UXONRwhPOo1gGon9b9lSK6cBgYdQGcdUyap9O4j6q5LGMZHUMSHFMT0L6E7iSAcLJ4P v4v9FWi2APwUT/1qgMUGz+9DkX2gybPBjYCrvlwHCMXTiMorhnHHR6G6oiJjp6+VEMuIs aH3qcrUnbth08rIiDyHZPacF7vUuNd5mdJs3hkZkkegCd2NeIYQFHR60C4T6n/f0bIWBn ZWiY+3PxzwOisjEOvITwYFFz5Ig2rKTPUNZwTvxKZ7HYVNZXmMz9hL0yQ4dExinnlr0Yn FafiE8r6IqYnVcVXmZ3SQhWo8qIKwiiX2N55eQf4f6JHVpb7vxSD30lS+mR8DEV6TRg== 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.169 Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169]) (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 5A5B9606A32D for ; Fri, 4 Dec 2026 18:49:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5A5B9606A32D 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-f169.google.com with SMTP id 5a478bee46e88-386ab9ab619so2070246eec.1 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=TPuyvWGYumHqfGg2UKJdGqfG/nfNXhgSZr7fyI+JPW+UGcRmr/djtR+w/AGIF3oxP9 c8+kor1d2NUFcJA6cs9XUw1mycwyLpFr3gFp5j4WcJBkYWOy1xmKSYkOgB+XxTGVm0G2 /SKvzQV/PG90mzD2hxaHq5mX+beXZAfAVJk63E8YXW0680WEv9PGVwBgDj2B3Rd64TRf 0qIb85LU4hulevAow8/DyiH4AffTcBOluZMGur7Z/QJ6rWl5k0ZajJpZrO5LPFyDnMjN TiQ/QekZ5c88KZsx0Q3TnHPPocUwYfjDtVkV+lvHG56R/1kRO0S8ArJR5NJg+2DtOKWG maSQ== X-Forwarded-Encrypted: i=1; AL+hErFxbIZosHBGDkSceuqBVeFDP63PZwPu+crfZMMMN2obOwIMEg1MAmeI+6hKs5NQjzMJmdgaFLtybf3lCmE=@vger.kernel.org X-Gm-Message-State: AB4q+uHd4NHeuBrfxX83wGUx81QjoezfGLv6Mfjdao3D98ki3vjH3UPX Zj5qdApPjs8/YC+5cTWXFwxOxVXjmAVC0bW328P8Lcp+7vqi2dugeCFg X-Gm-Gg: AZFdTZcBdDH1wCYf+vGDF2HxD8qcNPDzlNdbF9qSUoZlSMCf+MJ2iG8kzhaW9lOrWdN /ab/hSHOyviGuqA8TT282I0RO7RYHjCXI5tEf74nSxHNsRRLTsB6SBsHpCZb/zQnQmursJZxYYg S2r8ozWwIzqtur5YtdIhu2C2B9Q2a+vGyaijfWRa8WAaVaSvC6Bs+QEFsDyBI75D6FfvVWt1QcJ DMYORYxL2RtzOtLF9rzI5L5zSGjQpHO/FfU3RqIzKaTB9T03WltR483Q7aIEtBMoSlNGGu4W9ne 3G7NZEF9vUHnDV2Z7AO0qRA/5DLfmqRVgR4GS8qTLR4n3BnY/76CI4dOL6fYus2QkyVp663dg1m 4XTdG7Iy4KmAJupwgwnX1yQ5Om5QJUvOBxwMN5Sj0DQ0HTmdJc9FvJRvo3Kwz2zpDMa+jDqedks yi+ll6kftz8wC+LAqhAdVs6s/KVfPad9QVGQZBU1IwLSzcptpdTXCZ5uolEQSjBlD1R+tA73yeX s84zra/QHlYwYBMt5Od/B05JwT0xB+4ht+tn7B5udTcyXfIQ0yEJLxm/oiw9cIoDxBvwXz9Cjn3 8rcXjy1uV2WiH9s3I4xbjSpDvMUFsPvv9rkqMRehDGYUf5uSHX5rleM3XROtbGuhgDCGen9ltwI N8miAsGD5APL8 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: linux-kernel@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