From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DDC606A322 for ; Sat, 5 Dec 2026 13:16:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=tRHFznTr; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mzFPjaRF Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 609EB81288; Sat, 5 Dec 2026 13:16:35 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id L75rMgcIuoX7; Sat, 5 Dec 2026 13:16:34 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 7F46C81EA4 Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796476594; b=iPOLDtOtym6tS7P5K8HzbRgcgIaLMU+SfdAb46SUADqMiSWORoZkpCxIDqFdvujDCwoq P1MhKtW9EQeRa9F0omghIcs0kN3sJqpIRxdmIMJe2Xy5X47yXQG31X8VpMFWitqA5+Dsw poJydbTQ1RSjTGjd+6SZtiwQcn6rTjFF9STtq2ZBYEO74hhqV56YGau2pCQGd1bUUaMhG 9Fw3OnWRe1XmCIf6G4yIC6C0EGfUWg716RBRd+acwquyf+S0kASBcpCLUkBC35yROgfV3 cX3RX0aW/n3qEpTouwAPDHlTQBAkWLn9wgUvBWvgudqiBTDXH3+D1P0qcqtaRJK2ApQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796476594; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: Received:DKIM-Signature:Message-ID:From:Subject:To:Cc:In-Reply-To: References:Content-Type:Content-Transfer-Encoding:Date:X-BeenThere: X-Mailman-Version:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Reply-To:Errors-To; bh=zbaTEGJh2GLt//aPXJvgY9IIXg79IjBIRNWHRtNU3Bw=; b=YUSATPTRRNypQncXGESWYX6oN0ceSDy9XoIqRCdvWuYYm7c7tstvkoRcdhxjtdF8YUqo rDsQ66q9Jp79lt9SYwgnC3dAvhIBgy28EiJQ6adajE6THEL5CxF6JrLof1J2gNx9/2/HI GODf6bbWbBnhuh99iMqqpjZBSZnta5le/Ab8wfno0utRBK7IbZN3YCCjgpKGPN+HjlvKl zgthN99rpfizRydMb1hGEqSPMTuisSySsAgHtLKb2VuI05HVBQA5dRY4Bhv6k6riYk5PO 6zeT+q8rDkfsaZUm57PN9RlbQCL9dws4JdnJtSikYpb64dDeYyvzoREnLAFkZ8HAqPg== ARC-Authentication-Results: i=1; smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1796476594; bh=zbaTEGJh2GLt//aPXJvgY9IIXg79IjBIRNWHRtNU3Bw=; h=From:Subject:To:Cc:In-Reply-To:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Reply-To:From; b=tRHFznTrnAp7PbHBOn/ikZxpYD75LU7kkIXekYyVWrWx2DtS+0AjvDWLj/osDXQnz dQhBcKTaZPDJ6PqTdZmwFzDd1OrO+Qa2JxQImeZFkby/1AzaL05uBs6FUGG+BRgSMS RwIYjtdN2KToEhICmeWVrl2IMbXwZYAJFMl+FRx8vxq8csen8wkJPggYpLY2yS3rqA 1lV0d1RZl70oeLMR5l8bEH+vkBFTGxTw7DuoP78sAdtqfAezw9BPabW9v0tRxOALnf WtaAplGB8pF1sNtZ5uhBpBFY1h2Vr+gXaz7kr3HSfcmPVAQVg1Q2VCZc/DAPxNzjTN 6KHvxR72zXX0A== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 7F46C81EA4; Sat, 5 Dec 2026 13:16:34 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id C00A436A for ; Sat, 5 Dec 2026 13:16:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BDB28400BE for ; Sat, 5 Dec 2026 13:16:32 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id xpFWq59pg_Vy for ; Sat, 5 Dec 2026 13:16:32 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp2.osuosl.org C154B400BD Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip=172.105.4.254 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=sashiko-bot@kernel.org; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mzFPjaRF Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by smtp2.osuosl.org (Postfix) with ESMTPS id C154B400BD for ; Sat, 5 Dec 2026 13:16:31 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 10A6661528; Sat, 5 Dec 2026 13:16:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9BF31F00A11; Sat, 5 Dec 2026 13:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796476589; bh=zbaTEGJh2GLt//aPXJvgY9IIXg79IjBIRNWHRtNU3Bw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=mzFPjaRFpHiiQl13d818KijE29ZbU/xcStBuNm1rBJ4idKM29bAnlz/flBN9UJZWg cLA5GyfL41KiRMQqG/G+5MPeZxUBph7t7ZOtWTqzBsA4soHcvDm0XAObGvySTvGeFB O+RWC7+j45Z4g8qur1ueHUvCeNq9/mqfRQl+5kvIm6F1ZB4dYu36zP2yzR1/+8bxBD KyCwAzD3XYabuY12xlxhFWB87U6s7CWoOOQI5+91+zq+2YWYEoJQnIA+ikgx9C3IFq +lJiYQ1zL1bxbinVvFpspnTqBNLFUHQVzV24fBRYTiK2VQeuk9ZjJJkRJ9iVSHfTD7 9/YCA+7Q1KWXw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 iwl-next 5/5] idpf: Unmap Rx payload pages above mapped threshold under DMA-FQ IOMMU. To: "Kuniyuki Iwashima" Cc: intel-wired-lan@lists.osuosl.org In-Reply-To: <20261205125237.2290932-6-kuniyu@google.com> References: <20261205125237.2290932-1-kuniyu@google.com> <20261205125237.2290932-6-kuniyu@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 13:16:29 +0000 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] idpf: use-after-free iterating adapter->vports in idpf_rx_bufs_init() - [Medium] idpf: early DMA unmap before sync in idpf_rx_splitq_clean() -- commit 7eb204337944ee9347e5afd898d0150f3523d291 Author: Kuniyuki Iwashima idpf: Unmap Rx payload pages above mapped threshold under DMA-FQ IOMMU. This commit adds threshold-based early DMA unmapping for splitq Rx payload pages in idpf when XDP is disabled on DMA-coherent devices under an IOMMU_DOMAIN_DMA_FQ domain. It tracks active descriptor references per page in a per-bufq ring and calls page_pool_dma_unmap_netmem() once all descriptors referencing a tracked page complete. > diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/et= hernet/intel/idpf/idpf_txrx.c > index fb6a2ea25dc5d..a21f21cf66ec7 100644 > --- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c > +++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c [ ... ] > @@ -869,6 +997,59 @@ static int idpf_rx_bufs_init(struct idpf_buf_queue *= bufq, > if (ret) > return ret; > =20 > + if (PP_DMA_INDEX_BITS && !fq.xdp && > + !dma_dev_need_sync(&vport->adapter->pdev->dev)) { > + struct iommu_domain *domain; > + > + domain =3D iommu_get_domain_for_dev(&vport->adapter->pdev->dev); > + if (domain && domain->type =3D=3D IOMMU_DOMAIN_DMA_FQ) { [ ... ] > + idpf_for_each_vport(vport->adapter, v) > + num_bufqs +=3D > + v->dflt_qv_rsrc.num_rxq_grp * > + v->dflt_qv_rsrc.num_bufqs_per_qgrp; > + num_bufqs =3D max_t(u32, 1, num_bufqs); [Severity: Medium] Can iterating adapter->vports here race with vport teardown on a multi-vport adapter and trigger a use-after-free? idpf_open() reaches idpf_rx_bufs_init() holding rtnl_lock and adapter->vport_ctrl_lock. On device removal, idpf_remove() -> idpf_vc_core_deinit() -> idpf_deinit_task() tears down vports sequentially via idpf_vport_dealloc() without holding either lock across vport destruction, while sibling netdevs are still registered. In idpf_vport_dealloc(), idpf_vport_rel() calls kfree(vport) before adapter->vports[i] is cleared to NULL: CPU0 CPU1 idpf_remove() idpf_vc_core_deinit() idpf_deinit_task() idpf_vport_dealloc(...) idpf_vport_rel(vports[0]) kfree(vports[0]) idpf_open(netdevs[1]) ... idpf_rx_bufs_init() v->dflt_qv_rsrc... <-- use-after-free adapter->vports[0] =3D NULL Dereferencing v->dflt_qv_rsrc on the freed sibling vport causes a slab use-after-free read. [ ... ] > @@ -3948,6 +4129,7 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queu= e *rxq, int budget) > buf_id =3D le16_to_cpu(rx_desc->buf_id); > =20 > rx_buf =3D &rx_bufq->buf[buf_id]; > + idpf_rx_buf_dma_unmap(rx_bufq, buf_id); > =20 > if (!coherent_hdr && !rx_bufq->hdr_pp) > goto payload; [Severity: Medium] Should idpf_rx_buf_dma_unmap() run after libeth_rx_sync_for_cpu() instead of before it? When entry->refs reaches 0, page_pool_dma_unmap_netmem() unmaps the page and clears netmem->dma_addr to 0. On an untrusted DMA-coherent PCIe device switched to IOMMU_DOMAIN_DMA_FQ via sysfs, dma_dev_need_sync() starts false and flips to true on the first unaligned streaming mapping that uses swiotlb: CPU0 CPU1 idpf_rx_splitq_clean() idpf_rx_buf_dma_unmap() page_pool_dma_unmap_netmem() dma_dev_need_sync() =3D=3D false dma_addr =3D 0 idpf_tx_splitq_map() dma_map_single() swiotlb_tbl_map_single() dma_reset_need_sync(dev) idpf_rx_splitq_clean_skb() libeth_rx_sync_for_cpu() iommu_dma_sync_single_for_cpu(0 + offset) swiotlb_bounce() <-- corrupts unrelated memory When host PAGE_SIZE exceeds the IOMMU granule (for example, 64K pages with a 4K granule), sub-page offsets >=3D 4K land in allocatable IOVA PFNs rather than the reserved PFN 0. If that PFN holds an active swiotlb bounce buffer, swiotlb_bounce() overwrites unrelated kernel memory. Moving idpf_rx_buf_dma_unmap() after libeth_rx_sync_for_cpu() and before rx_buf->netmem is cleared avoids syncing a cleared DMA address. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205125237.2290= 932-1-kuniyu@google.com?part=3D5