From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 703E540DFA5 for ; Tue, 10 Mar 2026 14:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773152989; cv=none; b=BTMfhvljVnV8NdfWT/IdAb6CWQfN/btOMxJLOj7vLNBBqR8lTsyRxPoZYYQmhuzwlX3F7pFRjsVoFUZ3e+Jm3xi3kqMNd315Dp0eku10LlqEo/7Ok/hDuUUXQOnyKVrDVY2VKZ2WMitevRpW7E5Lc42e3cY37ne0kCy4ixuV52A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773152989; c=relaxed/simple; bh=iER+Hd4+IIHZJwtIpReHWAJBLrkOCj27Ep772FXakME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XGBkDMJ546GFkPJVZuu0BVLvaObZB4g96pnWJIekaSgdvSZVG1iZVWbZDoM7Zh5iIB8E71DCxPCF2TJU5vlaCJJcOFjrIlA11s4mnNkJTRz/NEkeSgba8cAdE3mTGnEdPa8ZGNxyhberEO6N/76OcvTq9uYrrksQjJ0AIbpVs90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ba59QdOX; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ba59QdOX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773152987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G9Kl/AJsyijdHET1vAK8UKCGDRuKVXFmJTFZ6ZiROck=; b=ba59QdOXRH4wjpsBqtOsLYQQ8hNSFtdlkCc8OkR74Uo+8tDD56eT0btnb1x5fRRjuHBhVv 3/awSNLnJsdrqNAKb6ZrZrKYvyWifnyY/6OcRrThEfBhlvLdU46RJIGQFh01SihU49d3EC xQRjE9WhwVGeP+tkMALvbnNbvAZkil0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-68mKelE2NYKHcD6YgGEgEg-1; Tue, 10 Mar 2026 10:29:44 -0400 X-MC-Unique: 68mKelE2NYKHcD6YgGEgEg-1 X-Mimecast-MFC-AGG-ID: 68mKelE2NYKHcD6YgGEgEg_1773152981 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 698581800359; Tue, 10 Mar 2026 14:29:41 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.225.133]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 35D491800361; Tue, 10 Mar 2026 14:29:35 +0000 (UTC) From: Paolo Abeni To: longli@microsoft.com Cc: kotaranov@microsoft.com, erick.archer@outlook.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, pabeni@redhat.com, shradhagupta@linux.microsoft.com, haiyangz@microsoft.com, kys@microsoft.com, horms@kernel.org, linux-kernel@vger.kernel.org, decui@microsoft.com, schakrabarti@linux.microsoft.com, kuba@kernel.org, davem@davemloft.net, edumazet@google.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [net-next,v3,4/6] net: mana: Use GIC functions to allocate global EQs Date: Tue, 10 Mar 2026 15:29:31 +0100 Message-ID: <20260310142931.237121-1-pabeni@redhat.com> In-Reply-To: <20260306213302.544681-5-longli@microsoft.com> References: <20260306213302.544681-5-longli@microsoft.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html --- net: mana: Use GIC functions to allocate global EQs Replace the GDMA global interrupt setup code with the new GIC allocation and release functions for managing interrupt contexts. > diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c > index c43fd8089e77..bdc9dc437fb7 100644 > --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c > +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c [ ... ] > @@ -2052,26 +1998,17 @@ static int mana_gd_setup_remaining_irqs(struct pci_dev *pdev) > static void mana_gd_remove_irqs(struct pci_dev *pdev) > { > struct gdma_context *gc = pci_get_drvdata(pdev); > - struct gdma_irq_context *gic; > int irq, i; > > if (gc->max_num_msix < 1) > return; > > - for (i = 0; i < gc->max_num_msix; i++) { > - irq = pci_irq_vector(pdev, i); > - if (irq < 0) > - continue; > - > - gic = xa_load(&gc->irq_contexts, i); > - if (WARN_ON(!gic)) > - continue; > - > + for (i = 0; i < (gc->msi_sharing ? gc->max_num_msix : 1); i++) { ^^^ Does this loop condition leak GIC references when msi_sharing is false? When msi_sharing is false, the loop only releases the GIC at index 0. However, mana_gd_setup_dyn_irqs allocates GICs at indices 1 through nvec: drivers/net/ethernet/microsoft/mana/gdma_main.c:mana_gd_setup_dyn_irqs() { for (i = 1; i <= nvec; i++) { gic = mana_gd_get_gic(gc, false, &i); ... } } Each mana_gd_get_gic call initializes the GIC with refcount=1. These GICs at indices 1..nvec are never released because mana_gd_remove_irqs only processes index 0 when msi_sharing is false. The old code iterated over all gc->max_num_msix entries unconditionally: for (i = 0; i < gc->max_num_msix; i++) { ... gic = xa_load(&gc->irq_contexts, i); ... free_irq(irq, gic); xa_erase(&gc->irq_contexts, i); kfree(gic); } This ensured every allocated GIC was freed. The new code with the conditional loop breaks this, resulting in: 1. Leaked IRQ handlers - request_irq without matching free_irq for indices 1..nvec 2. Leaked gdma_irq_context memory - the GIC structures are never freed 3. Leaked xarray entries - the entries remain in gc->irq_contexts Additionally, pci_free_irq_vectors is called immediately after the loop, which attempts to tear down MSI-X vectors while IRQ handlers at indices 1..nvec are still registered. Can this trigger warnings or use-after-free if an interrupt fires during teardown? The next commit in the series (4475f13983ab "net: mana: Allocate interrupt context for each EQ when creating vPort") adds per-EQ get/put of GICs, but the EQ teardown only drops the EQ's reference (refcount goes from 2 to 1). The base reference from mana_gd_setup_dyn_irqs remains unreleased. > /* Need to clear the hint before free_irq */ > + irq = pci_irq_vector(pdev, i); > irq_update_affinity_hint(irq, NULL); > - free_irq(irq, gic); > - xa_erase(&gc->irq_contexts, i); > - kfree(gic); > + > + mana_gd_put_gic(gc, false, i); > } > > pci_free_irq_vectors(pdev);