From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 5E681494833; Tue, 13 Oct 2026 18:30:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791916228; cv=none; b=g+KfhAsISRvTn8vnnx1e7t1GE0YFAf9ayD0LDxS+ky1yFeFT1HfpVch1A6w0V2xL1nrMNeE11D+NhZpfD8DEZpYxfs9vNRb7X88T14HB/F8138kYpo0mHjMj7VMP/ObMDPL72Mh1kk5fdr+iogYitbPhhQKPTLOajhoU77yFzv4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791916228; c=relaxed/simple; bh=vsoN9VPUKAXLa2JsZgMJMchfeaJcDruftVemEkgYBjg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sLXtsF9aeBk4YKOo1T8uDx5KfA95yK541L3cpwqkaXEwSmeUVTqfaBAS5Dz6v2v71lZA7myvkVEPK4CROPnsinVQ4u/Y7EwNUM6E7CUYp/gDOlZbulIS3yLD0gpaRDviC7/34u4Y44P8vDe0bbT4ZfzlWv8goCSYe8wSjNVUu74= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=JgXuCVxO; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="JgXuCVxO" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69DDSvnV1890643; Tue, 13 Oct 2026 18:29:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=xyF4JDuMeEQvMItzn CzgF6CnD0mtO6JIYD96KSrz7BA=; b=JgXuCVxON0rjvreIke2iTVyOHu0+K56PY /24m27oKHIQcwOGVCsCtIo3aQlOcgM1Hl2OP6SRGGVENjlngI6cxDGkxeOOMCChr tUGvMK7KYBI+wlysKYqYM0IU9A0jfKHlb/AQSr+5ZesV8WxePIqJ8NoGJEC9xVdF bZjVBbfSC7COdnVkoWA6oc3CBt+E4K3BW0gUcfM6enLkn+ZaLg4DoZWHanDJZbZq IgkNDH/+6yjtM3qcJqSmQ8HJmg5Ur+S/yPiwl5qgGiNBTSC8cmOQ2OVMcPSzMDUi IEojsMKe//kMWJ6Wko5CHwJiKH99QbLUoqZNoVg1Ax4utGWF6tQ/w== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4h7dv3g50v-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 13 Oct 2026 18:29:47 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69DIFmeW3303971; Tue, 13 Oct 2026 18:29:46 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4h9qb6rytm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Oct 2026 18:29:46 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69DITivJ7471830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Oct 2026 18:29:45 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89C0E58064; Tue, 13 Oct 2026 18:29:44 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B32058068; Tue, 13 Oct 2026 18:29:41 +0000 (GMT) Received: from localhost.localdomain (unknown [9.67.58.174]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 13 Oct 2026 18:29:41 +0000 (GMT) From: Mingming Cao To: netdev@vger.kernel.org Cc: Mingming Cao , maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com, nnac123@linux.ibm.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, horms@kernel.org, davemarq@linux.ibm.com, bjking1@linux.ibm.com, jeff@garzik.org, santil@us.ibm.com, stephen@networkplumber.org Subject: [PATCH net-next v5 1/9] ibmveth: fix netpoll races with RX replenish Date: Tue, 13 Oct 2026 11:29:18 -0700 Message-Id: <20261013182926.30417-2-mmc@linux.ibm.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20261013182926.30417-1-mmc@linux.ibm.com> References: <20261013182926.30417-1-mmc@linux.ibm.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-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: IsHs9VNUhh7gAXRV94u6pk9rRxJ1Ag1Y X-Proofpoint-ORIG-GUID: lZ-PEp7MVF3GZq6femnOCE8yt_s5i9Rl X-Authority-Analysis: v=2.4 cv=aqInmiZV c=1 sm=1 tr=0 ts=6ace789b cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=qzTZ72RhqM2DaLNR-rAA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDEzMDA3MiBTYWx0ZWRfX+PxRC76J8JTc +0j3wnDshIqYLIfZWUGashYGq9UiJAbT3vb7L0YNMKx0Hw7USlbmKJesB6oontdl1YNSTmOz72o XMc2dpoIuwQEmL3nuS9yEz1C0dB4A/I= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDEzMDA3MiBTYWx0ZWRfX1rI65w2D/P0O PJYLfSKngMEvNrwufU0k2ne+m0YefeOAtPF4PN5Fjlfm8UOeEqHjEJiVGrT1ajAFV71idwBAHX+ m9rgdzyuLZgQPSWv00w3YNJM160VvEw89RzmRWhuEX6arh+UsgdShGjcO5uygXls/dq85FJW/wP M65nf8L4BdXPl25wqt8driupfo1yte7mSH9YdvLFXFYXKNnLjb1MVo0S2D9IwO+1uscVUqRtTdg /M5dnjt7aNsErripYcopLdXbQXNiOPOeCIgxF1IBV3+G+F0PNPWFQU1Dwjwp+HWI4+JoTFMdlJ4 KVvcBO0l8wx2EZkStX9eRBKN+br6JC+RyDVXkJYEdYxkfgRIHFXw1siCqJoFbJ6Kgn080kZxyA1 uJNJSA5di85jAndgpF7cPmyAxCyG6M1JCpNp+xHUYEkqdyM7YeYsEDYEJkrFNRyXaTH+Atr2sV+ i1JJ4dJQUF0E2oAUY9Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-13_01,2026-10-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610130072 ibmveth_poll_controller() runs RX replenish outside NAPI and without a lock, racing NAPI's replenish on another CPU. Both can fill the same slot, so an skb and its DMA mapping leak and PHYP can write into an unmapped buffer. netpoll calls it from netconsole and from netpoll-enabled bonds. ibmveth_open() also enables NAPI before the RX resources exist. ibmveth_change_mtu(), veth_pool_store(), ibmveth_set_csum_offload() and ibmveth_set_tso() call close() and open() directly, so while open() is still setting up, netpoll and the direct ibmveth_interrupt() calls can replenish NULL pools and read freed memory. Remove the callback, as Eric Dumazet did for many drivers after commit ac3d9dd034e5 ("netpoll: make ndo_poll_controller() optional"), including ibmvnic in commit 0c3b9d1b37df ("ibmvnic: remove ndo_poll_controller"). netpoll then polls NAPI itself with budget 0. napi->poll_owner serializes that with NAPI, but not with a NAPI poll that was already running when netpoll was set up, so skip RX replenish at budget 0, which netpoll uses for TX only. TX completes synchronously, so ibmveth_poll() has nothing else to do for netpoll. Enable NAPI just before request_irq(), once everything ibmveth_poll() touches exists. Found in review of the ibmveth multi-queue RX series and confirmed by code inspection of poll_one_napi() and the direct close()/open() callers; neither race was reproduced. Tested on a POWER10 LPAR with netconsole over ibmveth: a ping flood (678,470 packets, no loss) during a printk flood, and MTU changes and buffer pool toggles under traffic, with no warnings. No kernel selftests cover ibmveth. Fixes: 6b4223748895 ("[PATCH] ibmveth: Add netpoll function") Fixes: bea3348eef27 ("[NET]: Make NAPI polling independent of struct net_device objects.") Signed-off-by: Mingming Cao --- Changes in v2: - skip RX replenish when ibmveth_poll() runs with budget 0: napi->poll_owner does not serialize netpoll with a NAPI poll that was already running when netpoll was set up drivers/net/ethernet/ibm/ibmveth.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index abebdb1fc262..4a5869183be6 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -628,8 +628,6 @@ static int ibmveth_open(struct net_device *netdev) netdev_dbg(netdev, "open starting\n"); - napi_enable(&adapter->napi); - for(i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) rxq_entries += adapter->rx_buff_pool[i].size; @@ -717,10 +715,18 @@ static int ibmveth_open(struct net_device *netdev) } } + /* NAPI can run as soon as it is enabled, from netpoll during the + * direct close()/open() pairs or from a direct ibmveth_interrupt() + * call, so enable it only once everything ibmveth_poll() touches + * exists. + */ + napi_enable(&adapter->napi); + netdev_dbg(netdev, "registering irq 0x%x\n", netdev->irq); rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name, netdev); if (rc != 0) { + napi_disable(&adapter->napi); netdev_err(netdev, "unable to request irq 0x%x, rc %d\n", netdev->irq, rc); goto out_free_buffer_pools; @@ -765,7 +771,6 @@ static int ibmveth_open(struct net_device *netdev) out_free_buffer_list: free_page((unsigned long)adapter->buffer_list_addr); out: - napi_disable(&adapter->napi); return rc; } @@ -1542,7 +1547,11 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) } } - ibmveth_replenish_task(adapter); + /* netpoll polls with budget 0 for TX only, and is not serialized + * with a NAPI poll that was already running when it was set up + */ + if (budget) + ibmveth_replenish_task(adapter); if (frames_processed == budget) goto out; @@ -1682,14 +1691,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu) return -EINVAL; } -#ifdef CONFIG_NET_POLL_CONTROLLER -static void ibmveth_poll_controller(struct net_device *dev) -{ - ibmveth_replenish_task(netdev_priv(dev)); - ibmveth_interrupt(dev->irq, dev); -} -#endif - /** * ibmveth_get_desired_dma - Calculate IO memory desired by the driver * @@ -1791,9 +1792,6 @@ static const struct net_device_ops ibmveth_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = ibmveth_set_mac_addr, .ndo_features_check = ibmveth_features_check, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = ibmveth_poll_controller, -#endif }; static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) -- 2.50.1 (Apple Git-155)