From nobody Tue Nov 24 04:37:10 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794474926; b=nlIZNYBOc9j1/9aerumxBExShY0eMPhxlcyRo70hn226Vd9q7b4uduKt9SkCDy7lfaYf iYAGSUGuaa//8oPk0Td+wzodwvbo/BkYV3ueAVLWhLpEveSsKMkCVUSVcHkupmEp6+ih4 LdpdHzFt5RpyKQJgm5T0wkOgE180rmN2+3GmYBE1/LBNRtEhIxt0vGfH+oc8DSMyUQSve KVRxybpMlx1z9bsU1xy7EeCnCw96hDrrRu7EnXqQnJIEccgeI/3W26uauSBlU0fQV1/Bx PSGnMkl5cNCU9CWfYQ4sd5UR3r7ZKvZ+/2ub3cHeUKS8KS0yRnefaN62xI7/iAcD1ug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794474926; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=cEN7d+jyurewLFa/LuiPLiAZonMx9OftX2NbfIlKgdw=; b=mYyAqCWW6l1wgeQG+8wInaNaOA+XqXfs8qf59ffa+9LSLQAW032Dt3eqa88YYJkQKYfp sRQt714xBqyMSpbbtTjBnMPPFeenBIVp0k9fl9vP9C6al0rSKJiJagdtB2A58/7wPIWJF WEda9aNa0T8fzr/3s/+KJ//XCfWE2ML8f4VoZTHi6njZzKU4WsbA9wo0vpyJqge5lqkbq HTMz6kObc7zWY8pNb8DypG8SHSj11Y+RMJEFd0tFHyRgf2rxdaqnQBEMzQVyxpfjTpKcP hmFFvf6vQwuPzjPwAvtjwhVs6Z2B+5ySBF9OdyZXOC5upX3s2Ae1p9+MdpRmCpqmERQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RdELOKkG; arc=none smtp.remote-ip=74.125.82.182 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D156606A33A for ; Thu, 12 Nov 2026 09:15:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D156606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RdELOKkG Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-372bdb942dbso5196961eec.1 for ; Thu, 12 Nov 2026 01:15:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794474926; x=1795079726; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cEN7d+jyurewLFa/LuiPLiAZonMx9OftX2NbfIlKgdw=; b=RdELOKkGhI/YuUC1xnfrm+5EXnd8mmiRPEm4bZGtKq8StrF+btPPCAlsUV3okt0tpU JmJ4jZG9ZqPA4105qLMh4EKJsPIAQAtMuGfMFB1PNMjdRKgccORMbGJEdHd38dhZYob1 CUUY/6UmSXOm1ZApgLezphXnJIf7TaTeBdV2fGjdLahhS1BnM6KmeYygB/icQXnOr804 52EwsS7iHDyY4FEPgiTh8RnkXWGW6RbuFcEuarHwbbS2+qIVxhV4RzRduneXq/kRCKye P3YvP7ReONvCelis5BZGSZ3f+f8kC/z+jk4mqQXDtUOPGhzhtfaa54W67JHaSFXcZd49 0VLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794474926; x=1795079726; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=cEN7d+jyurewLFa/LuiPLiAZonMx9OftX2NbfIlKgdw=; b=i9ix2/ZZQP9yfpER+V48e0KEW/JquAbDmCRcLO2tBSxsqRRvRqAP8WdmfSoXMMALAn cd5sZeUiSRwy6d2NYL7cFHOiA61cIsuO4/bJUpIFerMqkqXlBDjtMeTBc3Q0hrA3e0WH uJEzsY5RmOdL9bGdebgNV1mQMnYD3CmVUtNl08ll8bCRZN9cvWa3vbyxa8junGJAqt1Z Np+Ibi5KpsuKICz6fkP/Ppj0ZB3tERs4wJtURsVeqq83IpZ7S5U02ADcGEtmFDFybnBd 082DNVn8HAmKVdxYhOtgfFlQMVMpf0Y9gUcpZb4PpkqRJO7nD0xlsK5crBzIae9cByvs dPxw== X-Forwarded-Encrypted: i=1; AL+hErGcEOa/Ui5JUyi2vTYtcR6CsAwZ6Wje7UaSeIKLc7nXQBwQyYW8sVYhV1aVIWVo4MbvY+9fAe9b8U6CV4E=@vger.kernel.org X-Gm-Message-State: APuU4Z9DgLw5Fi2KA5Jp3etP0jRelmsM/MofnowBOz3ASq7puN1wl49c kmlyL9WwkP4r4M2TRIeIz1cZcbz+bGa1r1p0UtBIs+ocb/goxxjFk0Ta X-Gm-Gg: AYBFou1ps90xtDT2/19Ki40udGKF1VKLBqOOHoW1UZxS1Dhc0263P92DGNcA6C3/jzp oZ48n2BBIooxrBQ0CbhvIs6spr7snsAJdPRyWuSHeYSeZYOITfWIePkipy4CHbyuqegsETfhLef lLDK6Qr9ymB8wRfBLefHrIR487IAOH7ZWozPDNhs1WrgmEsVRSuCNQK289aySMYu3fYwBYHX9Ja YpxK1+UIRjHuIIJLUZodcdrphTtuAQvjAPH4SLU2LeU6jE93rr3B6QuZkvuv+GQVzf8EcHTE2+z fZN/4qT3uzBwYDOyqy4nYeQVLi43oAYOY5lMEsC1Oj31nIrXeZC2JNZ3EzvNJZ+HAvXonQWStBG 2MgpE4LDfbT03YyhjRTaVfu8uZMb+kiqu2sb2g2uIBzREY+oJSbnolK6+Wu/o23XCA4sveGDcn7 td/31V3SrOtDHXC8YwDrOpIl3gRr8kQ25nzChkCXNQwbyN8CjWv9/1ycXoCQFMbHrzb1EsxJ6Xg ORXUIYsSGf1JT0tVQvYKnU2GGNnlY6uYaIr4J9WpqmNprkEjYQ/M7PMxkKQ9CnO0rDoVnrWYZXq ntNoSwpxdwXJHf5tV2KrxkaFh1HvnkHBV8faRiGIj2eK X-Received: by 2002:a05:7301:514a:b0:36a:7b3c:4e0a with SMTP id 5a478bee46e88-3768675676dmr5379824eec.24.1794474924729; Thu, 12 Nov 2026 01:15:24 -0800 (PST) Received: from localhost.localdomain ([2406:7400:51:27a4:c2b6:f9ff:fe77:10a0]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-375212e7d24sm40096319eec.22.2026.11.12.01.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2026 01:15:24 -0800 (PST) From: Amaan Cheval To: netdev@vger.kernel.org Cc: joshwash@google.com, hramamurthy@google.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, bcf@google.com, jordanrhee@google.com, przemyslaw.kitszel@intel.com, maciej.fijalkowski@intel.com, pkaligineedi@google.com, maolson@google.com, csully@google.com, willemb@google.com, yangchun@google.com, npl@google.com, awogbemila@google.com, shailend@google.com, nktgrg@google.com, maxyuan@google.com, bpf@vger.kernel.org, john.fastabend@gmail.com, hawk@kernel.org, sdf@fomichev.me, daniel@iogearbox.net, ast@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Amaan Cheval Subject: [PATCH net v6 1/2] gve: refuse XDP on queue formats without XDP support Date: Thu, 12 Nov 2026 14:44:50 +0530 Message-ID: <20261112091451.22969-2-amaan.cheval@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20261112091451.22969-1-amaan.cheval@gmail.com> References: <20261112091451.22969-1-amaan.cheval@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit d8a8ca14c937 ("gve: add XDP_TX and XDP_REDIRECT support for DQ RDA") enabled XDP on DQO-RDA by dropping the queue_format check from verify_xdp_configuration(), which until then refused every format but GQI-QPL. Nothing replaced it: gve_set_netdev_xdp_features() advertises no XDP features for DQO-QPL and GQI-RDA and gve_xdp_xmit() rejects both, but the core only checks that ndo_bpf exists, so a native XDP program, and an AF_XDP socket on top of it, can still be attached on a queue format the driver does not support. The DQO-QPL RX path was never written for that. Its page accounting assumes the driver keeps a reference of its own across every handoff: gve_xdp_done_dqo() passes the buffer to xdp_do_redirect() and then recycles it with gve_reuse_buffer(), so a redirect target that releases the buffer synchronously, such as an AF_XDP socket in copy mode, can drop the page's last reference when pagecnt_bias runs out. The page is then freed while it is still DMA-mapped and registered in the QPL, and the driver posts it back to the device. GQI-RDA is no better off: an XDP_TX there goes through gve_tx_fill_xdp(), which copies the frame into tx->tx_fifo, but a raw-addressing TX ring never allocates that FIFO, so the first XDP_TX writes through a NULL tx_fifo.base. Refuse XDP setup in gve_verify_xdp_configuration() whenever the driver advertises no XDP features for the current queue format, which today means DQO-QPL and GQI-RDA. A zero-copy XSK pool bind is already refused by the core for the same reason, and a copy-mode bind never reaches the driver and is harmless without a program. Fixes: d8a8ca14c937 ("gve: add XDP_TX and XDP_REDIRECT support for DQ RDA") Cc: stable@vger.kernel.org Reviewed-by: Joshua Washington Signed-off-by: Amaan Cheval Tested-by on v2: --- v6: - Say the check also covers GQI-RDA, where XDP_TX writes into a TX FIFO that raw addressing never allocates (Sashiko). Message only, so I carried Joshua's Reviewed-by. v5: https://lore.kernel.org/netdev/20261109100437.331423-2-amaan.cheval@gma= il.com/ - Check dev->xdp_features instead of queue_format, and reword the subject and message around that (Joshua). v4: https://lore.kernel.org/netdev/20261106114551.212675-2-amaan.cheval@gma= il.com/ drivers/net/ethernet/google/gve/gve_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ether= net/google/gve/gve_main.c index 2437cd8ba633..fe560f5c5408 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c @@ -1723,6 +1723,12 @@ static int gve_verify_xdp_configuration(struct net_d= evice *dev, struct gve_priv *priv =3D netdev_priv(dev); u16 max_xdp_mtu; =20 + if (!(dev->xdp_features & NETDEV_XDP_ACT_BASIC)) { + NL_SET_ERR_MSG_MOD(extack, + "XDP is not supported on this queue format."); + return -EOPNOTSUPP; + } + if (dev->features & NETIF_F_GRO_HW) { NL_SET_ERR_MSG_MOD(extack, "XDP is not supported when HW-GRO is on."); --=20 2.47.3 From nobody Tue Nov 24 04:37:10 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794474940; b=vfqC/LBegfldq6IQIEA+1mnA8oPT47U7H8qDZ2v4EHxPjcR87kajIOlyeOQfldU6LY+1 qedgwQX1shMK4fY2lYGAwKtG6JK/rGiHYIZ9dTthwD88yvP1fK3y9YS2wanr8li7gXLNl 01QGeuXkFteSTSUol+OoiAahBwevrRqx6+1R0g3lV5FFe/Wecdbql9KuMlYOkb+m9erpa WXNZH124M9KkPmGaAOCfUTlQ8T2y99Wmdvvfxp9notBvlfVPU4w3rlWNuKfl6ShgquLl+ gy3jdbBPUqoiPUPI1yBq2M8+3DFE+qVZ1XzOfncOTEskO9LSKSrsBae9KGqrVUvcWMQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794474940; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=Tm6gw4Nr3ga8o79ZJ8Y5quYuKLdUr5b2uF9gkEscNaE=; b=CtfnfQrYqhea0ykuwirW48IFO4tRk2sNgX4vM82QDdcoYz0cnmwNcrAgYt13VKFqRghd OrigXyalkgW6e7C69OGbtkKbq5HARImYS0OKqrgX+CoRe1yloEPHvMO/8aOaj2iijCMqD yiwApKVDgNjChQzkeymZB3obTdYXpTvhuP+xfd9IvDtlcg5TjVUq/I4Feok4Rg2Pdtotm 4a34yMTr20q2I92scSmp9n7MSEAeAmlWmzMUxGxXniRPduTe5CKApdXA0yCEcltZ5CN5N cTUdg53vZukQBeCb22NmtBWVQOYD4F77VnEGXgRpqNSEbq5MwpT5ubpfx8umUnGZKUA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=CcKSa+BQ; arc=none smtp.remote-ip=74.125.82.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B591C606A8BC for ; Thu, 12 Nov 2026 09:15:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B591C606A8BC Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=CcKSa+BQ Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-36a315ed211so697843eec.0 for ; Thu, 12 Nov 2026 01:15:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794474939; x=1795079739; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Tm6gw4Nr3ga8o79ZJ8Y5quYuKLdUr5b2uF9gkEscNaE=; b=CcKSa+BQ2xokalyWLWa4SPtACIKAXSJQ9rIOBPvApBTPCld/gDSiBcYTCk1o0zG2tc /UkLv7SR5ovLqQHHql//ePt4VVqqiJsSjmA951wBr0vBtbH9vx5WDdedzDu5JCI2Nsx/ aFpNOHOZ1yoL+0xDWWuyj7AfZrynAkJElSAQfpzEood0tzp9dfX0DN0lDoOKu3tXq0vx ibDpeYiA1InGWH34coPEVmrbZfzDngTdYWGz42uzH+ka9xuRXzI6kUQdxTY1mBuYCwsS zb5VdZFba032HZaSp6h5ivpBn66p2NwqNsrQ2Es3n6k3RbEPxm2LJUmKHj9Hc4Rq0DIu uPBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794474939; x=1795079739; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Tm6gw4Nr3ga8o79ZJ8Y5quYuKLdUr5b2uF9gkEscNaE=; b=ZMqJEy42fgxiSO+tKZkRjHo+v9PqGrz22Mz582n6lkQSvE/Li4OsCAJ/Ok/bYPp7vG XHJNz/LpqWYW82bMEaDN9rVlHaQSHtVfqByCC6UkfKwKPOs4vxosAylT/hmLPpjHkrq/ DCwqqyhpp7bbw7kELw7lhshQSxTzaHQno6c4Y8if1uX1iN4eULIBDUioSEUsKRRYezrB a5BwtMzz/vL6EQVwMl6zWpzYJwd4XlUEG5QItOonE/jrmYa5qmkWMgB7cMgPOSiRurx2 1ZVugCLgO0hsyxQnCrlddbxu5A4TRLC3oXJHSFSBc08v2fgR63HFn5oyQc6rDgRBmTdU uHhA== X-Forwarded-Encrypted: i=1; AL+hErEYbyf8iMsygODYeyeejo4CqfZ1CGsz81ii/sQMaT93NTfD9JsP4R+6h0xTLik00r7yc24cVoueo7HUN0M=@vger.kernel.org X-Gm-Message-State: APuU4Z/zakzl71NuleiHTqTSqG4TrteOw1yMRdq0XKv+0TZgSNi0QXan 0yxXHxi2ez8SXnI9hbbHGXM24K2K7hd/8iH7zBYxte1k27jQ2jScjN6/ X-Gm-Gg: AYBFou3iUfuGMfTvrKFvprXj19L7wkKSYtOF5OBiqdIZp63/nCQS54OmnGmOxBHC8GD 7lJ+N4UDRRIH9q9jDt/ZM2yyuE4GGW4uYJ4BM1q0dv3gMj3A5dGCght+OBXa/3JirFtEtpn88KK hDxJrzosb4hLSMeCN4BYZUKmJS8ZxTTB4TWm0Uu/brAKylGZanvohzoQNCp39YqzOEUXul/r0fg gDWKJml4Tb42DVpZMhI+gogU+rX57WrrEA7AXKR8JxPE0kWlq31Vnzn00JVmXbaszJhatDzlZJO adc7yajisLs5xChD0/fzChAVDryzNeRvzi8aWKjK1VSiWwKHm98GKRrDlrYgHGlZyas+CBAoWJi O+aIcg4U+wU8TL0WqTSkQHBgJo5ClEBLcNw5P6YmpmK+uh4oX5ZvAKojU7xLbdAOlDDapjEHytB tLiM38JmFuZX+Kwr+iiUqYZvSgXKCW0TzSugGx4ZVhezsvB8mBscO6bbYLLO8EYIMVlZUVvc/Ka zusJcHA2djecrlUBI9tW7i7Svs0lhiqwpRGcTP9emRRAzdoV99l0oMfWpaVFQsFk+gMLD5lbgYW wReI1RNt+e2hSzaGkqqoe8sj19HFebY8Jy3PuzYak1Ml X-Received: by 2002:a05:7301:2103:b0:36a:1a7b:d1bb with SMTP id 5a478bee46e88-377e1af5c7bmr1885067eec.22.1794474938445; Thu, 12 Nov 2026 01:15:38 -0800 (PST) Received: from localhost.localdomain ([2406:7400:51:27a4:c2b6:f9ff:fe77:10a0]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-375212e7d24sm40096319eec.22.2026.11.12.01.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2026 01:15:38 -0800 (PST) From: Amaan Cheval To: netdev@vger.kernel.org Cc: joshwash@google.com, hramamurthy@google.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, bcf@google.com, jordanrhee@google.com, przemyslaw.kitszel@intel.com, maciej.fijalkowski@intel.com, pkaligineedi@google.com, maolson@google.com, csully@google.com, willemb@google.com, yangchun@google.com, npl@google.com, awogbemila@google.com, shailend@google.com, nktgrg@google.com, maxyuan@google.com, bpf@vger.kernel.org, john.fastabend@gmail.com, hawk@kernel.org, sdf@fomichev.me, daniel@iogearbox.net, ast@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Amaan Cheval Subject: [PATCH net v6 2/2] gve: fix RX page refcount overflow from INT_MAX pagecnt_bias Date: Thu, 12 Nov 2026 14:44:51 +0530 Message-ID: <20261112091451.22969-3-amaan.cheval@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20261112091451.22969-1-amaan.cheval@gmail.com> References: <20261112091451.22969-1-amaan.cheval@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" gve's GQI and DQO-QPL RX paths set every RX page's refcount to INT_MAX and hand references to the stack by decrementing page_info->pagecnt_bias, to avoid an atomic op per packet. This leaves no room for anyone else: while a fresh page's buffer sits in an skb its refcount is already INT_MAX, so a single get_page() from the stack overflows it to negative. splice() of received TCP data into a pipe takes such a reference, and the onward splice into a socket then fails: skb_splice_from_iter() sees page_count() < 1, sendpage_ok() fails and the send returns -EIO (since commit 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")). tee() of the pipe fails with -EFAULT via try_get_page(). On GQI the reuse check gve_rx_can_recycle_buffer() also sees page_count() < pagecnt_bias, WARNs and calls gve_schedule_reset(), so a task that merely pins a fresh RX page (e.g. holds spliced data in an undrained tee() pipe) can reset the NIC. Use USHRT_MAX in a u16, as igb, igc, ixgbe, i40e and hns3 do: the bias only has to make the per-packet atomic rare, so a small value keeps page_count() far below INT_MAX however many references the stack takes. Refill by adding a fixed batch and setting the bias to it, which keeps the rule `references =3D page_count() - bias` intact. Refilling at 0 hands the driver's last reference to the consumer once every USHRT_MAX handoffs rather than once every INT_MAX, which is only safe because every consumer on these paths holds its reference until the driver has recycled the buffer. The previous patch keeps it that way by blocking XDP on DQO-QPL, so this one depends on it. Trees before 6.17, without commit d8a8ca14c937 ("gve: add XDP_TX and XDP_REDIRECT support for DQ RDA"), still refuse XDP on every format but GQI-QPL in verify_xdp_configuration(), so there this patch stands alone. Reproduced on gVNIC in GQI-QPL mode (GCE n2-standard-8, 6.12) and in DQO-RDA mode (GCE c3-standard-8, 6.12, where DQO-RDA still uses the bias) with the help of relay.py -- a small splice(2) TCP proxy -- relaying a download while the RX ring is refilled with fresh pages: ethtool -G eth0 rx 512 && ethtool -G eth0 rx 1024 # fresh RX pages ./relay.py $HOST 8080 & # splice()s both ways for i in $(seq 200); do curl -so /dev/null \ --connect-to $HOST:80:127.0.0.1:8080 http://$HOST/file; done Most downloads failed with EIO before the fix (tee() with EFAULT) and all completed after it. relay.py is at the Link below. This bug was found and fixed with the help of an AI coding assistant (Claude Code) over an interactive session; it read the driver and splice/pipe code and ran the tests above. Link: https://github.com/amaanc/kernel-bias Fixes: 9b8dd5e5ea48 ("gve: DQO: Add RX path") Fixes: 58401b2a46e7 ("gve: Add rx buffer pagecnt bias") Fixes: 82fd151d38d9 ("gve: Reduce alloc and copy costs in the GQ rx path") Cc: stable@vger.kernel.org Reviewed-by: Harshitha Ramamurthy Tested-by: Harshitha Ramamurthy Reviewed-by: Maciej Fijalkowski Signed-off-by: Amaan Cheval Tested-by on v2: --- v6: - No change; patch 1/2 changed. v5: https://lore.kernel.org/netdev/20261109100437.331423-3-amaan.cheval@gma= il.com/ - Name INT_MAX in the subject. No code change; patch 1/2 changed. v4: https://lore.kernel.org/netdev/20261106114551.212675-3-amaan.cheval@gma= il.com/ - Add patch 1/2, blocking XDP on DQO-QPL, which this fix depends on (Sashiko). Harshitha said Google would send such a patch; I'm happy to drop 1/2 in favour of theirs. - Say "overflow" instead of "headroom" in the subject and the commit message (Maciej). - Use USHRT_MAX directly instead of a GVE_PAGECNT_BIAS macro, as the other drivers do, and move its rationale next to the refill in gve_dec_pagecnt_bias() (Maciej). No functional change. - Added Reviewed-by from Maciej Fijalkowski. - Say which trees need patch 1/2, for stable. v3: https://lore.kernel.org/netdev/20261103090651.35399-1-amaan.cheval@gmai= l.com/ - Refill when the bias reaches 0 again, as in v1. DQO-QPL is not supposed to support XDP at all, and it will be blocked explicitly in a separate patch, so the v2 refill-at-1 change is not needed. - Added Reviewed-by and Tested-by from Harshitha Ramamurthy. v2: https://lore.kernel.org/netdev/20261102112613.18334-1-amaan.cheval@gmai= l.com/ - Refill when the bias reaches 1 instead of 0 so the driver keeps a reference of its own across every handoff. At bias 0 a consumer that returns its reference synchronously, such as an AF_XDP socket in copy mode on an XDP_REDIRECT from DQO-QPL, freed a page still registered in the QPL. - Commit message: explain the refill point, drop the build notes. - Re-tested on 6.12.113 (c3-standard-8, DQO-RDA, which still uses the bias on 6.12): no EIO/EFAULT from splice/tee and no NIC reset after applying the patch. DQO-QPL is untested; I have no access to that hardware. v1: https://lore.kernel.org/netdev/20261031173449.2439047-1-amaan.cheval@gm= ail.com/ Built allmodconfig W=3D1, no new warnings. drivers/net/ethernet/google/gve/gve.h | 2 +- .../net/ethernet/google/gve/gve_buffer_mgmt_dqo.c | 4 ++-- drivers/net/ethernet/google/gve/gve_rx.c | 8 ++++---- drivers/net/ethernet/google/gve/gve_utils.c | 12 ++++-------- drivers/net/ethernet/google/gve/gve_utils.h | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/g= oogle/gve/gve.h index b7ce6e8632db..18d7edbf4b3b 100644 --- a/drivers/net/ethernet/google/gve/gve.h +++ b/drivers/net/ethernet/google/gve/gve.h @@ -119,7 +119,7 @@ struct gve_rx_slot_page_info { void *page_address; u32 page_offset; /* offset to write to in page */ unsigned int buf_size; - int pagecnt_bias; /* expected pagecnt if only the driver has a ref */ + u16 pagecnt_bias; /* expected pagecnt if only the driver has a ref */ u16 pad; /* adjustment for rx padding */ u8 can_flip; /* tracks if the networking stack is using the page */ }; diff --git a/drivers/net/ethernet/google/gve/gve_buffer_mgmt_dqo.c b/driver= s/net/ethernet/google/gve/gve_buffer_mgmt_dqo.c index 6880d1531ba5..52223baf0303 100644 --- a/drivers/net/ethernet/google/gve/gve_buffer_mgmt_dqo.c +++ b/drivers/net/ethernet/google/gve/gve_buffer_mgmt_dqo.c @@ -149,8 +149,8 @@ int gve_alloc_qpl_page_dqo(struct gve_rx_ring *rx, buf_state->last_single_ref_offset =3D 0; =20 /* The page already has 1 ref. */ - page_ref_add(buf_state->page_info.page, INT_MAX - 1); - buf_state->page_info.pagecnt_bias =3D INT_MAX; + page_ref_add(buf_state->page_info.page, USHRT_MAX - 1); + buf_state->page_info.pagecnt_bias =3D USHRT_MAX; =20 return 0; } diff --git a/drivers/net/ethernet/google/gve/gve_rx.c b/drivers/net/etherne= t/google/gve/gve_rx.c index 81ea800e66e9..3bed19866376 100644 --- a/drivers/net/ethernet/google/gve/gve_rx.c +++ b/drivers/net/ethernet/google/gve/gve_rx.c @@ -152,8 +152,8 @@ static void gve_setup_rx_buffer(struct gve_rx_ring *rx, page_info->buf_size =3D rx->packet_buffer_size; *slot_addr =3D cpu_to_be64(addr); /* The page already has 1 ref */ - page_ref_add(page, INT_MAX - 1); - page_info->pagecnt_bias =3D INT_MAX; + page_ref_add(page, USHRT_MAX - 1); + page_info->pagecnt_bias =3D USHRT_MAX; } =20 static int gve_rx_alloc_buffer(struct gve_priv *priv, struct device *dev, @@ -230,8 +230,8 @@ static int gve_rx_prefill_pages(struct gve_rx_ring *rx, rx->qpl_copy_pool[j].buf_size =3D rx->packet_buffer_size; =20 /* The page already has 1 ref. */ - page_ref_add(page, INT_MAX - 1); - rx->qpl_copy_pool[j].pagecnt_bias =3D INT_MAX; + page_ref_add(page, USHRT_MAX - 1); + rx->qpl_copy_pool[j].pagecnt_bias =3D USHRT_MAX; } } =20 diff --git a/drivers/net/ethernet/google/gve/gve_utils.c b/drivers/net/ethe= rnet/google/gve/gve_utils.c index caed38cd5f2b..930555ac8fe9 100644 --- a/drivers/net/ethernet/google/gve/gve_utils.c +++ b/drivers/net/ethernet/google/gve/gve_utils.c @@ -93,15 +93,11 @@ void gve_dec_pagecnt_bias(struct gve_rx_slot_page_info = *page_info) { page_info->pagecnt_bias--; if (page_info->pagecnt_bias =3D=3D 0) { - int pagecount =3D page_count(page_info->page); - - /* If we have run out of bias - set it back up to INT_MAX - * minus the existing refs. + /* Out of bias: take another batch. USHRT_MAX keeps this rare + * while leaving page_count() far below INT_MAX. */ - page_info->pagecnt_bias =3D INT_MAX - pagecount; - - /* Set pagecount back up to max. */ - page_ref_add(page_info->page, INT_MAX - pagecount); + page_info->pagecnt_bias =3D USHRT_MAX; + page_ref_add(page_info->page, USHRT_MAX); } } =20 diff --git a/drivers/net/ethernet/google/gve/gve_utils.h b/drivers/net/ethe= rnet/google/gve/gve_utils.h index bf2e9a0adb36..c686142d37ea 100644 --- a/drivers/net/ethernet/google/gve/gve_utils.h +++ b/drivers/net/ethernet/google/gve/gve_utils.h @@ -25,7 +25,7 @@ struct sk_buff *gve_rx_copy_data(struct net_device *dev, = struct napi_struct *nap struct sk_buff *gve_rx_copy(struct net_device *dev, struct napi_struct *na= pi, struct gve_rx_slot_page_info *page_info, u16 len); =20 -/* Decrement pagecnt_bias. Set it back to INT_MAX if it reached zero. */ +/* Decrement pagecnt_bias. Top it up by USHRT_MAX if it reached zero. */ void gve_dec_pagecnt_bias(struct gve_rx_slot_page_info *page_info); =20 void gve_add_napi(struct gve_priv *priv, int ntfy_idx, --=20 2.47.3