[PATCH net-next v2 6/7] mpls: Fix load tearing with u64_stats

David Yang posted 7 patches 2 weeks ago
[PATCH net-next v2 6/7] mpls: Fix load tearing with u64_stats
Posted by David Yang 2 weeks ago
On 64bit arches, struct u64_stats_sync is empty and provides no help
against load/store tearing. struct copying should not be considered
tear-free. Use u64_stats_reads() instead.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 net/mpls/af_mpls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 580aac112dd2..bd2e02b89d09 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1097,7 +1097,7 @@ static void mpls_get_stats(struct mpls_dev *mdev,
 		p = per_cpu_ptr(mdev->stats, i);
 		do {
 			start = u64_stats_fetch_begin(&p->syncp);
-			local = p->stats;
+			u64_stats_reads(&local, &p->stats, sizeof(local));
 		} while (u64_stats_fetch_retry(&p->syncp, start));
 
 		stats->rx_packets	+= local.rx_packets;
-- 
2.51.0