Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Pin-yen Lin <treapking@google.com>
To: treapking@google.com
Cc: stable@vger.kernel.org
Subject: [PATCH net v3 5/5] gve: Fix UAF due to stats report race with teardown
Date: Tue, 13 Oct 2026 02:38:36 -0700	[thread overview]
Message-ID: <20261013093836.1269134-6-treapking@google.com> (raw)
In-Reply-To: <20261013093836.1269134-1-treapking@google.com>

While stats_report_timer is deleted during queue stop and teardown, the
corresponding stats_report_task work item is not explicitly cancelled.

This issue was identified by static analysis and code review via Sashiko
during review of earlier revisions. The race condition is purely
theoretical and was not observed triggering a crash in practice.

This leads to the following issues:
1. During queue stop: stats_report_task can still be pending after
   stats_report_timer is deleted and run after queues are stopped.
2. During teardown/reset/suspend: if stats_report_task was queued by
   the timer, freeing priv->stats_report in
   gve_free_stats_report() without cancelling the work item can cause a
   NULL pointer dereference or UAF on priv->stats_report when
   gve_stats_report_task() runs.

Fix this by calling cancel_work_sync(&priv->stats_report_task) after
timer_delete_sync() in both gve_queues_stop() and gve_free_stats_report().

The change is theoretical and was not tested on real hardware.

Link: https://sashiko.dev/#/patchset/20260425002450.163421-1-hramamurthy%40google.com?part=1
Cc: stable@vger.kernel.org
Fixes: 24aeb56f2d38 ("gve: Add Gvnic stats AQ command and ethtool show/set-priv-flags.")
Signed-off-by: Pin-yen Lin <treapking@google.com>
---

Changes in v3:
- New in v3

 drivers/net/ethernet/google/gve/gve_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index f1eb0c6e1f9b..28624ded5f3b 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -350,6 +350,7 @@ static void gve_free_stats_report(struct gve_priv *priv)
 		return;
 
 	timer_delete_sync(&priv->stats_report_timer);
+	cancel_work_sync(&priv->stats_report_task);
 	dma_free_coherent(&priv->pdev->dev, priv->stats_report_len,
 			  priv->stats_report, priv->stats_report_bus);
 	priv->stats_report = NULL;
@@ -1593,6 +1594,7 @@ static int gve_queues_stop(struct gve_priv *priv)
 		gve_clear_device_rings_ok(priv);
 	}
 	timer_delete_sync(&priv->stats_report_timer);
+	cancel_work_sync(&priv->stats_report_task);
 
 	gve_unreg_xdp_info(priv);
 
-- 
2.56.0.385.gd3acb90ef8-goog


      parent reply	other threads:[~2026-10-13  9:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261013093836.1269134-1-treapking@google.com>
2026-10-13  9:38 ` [PATCH net v3 1/5] gve: Fix race between stats query and queue reconfig Pin-yen Lin
2026-10-13  9:42   ` Pin-yen Lin
2026-10-13  9:38 ` [PATCH net v3 2/5] gve: Fix backward stats when interface goes down or configuration is adjusted Pin-yen Lin
2026-10-13  9:38 ` [PATCH net v3 3/5] gve: Block invalid ring sizes when device options are 0 Pin-yen Lin
2026-10-13  9:38 ` [PATCH net v3 4/5] gve: Fix link flap after ethtool ops Pin-yen Lin
2026-10-13  9:38 ` Pin-yen Lin [this message]

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=20261013093836.1269134-6-treapking@google.com \
    --to=treapking@google.com \
    --cc=stable@vger.kernel.org \
    /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