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: <20241203102913.GD9361@kernel.org>
Date: Tue, 3 Dec 2024 10:29:13 +0000
From: Simon Horman <horms@...nel.org>
To: Kory Maincent <kory.maincent@...tlin.com>
Cc: Andrew Lunn <andrew@...n.ch>, Oleksij Rempel <o.rempel@...gutronix.de>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Jonathan Corbet <corbet@....net>,
	Donald Hunter <donald.hunter@...il.com>,
	Rob Herring <robh@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Russell King <linux@...linux.org.uk>,
	Liam Girdwood <lgirdwood@...il.com>,
	Mark Brown <broonie@...nel.org>,
	Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	linux-doc@...r.kernel.org, Kyle Swenson <kyle.swenson@....tech>,
	Dent Project <dentproject@...uxfoundation.org>,
	kernel@...gutronix.de,
	Maxime Chevallier <maxime.chevallier@...tlin.com>
Subject: Re: [PATCH RFC net-next v3 26/27] net: pse-pd: tps23881: Add support
 for static port priority feature

On Thu, Nov 21, 2024 at 03:42:52PM +0100, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
> 
> This patch enhances PSE callbacks by introducing support for the static
> port priority feature. It extends interrupt management to handle and report
> detection, classification, and disconnection events. Additionally, it
> introduces the pi_get_pw_req() callback, which provides information about
> the power requested by the Powered Devices.
> 
> Interrupt support is essential for the proper functioning of the TPS23881
> controller. Without it, after a power-on (PWON), the controller will
> no longer perform detection and classification. This could lead to
> potential hazards, such as connecting a non-PoE device after a PoE device,
> which might result in magic smoke.
> 
> Signed-off-by: Kory Maincent <kory.maincent@...tlin.com>
> ---
> 
> We may need a fix for the interrupt support in old version of Linux.
> 
> Change in v3:
> - New patch
> ---
>  drivers/net/pse-pd/tps23881.c | 197 ++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 188 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c

...

> +static int tps23881_irq_event_detection(struct tps23881_priv *priv,
> +					u16 reg_val,
> +					unsigned long *notifs,
> +					unsigned long *notifs_mask)
> +{
> +	enum ethtool_pse_events event;
> +	int reg, ret, i, val;
> +	u8 chans;
> +
> +	chans = tps23881_it_export_chans_helper(reg_val, 0);
> +	for_each_set_bit(i, (unsigned long *)&chans, TPS23881_MAX_CHANS) {

Hi Kory,

The storage size of chans is only 1 byte, but here we are pretending that
it has more space. Which seems to be a bit of a stretch. Perhaps it would
be better to simply use unsigned long as the type of chans here and in
tps23881_irq_event_classification().

W=1 build with gcc-14 on x86_64 complains about this line as follows:

In function 'find_next_bit',
    inlined from 'tps23881_irq_event_detection' at drivers/net/pse-pd/tps23881.c:1281:2,
    inlined from 'tps23881_irq_event_handler' at drivers/net/pse-pd/tps23881.c:1363:9,
    inlined from 'tps23881_irq_handler' at drivers/net/pse-pd/tps23881.c:1400:9:
./include/linux/find.h:65:23: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u8[1]' {aka 'unsigned char[1]'} [-Warray-bounds=]
   65 |                 val = *addr & GENMASK(size - 1, offset);
      |                       ^~~~~
drivers/net/pse-pd/tps23881.c: In function 'tps23881_irq_handler':
drivers/net/pse-pd/tps23881.c:1278:12: note: object 'chans' of size 1
 1278 |         u8 chans;
      |            ^~~~~

> +		reg = TPS23881_REG_DISC + (i % 4);
> +		ret = i2c_smbus_read_word_data(priv->client, reg);
> +		if (ret < 0)
> +			return ret;
> +
> +		val = tps23881_calc_val(ret, i, 0, 0xf);
> +		/* If detection valid */
> +		if (val == 0x4)
> +			event = ETHTOOL_C33_PSE_EVENT_DETECTION;
> +		else
> +			event = ETHTOOL_C33_PSE_EVENT_DISCONNECTION;
> +
> +		tps23881_set_notifs_helper(priv, BIT(i), notifs,
> +					   notifs_mask, event);
> +	}
> +
> +	return 0;
> +}

...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ