From: David Yang <mmyangfl@gmail.com>
To: netdev@vger.kernel.org
Cc: David Yang <mmyangfl@gmail.com>,
Sabrina Dubroca <sd@queasysnail.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next v2 5/7] macsec: fix memcpy with u64_stats
Date: Sat, 24 Jan 2026 00:21:37 +0800 [thread overview]
Message-ID: <20260123162159.2877941-6-mmyangfl@gmail.com> (raw)
In-Reply-To: <20260123162159.2877941-1-mmyangfl@gmail.com>
On 64bit arches, struct u64_stats_sync is empty and provides no help
against load/store tearing. memcpy() should not be considered tear-free.
Use u64_stats_reads() instead.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/macsec.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 5200fd5a10e5..533a64713ea7 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2806,7 +2806,7 @@ static void get_rx_sc_stats(struct net_device *dev,
stats = per_cpu_ptr(rx_sc->stats, cpu);
do {
start = u64_stats_fetch_begin(&stats->syncp);
- memcpy(&tmp, &stats->stats, sizeof(tmp));
+ u64_stats_reads(&tmp, &stats->stats, sizeof(tmp));
} while (u64_stats_fetch_retry(&stats->syncp, start));
sum->InOctetsValidated += tmp.InOctetsValidated;
@@ -2887,7 +2887,7 @@ static void get_tx_sc_stats(struct net_device *dev,
stats = per_cpu_ptr(macsec_priv(dev)->secy.tx_sc.stats, cpu);
do {
start = u64_stats_fetch_begin(&stats->syncp);
- memcpy(&tmp, &stats->stats, sizeof(tmp));
+ u64_stats_reads(&tmp, &stats->stats, sizeof(tmp));
} while (u64_stats_fetch_retry(&stats->syncp, start));
sum->OutPktsProtected += tmp.OutPktsProtected;
@@ -2943,7 +2943,7 @@ static void get_secy_stats(struct net_device *dev, struct macsec_dev_stats *sum)
stats = per_cpu_ptr(macsec_priv(dev)->stats, cpu);
do {
start = u64_stats_fetch_begin(&stats->syncp);
- memcpy(&tmp, &stats->stats, sizeof(tmp));
+ u64_stats_reads(&tmp, &stats->stats, sizeof(tmp));
} while (u64_stats_fetch_retry(&stats->syncp, start));
sum->OutPktsUntagged += tmp.OutPktsUntagged;
--
2.51.0
next prev parent reply other threads:[~2026-01-23 16:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 16:21 [PATCH net-next v2 0/7] u64_stats: Introduce u64_stats_reads() David Yang
2026-01-23 16:21 ` [PATCH net-next v2 1/7] " David Yang
2026-01-23 16:21 ` [PATCH net-next v2 2/7] u64_stats: Doc incorrect usage with plain variables David Yang
2026-01-23 16:21 ` [PATCH net-next v2 3/7] net: bridge: mcast: fix memcpy with u64_stats David Yang
2026-01-23 16:21 ` [PATCH net-next v2 4/7] net: openvswitch: fix load tearing " David Yang
2026-01-24 0:49 ` kernel test robot
2026-01-26 12:25 ` Ilya Maximets
2026-01-26 18:29 ` David Laight
2026-01-26 18:35 ` Eric Dumazet
2026-01-26 19:18 ` David Laight
2026-01-23 16:21 ` David Yang [this message]
2026-01-23 16:21 ` [PATCH net-next v2 6/7] mpls: Fix " David Yang
2026-01-23 16:21 ` [PATCH net-next v2 7/7] vxlan: vnifilter: fix memcpy " David Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260123162159.2877941-6-mmyangfl@gmail.com \
--to=mmyangfl@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox