lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c30a0242-9c68-4930-a752-80fb4ad499d9@solid-run.com>
Date: Tue, 7 May 2024 12:03:31 +0000
From: Josua Mayer <josua@...id-run.com>
To: Florian Fainelli <f.fainelli@...il.com>, Andrew Lunn <andrew@...n.ch>,
	Vladimir Oltean <olteanv@...il.com>, "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo
 Abeni <pabeni@...hat.com>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Mor Nagli
	<mor.nagli@...id-run.com>
Subject: Re: [PATCH net-next v3] net: dsa: mv88e6xxx: control mdio bus-id
 truncation for long paths

Am 05.05.24 um 21:11 schrieb Florian Fainelli:
> Le 5 mai 2024 02:52:45 GMT-07:00, Josua Mayer <josua@...id-run.com> a écrit :
>> mv88e6xxx supports multiple mdio buses as children, e.g. to model both
>> internal and external phys. If the child buses mdio ids are truncated,
>> they might collide with each other leading to an obscure error from
>> kobject_add.
>>
>> The maximum length of bus id is currently defined as 61
>> (MII_BUS_ID_SIZE). Truncation can occur on platforms with long node
>> names and multiple levels before the parent bus on which the dsa switch
>> itself sits, e.g. CN9130 [1].
>>
>> Compare the return value of snprintf against maximum bus-id length to
>> detect truncation. In that case write an incrementing marker to the end
>> to avoid name collisions.
>> This changes the problematic bus-ids mdio and mdio-external from [1]
>> to [2].
>>
>> Truncation at the beginning was considered as a workaround, however that
>> is still subject to name collisions in sysfs where only the first
>> characters differ.
>>
>> [1]
>> [    8.324631] mv88e6085 f212a200.mdio-mii:04: switch 0x1760 detected: Marvell 88E6176, revision 1
>> [    8.389516] mv88e6085 f212a200.mdio-mii:04: Truncated bus-id may collide.
>> [    8.592367] mv88e6085 f212a200.mdio-mii:04: Truncated bus-id may collide.
>> [    8.623593] sysfs: cannot create duplicate filename '/devices/platform/cp0/cp0:config-space@...00000/f212a200.mdio/mdio_bus/f212a200.mdio-mii/f212a200.mdio-mii:04/mdio_bus/!cp0!config-space@...00000!mdio@...200!ethernet-switch@...di'
>> [    8.785480] kobject: kobject_add_internal failed for !cp0!config-space@...00000!mdio@...200!ethernet-switch@...di with -EEXIST, don't try to register things with the same name in the same directory.
>> [    8.936514] libphy: mii_bus /cp0/config-space@...00000/mdio@...200/ethernet-switch@...di failed to register
>> [    8.946300] mdio_bus !cp0!config-space@...00000!mdio@...200!ethernet-switch@...di: __mdiobus_register: -22
>> [    8.956003] mv88e6085 f212a200.mdio-mii:04: Cannot register MDIO bus (-22)
>> [    8.965329] mv88e6085: probe of f212a200.mdio-mii:04 failed with error -22
>>
>> [2]
>> /devices/platform/cp0/cp0:config-space@...00000/f212a200.mdio/mdio_bus/f212a200.mdio-mii/f212a200.mdio-mii:04/mdio_bus/!cp0!config-space@...00000!mdio@...200!ethernet-switch...!-0
>> /devices/platform/cp0/cp0:config-space@...00000/f212a200.mdio/mdio_bus/f212a200.mdio-mii/f212a200.mdio-mii:04/mdio_bus/!cp0!config-space@...00000!mdio@...200!ethernet-switch...!-1
>>
>> Signed-off-by: Josua Mayer <josua@...id-run.com>
>> ---
> The idea and implementation is reasonable but this could affect other drivers than mv88e6xxx, why not move that logic to mdiobus_register() and tracking the truncation index globally within the MDIO bus layer?
Conceptually I agree, it would be nice to have a centralized
solution to this problem, it probably can occur in multiple places.

My reasoning is that solving the problem within a single driver
is a much smaller task, especially for sporadic contributors
who lack a deep understanding for how all layers interact.

Perhaps agreeing on a good solution within this driver
can inform a more general solution to be added later.

> If we prefer a driver based solution, the mii_bus object could carry a truncation format, at the risk of creating more variation between drivers in case of truncation. We could also wait until we have another driver requiring a similar solution before promoting this to a wider range.


br
Josua Mayer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ