Linux-HyperV List
 help / color / mirror / Atom feed
From: Sahil Chandna <sahilchandna@linux.microsoft.com>
To: sashiko-reviews@lists.linux.dev, linux-hyperv@vger.kernel.org,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH net v2] net: mana: Add support to process throttled EQEs
Date: Mon, 19 Oct 2026 14:09:33 +0530	[thread overview]
Message-ID: <63471f61-97ff-4cd9-9c45-3b737edd8e69@linux.microsoft.com> (raw)
In-Reply-To: <sashiko-outbox-172938@kernel.org>

On 15-10-2026 19:13, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] net: mana: use-after-free of CQ during teardown due to RCU-001 removal ordering violation
> --
> 
> commit 4c00972dfa8283dfc036bc3bbb77031cb6550854
> Author: Sahil Chandna <sahilchandna@linux.microsoft.com>
> 
> net: mana: Add support to process throttled EQEs
> 
> When an event queue nears full, the hardware coalesces the per-CQ
> GDMA_EQE_COMPLETION notifications into a single throttle EQE (type 4)
> that carries no cq_id. The driver does not handle this event type, so
> it falls through to the default case and is dropped. Any CQ whose
> completion notification was replaced by the throttle EQE can remain
> unserviced, causing its queue to stall.
> 
> Link: https://lore.kernel.org/all/20261008083315.306076-1-sahilchandna@linux.microsoft.com/
> 
>> diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
>> index ae0ed700b3b93..95ba6ba161ae2 100644
>> --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
>> +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> [ ... ]
>> @@ -1063,17 +1089,45 @@ static void mana_gd_create_cq(const struct gdma_queue_spec *spec,
>>  static void mana_gd_destroy_cq(struct gdma_context *gc,
>>  			       struct gdma_queue *queue)
>>  {
>> +	struct gdma_queue *eq = queue->cq.parent;
>> +	bool attached = false;
>>  	u32 id = queue->id;
>> +	u8 i;
>> +
>> +	if (eq) {
>> +		for (i = 0; i < GDMA_EQ_MAX_CHILD_CQ; i++) {
>> +			if (rcu_access_pointer(eq->eq.child_cq[i]) == queue) {
>> +				RCU_INIT_POINTER(eq->eq.child_cq[i], NULL);
>> +				attached = true;
>> +			}
>> +		}
>> +
>> +		if (attached)
>> +			synchronize_net();
>> +	}
>>  
>>  	if (id >= gc->max_num_cqs)
>>  		return;
> 
> [Severity: High]
> Does this code order the CQ removal and grace period correctly to prevent
> a use-after-free?
> 
> Looking at the rest of mana_gd_destroy_cq(), gc->cq_table[id] is cleared
> after the synchronize_net() grace period ends:
> 
> drivers/net/ethernet/microsoft/mana/gdma_main.c:mana_gd_destroy_cq() {
> 	if (eq) {
> 		...
> 		if (attached)
> 			synchronize_net();
> 	}
> 
> 	if (id >= gc->max_num_cqs)
> 		return;
> 
> 	if (!gc->cq_table[id])
> 		return;
> 
> 	gc->cq_table[id] = NULL;
> }
> 
> Because gc->cq_table[id] remains published during and immediately after
> the grace period, can a concurrent or delayed interrupt processing
> GDMA_EQE_COMPLETION in mana_gd_process_eqe() still find the CQ?
> 
> drivers/net/ethernet/microsoft/mana/gdma_main.c:mana_gd_process_eqe() {
> 	case GDMA_EQE_COMPLETION:
> 		...
> 		cq = gc->cq_table[cq_id];
> 		...
> 		if (cq->cq.callback)
> 			cq->cq.callback(cq->cq.context, cq);
> }
> 
> If a new reader accesses the CQ from gc->cq_table after synchronize_net()
> returns, but before the caller mana_gd_destroy_queue() frees the memory via
> kfree(), could it lead to a use-after-free crash?
> 
> Should the clearing of gc->cq_table[id] happen before calling
> synchronize_net() so all reader-visible references are removed before
> waiting for the grace period?
> 
The cq_table dereferencing race is real between mana_gd_destroy_cq and
in GDMA_EQE_COMPLETION. I will address this re-ordering and if there are
any other comments on this patch in v3.

  reply	other threads:[~2026-10-19  8:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 13:43 [PATCH net v2] net: mana: Add support to process throttled EQEs Sahil Chandna
2026-10-15 13:43 ` sashiko-bot
2026-10-19  8:39   ` Sahil Chandna [this message]
2026-10-21  0:39 ` Jakub Kicinski

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=63471f61-97ff-4cd9-9c45-3b737edd8e69@linux.microsoft.com \
    --to=sahilchandna@linux.microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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