Skip to content

Commit d5a9314

Browse files
josh8551021mehmetb0
authored andcommitted
gve: guard XDP xmit NDO on existence of xdp queues
BugLink: https://bugs.launchpad.net/bugs/2097738 commit ff7c2de upstream. In GVE, dedicated XDP queues only exist when an XDP program is installed and the interface is up. As such, the NDO XDP XMIT callback should return early if either of these conditions are false. In the case of no loaded XDP program, priv->num_xdp_queues=0 which can cause a divide-by-zero error, and in the case of interface down, num_xdp_queues remains untouched to persist XDP queue count for the next interface up, but the TX pointer itself would be NULL. The XDP xmit callback also needs to synchronize with a device transitioning from open to close. This synchronization will happen via the GVE_PRIV_FLAGS_NAPI_ENABLED bit along with a synchronize_net() call, which waits for any RCU critical sections at call-time to complete. Fixes: 39a7f4a ("gve: Add XDP REDIRECT support for GQI-QPL format") Cc: [email protected] Signed-off-by: Joshua Washington <[email protected]> Signed-off-by: Praveen Kaligineedi <[email protected]> Reviewed-by: Praveen Kaligineedi <[email protected]> Reviewed-by: Shailend Chand <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> CVE-2024-57932 Signed-off-by: Koichiro Den <[email protected]>
1 parent 23f4381 commit d5a9314

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

drivers/net/ethernet/google/gve/gve_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,9 @@ static void gve_turndown(struct gve_priv *priv)
18891889

18901890
gve_clear_napi_enabled(priv);
18911891
gve_clear_report_stats(priv);
1892+
1893+
/* Make sure that all traffic is finished processing. */
1894+
synchronize_net();
18921895
}
18931896

18941897
static void gve_turnup(struct gve_priv *priv)

drivers/net/ethernet/google/gve/gve_tx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,12 @@ int gve_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
834834
struct gve_tx_ring *tx;
835835
int i, err = 0, qid;
836836

837-
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
837+
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK) || !priv->xdp_prog)
838838
return -EINVAL;
839839

840+
if (!gve_get_napi_enabled(priv))
841+
return -ENETDOWN;
842+
840843
qid = gve_xdp_tx_queue_id(priv,
841844
smp_processor_id() % priv->num_xdp_queues);
842845

0 commit comments

Comments
 (0)