]> git.ipfire.org Git - thirdparty/linux.git/commit
gve: Fix race condition on tx->dropped_pkt update
authorMax Yuan <maxyuan@google.com>
Thu, 27 Nov 2025 00:07:51 +0000 (00:07 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 28 Nov 2025 01:44:52 +0000 (17:44 -0800)
commit858b1d07e49106a302cc7c7fbeee4fb2698573c9
treef6ced59e75aa7a0866b45bcf399f92ac3bdbd702
parent4c03592689bc19df9deda7a33d56c6ac0cec8651
gve: Fix race condition on tx->dropped_pkt update

The tx->dropped_pkt counter is a 64-bit integer that is incremented
directly. On 32-bit architectures, this operation is not atomic and
can lead to read/write tearing if a reader accesses the counter during
the update. This can result in incorrect values being reported for
dropped packets.

To prevent this potential data corruption, wrap the increment
operation with u64_stats_update_begin() and u64_stats_update_end().
This ensures that updates to the 64-bit counter are atomic, even on
32-bit systems, by using a sequence lock.

The u64_stats_sync API requires the writer to have exclusive access,
which is already provided in this context by the network stack's
serialization of the transmit path (net_device_ops::ndo_start_xmit
[1]) for a given queue.

[1]: https://www.kernel.org/doc/Documentation/networking/netdevices.txt

Signed-off-by: Max Yuan <maxyuan@google.com>
Reviewed-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/google/gve/gve_tx.c
drivers/net/ethernet/google/gve/gve_tx_dqo.c