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] [day] [month] [year] [list]
Message-ID: <20260109035904.2904127-1-kuba@kernel.org>
Date: Thu,  8 Jan 2026 19:59:04 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: mmyangfl@...il.com
Cc: Jakub Kicinski <kuba@...nel.org>,
	linux-kernel@...r.kernel.org,
	netdev@...r.kernel.org,
	davem@...emloft.net,
	andrew@...n.ch,
	edumazet@...gle.com,
	pabeni@...hat.com,
	david.laight.linux@...il.com,
	olteanv@...il.com,
	dan.carpenter@...aro.org
Subject: Re: [net-next,v4,2/2] net: dsa: yt921x: Use u64_stats_t for MIB stats

This is an AI-generated review of your patch.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: dsa: yt921x: Use u64_stats_t for MIB stats

This patch converts the MIB statistics from plain u64 to u64_stats_t and
adds a u64_stats_sync seqcount to provide atomicity on 32-bit architectures
while remaining lock-free on 64-bit architectures.

> diff --git a/drivers/net/dsa/yt921x.h b/drivers/net/dsa/yt921x.h
> index 61bb0ab3b09a..17fee83952c2 100644
> --- a/drivers/net/dsa/yt921x.h
> +++ b/drivers/net/dsa/yt921x.h

[ ... ]

> @@ -533,9 +535,13 @@ struct yt921x_port {
>  	bool isolated;
>
>  	struct delayed_work mib_read;
> +	struct u64_stats_sync syncp;
>  	struct yt921x_mib mib;
> -	u64 rx_frames;
> -	u64 tx_frames;
> +	u64_stats_t rx_frames;
> +	u64_stats_t tx_frames;
> +
> +	/* only used by read routine to avoid huge allocations on the stack */
> +	struct yt921x_mib mib_new;
>  };

The new syncp field requires u64_stats_init() to be called before use.
Looking at yt921x_mdio_probe(), the port initialization loop only sets
pp->index and calls INIT_DELAYED_WORK() but does not call
u64_stats_init(&pp->syncp).

On 32-bit architectures, u64_stats_init() calls seqcount_init() which
initializes the lockdep tracking. Without this initialization, builds
with CONFIG_DEBUG_LOCK_ALLOC may have lockdep issues.

For reference, the xrs700x DSA driver does this correctly in
xrs700x_alloc_port_mib():

    mutex_init(&p->mib_mutex);
    u64_stats_init(&p->syncp);

Should u64_stats_init(&pp->syncp) be added to the port initialization
loop in yt921x_mdio_probe()?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ