From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202403; cv=none; d=zohomail.com; s=zohoarc; b=Rcf2eKG+PHl6jfG0TGLl6hrEW/M5U3MDCUHNbWbaMInUhaxVlaLwJ2yieCdN+gw69hA3KeG5MTbkZsTg5xiMPFHE3V1SZ4pf0PgsMTEUAwOn2tu9cnB9LsAv7gMDzBwUqcdm0sSAJz/islvJEHFOz63iM1D8LEj7SnI+UOKS4h0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202403; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cLiz4iKSk0iO00Jbp4tO8M/i0jukd0yN2q4d79rROSk=; b=djm7UwrToeWTGfSCpZW8g0+bTzJxfhbAh+8TKLBgDdf0qeVLdGRija+V4dtS/NeMdCnxX7eJYh0Pf58ZEPSIoDIDLrTgkgHm0RipLuU34XrOAcmuVbIwXLZ5acU9iYEFQm4qC8FsBXjv/AAlJN2omeTKF6A3/h7jbgpR1L3ZLpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202403512987.4918798511756; Sun, 8 Nov 2026 21:33:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzS-0006zB-OE; Mon, 09 Nov 2026 00:32:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz9-0006u6-5F; Mon, 09 Nov 2026 00:32:13 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006HT-L9; Mon, 09 Nov 2026 00:32:01 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtP046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:34 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=cLiz4iKSk0iO00Jbp4tO8M/i0jukd0yN2q4d79rROSk=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202294; v=1; b=akvnyCuKxOwgDvcAqXDANdK8WvBy19OiZJpJIVMwGy//1+VI4lVmEYYDawOBFH7N js37ESlDVF+kqn8Cmc3HCno08kfOE7nRyJpEuLNTeHIdzKmhUj8htjcMKsdiYywW fRzKJT7vlpKmb5FjgrCa78AnA3IYdJeDMW41OdHhEEjhuk2qmd63dICW8jAWkx0P rdIXvMse4yuqa5G9J6QBannfinHfPjSl27OygyonlFZmFhzP5pEwwwnrva0XLuI1 qJcJSOAnPvj+SKZJNbY7qdo3/v0p0ZcewdSK6RHUi0OmWwMcJ/rygoRz8TUxen/K qaIrZNYyQLjE3Yf9ZG7KhA== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:46 +0900 Subject: [PATCH v2 01/14] hw/net/net_rx_pkt: Handle bogus l4hdr_off when validating SCTP checksum MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-1-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2520; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=6AOMtftVXVnBrguVzdDQMUbU5LQT8baBDLpMNBZR74E=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqLnpndfXrHndr3KjyHmK30XWF2eyTrc77To+7ZpTo LNz+9GKjlIWBjEuBlkxRZaUot3cGtG1nwoT4ltg5rAygQxh4OIUgIlodTP8d5Uo1PdUk7/S6C9h ZSJ1+2JLh+/8k5vzRTYt/RlxZ+7hDEaGJwJOvq/PmPxY9ynT7oz0SeF13WXJZ2enHTfZmn137ak cNgA= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202405324158500 From: Peter Maydell In _net_rx_pkt_validate_sctp_sum() we calculate a checksum that starts at the NetRxPkt::l4hdr_off offset. If this offset (which might be guest controlled) is larger than the size of the packet, the loop that walks through the iovec can walk off the end of it. The resulting out-of-bounds read in attempting to convert the iov to a buffer might cause a segfault. We also weren't correctly checking the return values of iov_to_buf() and iov_from_buf() when reading and writing the checksum word: if the l4hdr_off claims the checksum word is half off the end of the packet these functions will return the count of how much data they were able to access, and we should fail if they don't write the entire 4 byte word. Return "checksum not valid" if the l4hdr_off is too large or the iov accesses don't do the full read/write. Note that this affects only the igb network device; the other user of this function (e1000e) does its own check on the l4 header and won't calculate a checksum if it's out of range. Cc: qemu-stable@nongnu.org Fixes: 907209e3111dd62 ("igb: Implement Rx SCTP CSO") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4138 Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- hw/net/net_rx_pkt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index f87b6f046ccf..03a35f03154d 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -549,19 +549,23 @@ _net_rx_pkt_validate_sctp_sum(struct NetRxPkt *pkt) uint32_t original; bool valid; =20 - for (vec =3D pkt->vec; vec->iov_len < off; vec++) { + for (vec =3D pkt->vec; vec_len > 0 && vec->iov_len < off; vec++) { off -=3D vec->iov_len; vec_len--; } + if (vec_len =3D=3D 0) { + return false; + } =20 csum_off =3D off + 8; =20 - if (!iov_to_buf(vec, vec_len, csum_off, &original, sizeof(original))) { + if (iov_to_buf(vec, vec_len, csum_off, + &original, sizeof(original)) !=3D sizeof(original)) { return false; } =20 - if (!iov_from_buf(vec, vec_len, csum_off, - &calculated, sizeof(calculated))) { + if (iov_from_buf(vec, vec_len, csum_off, + &calculated, sizeof(calculated)) !=3D sizeof(calculat= ed)) { return false; } =20 --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202381; cv=none; d=zohomail.com; s=zohoarc; b=mDylqptnwrM4PvsNQyu3Q0qY4yWKJYu+1hy1usShT85C/bNtzPQ/V+8Dkdcjkuv8n2nrjWPwE/F/qPOS9kf0oeas13l6PI/VysahnyPifQhNT3CEYlm4IR8Cv9ODGWiX1W8Jqe/nElDXWkW9T0q9CRk5newDpkcJUk9XSu6LZ0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202381; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=U56RFa7x+IaqujX2yXhRp/iTyAE2XXP/zdsjk8V6gXs=; b=DaRD/x+v18BpxFUkR+NA5D8qy8c8x1GfCSMl1i0UvtiP8+/9duHOxXDD2soEb/xcsxiEuwsXimhxyDw+XxpRxpqVZbAkBs2kAiji5sR5IKxz9ArmmuJa1WsKM2zard7AxV0UzdiueGMO6e7sVVOSOOySjD/cP+FGOQgqX7TIJG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202380122655.1591522110687; Sun, 8 Nov 2026 21:33:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzR-0006xN-GM; Mon, 09 Nov 2026 00:32:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz9-0006u1-3Z for qemu-devel@nongnu.org; Mon, 09 Nov 2026 00:32:07 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006HU-B4 for qemu-devel@nongnu.org; Mon, 09 Nov 2026 00:32:01 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtQ046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:34 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=U56RFa7x+IaqujX2yXhRp/iTyAE2XXP/zdsjk8V6gXs=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202294; v=1; b=mxqFRY0zX/inaoi9+gdTi+f0RM+MY9NMNzKNz7pT6jt22pphoAuy/+D9dCpSPUj9 ZgW//ohPLOmXXIY1uQKObnrS6fcnujw8fzAgfAnIDARdbRsCIBDEumLThYfETZP0 XzE0HIyzEbOEkG3wz7CfZGtlg81ro/EdbUJRiUyIJqU0eqSWdyb6y4QtPEuou+mi Y+wOyYV5IxYSKAlK34X4o4c8xJH6cQhdwN3JOFC85yUSDM9wJkqKZ7dQl3qFMVTT mye7pw+tJ+wBEGbV764PSdh6PwdLyJh8aPInKP7TToGCMTyZ4pWCg9Hv6SI49ioz IeQOa+I26R+qcRA0WkbEIA== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:47 +0900 Subject: [PATCH v2 02/14] net/eth.c: Check for undersized L2 headers in eth_get_protocols() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-2-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1432; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=czsctkVOkFfXgtnSRXWt556uIZ6EbzX2ykTov13/Gfk=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqLlTF55bphTEUtj3+dtF3hNH96Q5q0nuaTvUopywt CRFSe94RykLgxgXg6yYIktK0W5ujejaT4UJ8S0wc1iZQIYwcHEKwER+tjD8L7FsL+otlw/TEjw1 xzN8rxp/x5eZFu8KuA3f7v7bdGzDVYbfbEFP9wjOPeZxV2NSOH+TW8BrQ7u9r05PFGNqsuktCjr CDwA= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202388518158500 We already have some header bounds checks. Add a missing check for L2 headers. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- net/eth.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/net/eth.c b/net/eth.c index 12ec316e240e..59b278b887c1 100644 --- a/net/eth.c +++ b/net/eth.c @@ -139,21 +139,28 @@ void eth_get_protocols(const struct iovec *iov, size_= t iovcnt, size_t iovoff, bool fragment =3D false; size_t input_size =3D iov_size(iov, iovcnt); size_t copied; + uint32_t hdr_size; uint8_t ip_p; =20 *hasip4 =3D *hasip6 =3D false; - *l3hdr_off =3D iovoff + eth_get_l2_hdr_length_iov(iov, iovcnt, iovoff); l4hdr_info->proto =3D ETH_L4_HDR_PROTO_INVALID; =20 + if (input_size < iovoff) { + return; + } + + hdr_size =3D eth_get_l2_hdr_length_iov(iov, iovcnt, iovoff); + if (input_size - iovoff < hdr_size) { + return; + } + + *l3hdr_off =3D iovoff + hdr_size; + proto =3D eth_get_l3_proto(iov, iovcnt, *l3hdr_off); =20 if (proto =3D=3D ETH_P_IP) { struct ip_header *iphdr =3D &ip4hdr_info->ip4_hdr; =20 - if (input_size < *l3hdr_off) { - return; - } - copied =3D iov_to_buf(iov, iovcnt, *l3hdr_off, iphdr, sizeof(*iphd= r)); if (copied < sizeof(*iphdr) || IP_HEADER_VERSION(iphdr) !=3D IP_HEADER_VERSION_4) { --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202438; cv=none; d=zohomail.com; s=zohoarc; b=bYdFKqr/2pKSQoQHXi4XxMJMCR6rKSW/xhFgWN1QT+taXGzYVdSA8syLgUdfZf3D4iXrYyWxlAnLbWBbLAyQUijDp+80E8gVmA7v+jrnDuhFhPF19Qn07naZQdXhWlxRlOT0UXswN3bP6pX910qe8i4iL6Zvm8vrTjd65DxV638= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202438; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SrGQealLyH3hg42u+EWDOoemyLjrZmzhxYj9oW/6TSU=; b=VdMalgf728dYx4Ov5SUYdYgxa7//Ivr0qv3yWu75rIOPxwRVO2B+OodXaMBPgv7iZmmJ9/r2cqXCNJruSwac/rZxae21lFU5tuKLJQHqtEb3UMHvpbWmqhxZ7ZPye5TD0ELIdBL/eLQdaWHt00n/df0YkRZqWQnkWB9H0sq0qmg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202435919238.44344831390492; Sun, 8 Nov 2026 21:33:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzY-00072C-LU; Mon, 09 Nov 2026 00:32:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz9-0006u2-42; Mon, 09 Nov 2026 00:32:07 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006HQ-EE; Mon, 09 Nov 2026 00:32:00 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtR046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:34 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=SrGQealLyH3hg42u+EWDOoemyLjrZmzhxYj9oW/6TSU=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202294; v=1; b=DWbNZUrkVAJdoaW2GYb7bobpHVt3z31IvkfyRdbG7NICY1qghrBvporklc3r3EX9 19JZ7GzLYUnLAL2hxmWVJNSQorvYioQeGUQjscu1YHSnqC1yN1K8FF0xwXeNG/z3 Z/2+vc0iZuUULWaEYM6BrDl87ITeP6hb5kgvoVuAAuNvax6lAMTL+xUhRhdzBk+7 P6iMrjZHNWchOmHeTuAv19dofF4BNUvJuofdmbsTL6zzKm+gU0CMa/0YaZhRQz6I +IWY3jek3ml4HU2OnepXJiHpRk3goFeraS1tUSfXxlXIRnulPICg7N89IDyTnBuL kFKtXymBFEKPZn4gcRmpKw== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:48 +0900 Subject: [PATCH v2 03/14] net/eth.c: Check for undersized IPv4 headers in eth_get_protocols() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-3-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1569; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=yESB8Zab4os/s1R62J8xq9PMyiu3eYpATt16sW8tdWY=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqHnfP94W5DxQyaD1iMGsOu2TB/v9XN0NF018Vsy8M Oe+DlNsRykLgxgXg6yYIktK0W5ujejaT4UJ8S0wc1iZQIYwcHEKwESWbWZkuHCdxTz4YiSf8RGv j7KvxU6v63vJoxDV+HXFjo+n33SsUWNkWOHAFbTgqtX+hbypEaau6zUYFy1qu3FDIYyn/GDLhp9 bWQA= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202441837158500 From: Peter Maydell In the IPv6 path of eth_get_protocols(), eth_parse_ipv6_hdr() does various sanity checks on the packet's IPv6 header, so we won't tell the caller we have an IPv6 header when we have a malformed one. However for IPv4 we only check the version and that we have at least the minimum header size. Harden this codepath by checking also that the header size declared in the packet's own headers is neither smaller than the minimum nor larger than the actual packet size. Missing these checks shouldn't cause problems if the caller is validating all offsets and lengths before use, but checking here too is defence-in-depth, hence the cc to stable. Cc: qemu-stable@nongnu.org Fixes: 69ff5ef847457555 ("net/eth: Report if headers are actually present") Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- net/eth.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/eth.c b/net/eth.c index 59b278b887c1..038f7d889c33 100644 --- a/net/eth.c +++ b/net/eth.c @@ -163,6 +163,8 @@ void eth_get_protocols(const struct iovec *iov, size_t = iovcnt, size_t iovoff, =20 copied =3D iov_to_buf(iov, iovcnt, *l3hdr_off, iphdr, sizeof(*iphd= r)); if (copied < sizeof(*iphdr) || + IP_HDR_GET_LEN(iphdr) < sizeof(*iphdr) || + input_size - *l3hdr_off < IP_HDR_GET_LEN(iphdr) || IP_HEADER_VERSION(iphdr) !=3D IP_HEADER_VERSION_4) { return; } --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202461; cv=none; d=zohomail.com; s=zohoarc; b=Sbp/Gp9ZEhkejewiucSzAK1ph9DWU3nCaQv+N/N0J9ORIdSS7P7pS8qdTNOnxV9WvqQXjFiIA5gfFw4l4kCLD26hVK07U7suHTBVXQR+Gp8gR7okbUi4wbpRgDZo9+LS0ODGfja04Itrr3e5psfBi1eSHYHY6J9NdApijzdDZYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202461; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1PWPfSpTpsQUoLM2IbhyYtO/CHho/MAxAEO2lE99/uU=; b=g5EHWp7meZSosSpm00C9gW/0/kiur+HEXlhqQy3JlBmCyTxIFhrlvVeynJ4QlH6wfPgimr9I3ktFheF1DmjoNHxjdGouM29bY97mlEoXUUrcqXkRs1ZfNAgnBnw8uBdw7a66dyQ0beXwdOHZ/RjlFNXGWzVSfI6HlUdMlv200mk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202461977807.5442822830177; Sun, 8 Nov 2026 21:34:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzc-00073o-Jx; Mon, 09 Nov 2026 00:32:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz9-0006u3-4I; Mon, 09 Nov 2026 00:32:07 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006Ha-Nw; Mon, 09 Nov 2026 00:32:02 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtS046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:34 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=1PWPfSpTpsQUoLM2IbhyYtO/CHho/MAxAEO2lE99/uU=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202295; v=1; b=X7kUQ7IBw0FRm3QZjW0CvRrp+oqiR4bHgD0+5f1Pzf0B9A3DNOD8C52iJBpyCR6n wKG/tG23DDoqb//tE5eTE64TWzAwmDFOPey3v2rkT4dk3hKWQiyHWiqqqN33u7/R na3LqeAJ18PMlnMNbt9b4McqMCvXBLhZmYArCG+IxJtKOEqdlMSZS0laN0BJHmX6 XdN1Josw8ZEvlj9Kcrsa21voJ99P5ydoAtSHJMu0MmLnvwi3vylUMpzGKyQd7uId wTi7RD4m/Jq7ItYZStgS/q7mJLm7c0lEIG4qGcA2z5GKOuqj4UGlKzd9PRwDGSmP kzDuaZRw0VtIQCtZPzF7hg== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:49 +0900 Subject: [PATCH v2 04/14] net/eth.c: In eth_get_protocols(), don't report TCP data offset off end of packet MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-4-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1193; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=xBUF+wGLcCflMruqyziIwNETSXIzU8t31Fp6gufY6wo=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqPlL62xaV08Jc/5fIt9jp3gl4Rf7DcveHyW/gvZxi ztNbVvbUcrCIMbFICumyJJStJtbI7r2U2FCfAvMHFYmkCEMXJwCcJNdGBl655gv/l6x5YRvOfPO CZts7iWYrnse279DT/d8Def1k0JbGf6XdZyfe0eZ93f+2zunlAqfhNuYnb7H3FT57Ai7/bYFRRO YAQ== X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202464159158500 eth_get_protocols() already rejects some out-of-bounds offsets found in packets. Add a missing check for TCP data offset. Fixes: eb700029c783 ("net_pkt: Extend packet abstraction as required by e10= 00e functionality") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4155 Cc: qemu-stable@nongnu.org Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- net/eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/eth.c b/net/eth.c index 038f7d889c33..a444377fd0ae 100644 --- a/net/eth.c +++ b/net/eth.c @@ -197,7 +197,8 @@ void eth_get_protocols(const struct iovec *iov, size_t = iovcnt, size_t iovoff, if (_eth_copy_chunk(input_size, iov, iovcnt, *l4hdr_off, sizeof(l4hdr_info->hdr.tcp), - &l4hdr_info->hdr.tcp)) { + &l4hdr_info->hdr.tcp) && + input_size - *l4hdr_off >=3D TCP_HEADER_DATA_OFFSET(&l4hdr_inf= o->hdr.tcp)) { l4hdr_info->proto =3D ETH_L4_HDR_PROTO_TCP; *l5hdr_off =3D *l4hdr_off + TCP_HEADER_DATA_OFFSET(&l4hdr_info->hdr.tcp); --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202415; cv=none; d=zohomail.com; s=zohoarc; b=WRL1KjjnHDqoDW4mKDrfXBbH+Q30LF5dEgz7gskxUf9ZVAL/mN9406XX6SylNvwkciASxDt45VjLHSz8+icfBpbgX0e2W7k7fFUXJ/m5auPmtLrz5vPEmqjGxezSAZy13mxB28vZ8tgoTOmrkQfz+AEsWCh8VqyAT99FV5GRn/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202415; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nS68T1K5GUo+z5Wjd++UxQEFBoXWihDWYIw4jTHswF8=; b=CUeh/OuQ/CwLLCtavFm39HFaocs+rXKQCKjLn52sIR5zCX3d2ThIvbWSbrdQYX3b0POFQAxC0POtOJ1Ve501GKTjp7TrZ4ROrnYfqEqcrB2jhF1i/eDLEEDuqDmo2pTuGAV6xIa6egOhPZo61snsJFXDn/bt+pjbEtacWAVGcKE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202415564747.7743277579829; Sun, 8 Nov 2026 21:33:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzh-00075i-Dw; Mon, 09 Nov 2026 00:32:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzA-0006uE-WA; Mon, 09 Nov 2026 00:32:15 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006HR-Mf; Mon, 09 Nov 2026 00:32:03 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtT046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:35 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=nS68T1K5GUo+z5Wjd++UxQEFBoXWihDWYIw4jTHswF8=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202295; v=1; b=INupjwy8cJfbcV5P+coDWeiSIvXTPX5FI8b0S9SKZQggsvZ+z8mscAL/wZiB6Ezr U6URNaWvu3Qp8/RqLBhHgBt8MISTcq1YpzkBmqhRAQ/W9P5uyQRFQAPsgixeUrWh LHNTidAp4Jyp11U4ROkybO332CjNWvxtp3npuEdbruhuoN8AkiDxGDGmehnlfO7K Fsij6gRIdmc7aGCKH35GqhzTf95yVJERgX9J8GwKEIO9LasHgEzttrTzdEHo+5fS oSKY51LL5ac210/O8DGI5U2fQ/Z6nPCGsZpCgURDz8JqbIE9zFyvFCUekItD9NJZ gIf7RAC52jO8qPDicN2Jdw== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:50 +0900 Subject: [PATCH v2 05/14] net/eth.c: In eth_get_protocols(), don't report SCTP header off end of packet MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-5-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2498; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=GCsYSzzEBAWyDhzuwEVw27E2a4WMsyhsSjArDIzihX0=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqMXn5R6tOxS15ihfTvyDvMhjvy8ejK4Mk/9epugmv Ohm6qnjHaUsDGJcDLJiiiwpRbu5NaJrPxUmxLfAzGFlAhnCwMUpABMJfcbwV8QxU3rxr5zA21qi K07dsT6//fWlNwELziue0DmfYeNb+pzhn8LmPC1rD+uQmxKduiJRDWfz9WeurovvSz7yaomtZfh JDgA= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202417499158500 From: Peter Maydell eth_get_protocols() parses an ethernet packet and tells the caller about various offsets into it and other properties of the packet. For the L4 protocol, in both the IP_PROTO_TCP and IP_PROTO_UDP branches we implicitly check that the packet does contain a whole TCP or UDP header at the l4hdr_off offset, because _eth_copy_chunk() will fail if the input packet size isn't big enough for the whole header we are copying out of it. But for IP_PROTO_SCTP we don't copy the SCTP common header. In this case we should still do the length check, so we don't set l4hdr_info->proto to say there's an SCTP header present when there isn't. This shouldn't have any visible effects if the downstream consumers of the l4hdr_info are conservative about checking before they access into the packet, but checking here too adds defence in depth, hence the cc to stable. Cc: qemu-stable@nongnu.org Fixes: 907209e3111d ("igb: Implement Rx SCTP CSO") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Akihiko Odaki [Reversed the condition and changed it to use input_size - *l4hdr_off] --- include/net/eth.h | 2 ++ net/eth.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/eth.h b/include/net/eth.h index 46dc9ed5acd9..e10684ed9234 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -394,6 +394,8 @@ typedef struct eth_l4_hdr_info_st { bool has_tcp_data; } eth_l4_hdr_info; =20 +#define SCTP_COMMON_HEADER_LEN 12 + void eth_get_protocols(const struct iovec *iov, size_t iovcnt, size_t iovo= ff, bool *hasip4, bool *hasip6, size_t *l3hdr_off, diff --git a/net/eth.c b/net/eth.c index a444377fd0ae..55d85cecd1d6 100644 --- a/net/eth.c +++ b/net/eth.c @@ -223,7 +223,14 @@ void eth_get_protocols(const struct iovec *iov, size_t= iovcnt, size_t iovoff, break; =20 case IP_PROTO_SCTP: - l4hdr_info->proto =3D ETH_L4_HDR_PROTO_SCTP; + /* + * We don't copy the SCTP common header into l4hdr_info, but + * don't report SCTP as present if the packet isn't big enough + * to actually have an SCTP header. + */ + if (input_size - *l4hdr_off >=3D SCTP_COMMON_HEADER_LEN) { + l4hdr_info->proto =3D ETH_L4_HDR_PROTO_SCTP; + } break; } } --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202554; cv=none; d=zohomail.com; s=zohoarc; b=cw6hyKyMqk4aakbM6WHrZ/CfJgf/DmIN8QuVCuwhT2nHsGHedYB1bh76/gU0AbQn8losKkWmTylA/I4IfMH5YIinr7OpsS5RjFwVtA85j8TtnRsov0sL4wjTCQOo2hW1ckzywHYQH/6R8JcR8gTuaDys9bRGhpuJY7pnITQ5K80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202554; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2YZ5lsUQbliaXH9gSRAgRrIfi5uICm2+yllFRphNaD0=; b=eiLPvP11NVdTkWZGW2Ztp03z/keBzSIh9wxEEd1A6bEeVNL5DNtbBH/GI+DgvB0f65VDDUR+VY6WtMMVYACv2fBImlxmPRC0cFh0czlabrncDoCz/KXU5yFeIZO4/qeDo+ly1zh4Mvc+7COKRtlE2H4T9acBkWmoHR1O0iPa7DY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202553985826.6809759263857; Sun, 8 Nov 2026 21:35:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzW-00070k-Jl; Mon, 09 Nov 2026 00:32:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzA-0006uD-Jz; Mon, 09 Nov 2026 00:32:13 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006Hy-Ma; Mon, 09 Nov 2026 00:32:03 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtU046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:35 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=2YZ5lsUQbliaXH9gSRAgRrIfi5uICm2+yllFRphNaD0=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202295; v=1; b=KOvBcO1YvcB6GaTay4FCPsUPleOWAOVqAIUgFsik9VOLjahn+Su2YE9enbRRprwO QDT9deuA0KNoaDZbadEfjKVgzRBqDYceA4RS0gNQyqtB4Z5JNAgfsvIKJIOmspJB DQjoLxl5cOH5wnPGctnmYVD/63YfvSqP3RGjMS73kNzUSMDPfNbGIVOG0iHsn/Rp kz6tZuFj4rvQ50Ur0+XKqlHL5g64AtFIzW6SrlWSq01FFpkRDwDMNQHEO8vpiVxh C5paC9HqndoFc4DYQCx0nA6pWTOm4lRj/Ses0zqLYK61gnA4gujZv82df2hBfict Z2nKr+sQGHBXk6XaC/iJ2w== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:51 +0900 Subject: [PATCH v2 06/14] net/eth.c: In eth_parse_ipv6_hdr(), fix check of input size MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-6-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org, Lazymio X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5849; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=5o0B0rhTWpkt2UipV4PHIfwO3xnoQvhtLsHZm/dsLuc=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqMV8Ow7cW/o+IZWhxzCrRnDGhyO9D456RdxbmDB/m qjL1g7RjlIWBjEuBlkxRZaUot3cGtG1nwoT4ltg5rAygQxh4OIUgIks+s/wzz7vYeOPsLA3Oec3 KlT9Zc+5wHi6sT/O81/JyWNudvfvPGRk+He79JPDTN/1u85+lRCdt9xIYeHDk9fXmV/p4e1z0r9 ymxEA X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202555561158500 We already have some L4/L5 header bound checks. Add the missing coverage for IPv6. The IPv6 header parser incorrectly derives L4 offsets greater than actual values. Adding a bound check without fixing it would reject valid packets while fixing it without adding a bound check can result in an out-of-bounds access, so fix it along with the bound check addition. One fixed problem of the parser is that extension header size is not properly computed for the Fragment Header and the IP Authentication Header. RFC 8200 "Internet Protocol, Version 6 (IPv6) Specification" section 4.5. "Fragment Header" says the Fragment Header has a fixed size. The byte represented by ext_hdr.ip6r_len is reserved and "ignored on reception". RFC 4302 "IP Authentication Header" section 2.2. "Payload Length" says it specifies the length of AH in 32-bit words (4-byte units), minus "2". Another fixed problem is that the parser continues parsing extensions in noninitial fragments. RFC 8200 "Internet Protocol, Version 6 (IPv6) Specification" section 4.5 "Fragment Header" says the noninitial fragment packets have the Fragment Header containing "the Next Header value that identifies the first header after the Per-Fragment headers of the original packet" followed by "the fragment itself." Therefore, the data following the Fragment Header in the noninitial fragment packet must be treated as a fragment instead of another extension header, regardless of the Next Header value the Fragment Header contains. Fixes: eb700029c783 ("net_pkt: Extend packet abstraction as required by e10= 00e functionality") Fixes: 75020a702151 ("Common definitions for VMWARE devices") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4155 Cc: qemu-stable@nongnu.org Reported-by: Lazymio Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- net/eth.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---= -- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/net/eth.c b/net/eth.c index 55d85cecd1d6..ba0e964b97b8 100644 --- a/net/eth.c +++ b/net/eth.c @@ -16,6 +16,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "qemu/log.h" #include "net/eth.h" #include "net/checksum.h" @@ -473,7 +474,9 @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int pk= t_frags, struct ip6_ext_hdr ext_hdr; size_t bytes_read; uint8_t curr_ext_hdr_type; + uint16_t buf; size_t input_size =3D iov_size(pkt, pkt_frags); + bool subsequent =3D false; =20 info->rss_ex_dst_valid =3D false; info->rss_ex_src_valid =3D false; @@ -513,25 +516,73 @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int = pkt_frags, return false; } =20 - if (curr_ext_hdr_type =3D=3D IP6_ROUTING) { + switch (curr_ext_hdr_type) { + case IP6_ROUTING: if (ext_hdr.ip6r_len =3D=3D sizeof(struct in6_address) / 8) { info->rss_ex_dst_valid =3D _eth_get_rss_ex_dst_addr(pkt, pkt_frags, ip6hdr_off + info->full_hdr_l= en, &ext_hdr, &info->rss_ex_dst); } - } else if (curr_ext_hdr_type =3D=3D IP6_DESTINATON) { + info->full_hdr_len +=3D (ext_hdr.ip6r_len + 1) * IP6_EXT_GRANU= LARITY; + break; + + case IP6_DESTINATON: info->rss_ex_src_valid =3D _eth_get_rss_ex_src_addr(pkt, pkt_frags, ip6hdr_off + info->full_hdr_len, &ext_hdr, &info->rss_ex_src); - } else if (curr_ext_hdr_type =3D=3D IP6_FRAGMENT) { + info->full_hdr_len +=3D (ext_hdr.ip6r_len + 1) * IP6_EXT_GRANU= LARITY; + break; + + case IP6_FRAGMENT: + bytes_read =3D iov_to_buf(pkt, pkt_frags, + ip6hdr_off + info->full_hdr_len + 2, + &buf, sizeof(buf)); + if (bytes_read < sizeof(buf)) { + return false; + } + + /* + * Per RFC 8200, the Fragment header does not have the Hdr Ext= Len. + */ + info->full_hdr_len +=3D 8; + info->fragment =3D true; + + /* + * Detect a subsequent fragment per RFC 8200. + * + * A subsequenet fragment contains no extension headers while = the + * Next Header value identifies the first header after the + * Per-Fragment headers of the original packet. + * + * The subsequent fragment is detected by checking if the Frag= ment + * Offset is nonzero. + */ + subsequent =3D extract16(be16_to_cpu(buf), 3, 13); + break; + + case IP6_AUTHENTICATION: + /* + * Per RFC 4302, the Authentication Header has the Payload Len + * instead of the Hdr Ext Len. The Payload Len specifies the l= ength + * of AH in 4-byte units. + */ + info->full_hdr_len +=3D (ext_hdr.ip6r_len + 2) * 4; + break; + + default: + info->full_hdr_len +=3D (ext_hdr.ip6r_len + 1) * IP6_EXT_GRANU= LARITY; } =20 - info->full_hdr_len +=3D (ext_hdr.ip6r_len + 1) * IP6_EXT_GRANULARI= TY; curr_ext_hdr_type =3D ext_hdr.ip6r_nxt; - } while (eth_is_ip6_extension_header_type(curr_ext_hdr_type)); + } while (!subsequent && + eth_is_ip6_extension_header_type(curr_ext_hdr_type)); + + if (input_size < ip6hdr_off + info->full_hdr_len) { + return false; + } =20 info->l4proto =3D ext_hdr.ip6r_nxt; return true; --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202392; cv=none; d=zohomail.com; s=zohoarc; b=EMoweOMK5yB75AJf3RBU3MFk54Qy6inwzpqFC+2/KHHOdCouJSrXkfxFEDEameDrcJIsRiRqH8X3KmguC5koLvfP0nenq173Q1Mi6YMcj2v0p6YFfEATAtTmQTl98f/3lu1OLGrlt0qI9PLDR1KXviIKOXNXkUFE2avq3ufqcUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202392; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PPjtMe7/DOEseSjjnqmeEol8IGuh2LwrK+JxTc9S1SU=; b=CNKamV1PdXGZn7PuVYAgAR6lIW6YcluVedIhS8S/+umJCnueCSCuTW/27n8RW93qzRbxU6QAazFH0dgmpfug4GjwcE1ALbC8mGmaU7EuwaHox/oBjgYZuWyCocLDWd3oFMMTtBy6mmvgjXDFrepeTNdlhSnF0JUI9jMgnUS38HA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202392654568.407705473103; Sun, 8 Nov 2026 21:33:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzZ-00072i-DC; Mon, 09 Nov 2026 00:32:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz9-0006u0-30 for qemu-devel@nongnu.org; Mon, 09 Nov 2026 00:32:07 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006HS-1A for qemu-devel@nongnu.org; Mon, 09 Nov 2026 00:32:01 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtV046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:35 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=PPjtMe7/DOEseSjjnqmeEol8IGuh2LwrK+JxTc9S1SU=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202295; v=1; b=I6dzi/qjd7YJXxws1teN/NO40ba/ve9uX+5D28Wlk74hRyBFSdMry50BCDhSF0kO NM/0pzzfe5rTy3Yaw5LCMUI5NAokgVTAvEitCI0N75J5+j0CTR2+kx9P/gv2mAvf hxXjaZhY1uzyk3baqiGtXlqU4ZppEHJtobJ1mObUmZaPe15f/kvS72HMFIbrAW82 TpDYHqPrusqQTIMs7VyA0J5mzrzhqk2Qydvv9Nz0eC0TyzBCznt4fHOvGh8gWPZT 7ALrO3EPtlFCP8V3iK9OKPy9+xLHDmtjxMdiGt54VJwVmtFAqQgJ9A4tR/hLTqQ9 jm11IsT+D9Sfydkra7ysYQ== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:52 +0900 Subject: [PATCH v2 07/14] net/eth.c: Move the Routing Header Hdr Ext Len check MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-7-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1942; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=9F0P3hUuonhELThFf7z0bn/d/7sKXmyNZ4/5qZE/lL8=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqCVq16ZmLA1WLI9vj9TiTctYscVSdLFgcJnuk8wr/ H7liW86SlkYxLgYZMUUWVKKdnNrRNd+KkyIb4GZw8oEMoSBi1MAJuJUysiwNGXGI25/jW12m/7b vL1VJhgucvvxG4v1y2Z131774dn9NQz/dCOuNIlInvM+p7vviDPvrC0rps3L8olOE/fo9pczWH6 KDwA= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202395161158500 RFC 8200 - Internet Protocol, Version 6 (IPv6) Specification section 4.4 [1] says the Routing Header length depends on the Routing Type, so place the checks of the Hdr Ext Len and the Routing Type together. [1] https://datatracker.ietf.org/doc/html/rfc8200#section-4.4 Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- net/eth.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net/eth.c b/net/eth.c index ba0e964b97b8..0c3b4e784a59 100644 --- a/net/eth.c +++ b/net/eth.c @@ -407,7 +407,8 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int p= kt_frags, bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset, &rt_hdr, sizeof(rt_hdr)); assert(bytes_read =3D=3D sizeof(rt_hdr)); - if ((rt_hdr.rtype !=3D 2) || (rt_hdr.segleft !=3D 1)) { + if (rt_hdr.len !=3D sizeof(struct in6_address) / 8 || + rt_hdr.rtype !=3D 2 || rt_hdr.segleft !=3D 1) { return false; } bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(rt_h= dr), @@ -518,12 +519,10 @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int = pkt_frags, =20 switch (curr_ext_hdr_type) { case IP6_ROUTING: - if (ext_hdr.ip6r_len =3D=3D sizeof(struct in6_address) / 8) { - info->rss_ex_dst_valid =3D - _eth_get_rss_ex_dst_addr(pkt, pkt_frags, - ip6hdr_off + info->full_hdr_l= en, - &ext_hdr, &info->rss_ex_dst); - } + info->rss_ex_dst_valid =3D + _eth_get_rss_ex_dst_addr(pkt, pkt_frags, + ip6hdr_off + info->full_hdr_len, + &ext_hdr, &info->rss_ex_dst); info->full_hdr_len +=3D (ext_hdr.ip6r_len + 1) * IP6_EXT_GRANU= LARITY; break; =20 --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202495; cv=none; d=zohomail.com; s=zohoarc; b=m13lk+Gq0aHBHTbtikhKzDGmF899J2Y32VWW7937Vg4Az/JrveOcXK55GTbTThMsIOIE7PwpdnIDGGdSObWI7pvPbQCVGYT3ZdpkR/Brg4Rx5dVn2/trSGShHSfWcic85quaMJZuLDP5mUM9eA7PEfc/HITgu9vh/83FwmplMoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202495; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aEnGXpb/Ee4i8OiDpAQ1ZXhwkNY6p0+wMl0QVYOr3B8=; b=k1zI9Cl3QTlRLj3ydg4nOyxI+rSzC0NYRvbapzlpNPV1aatNFc+IiCui+Zede39LRLQ1K+SuAYyPIOksv+sE0A8uZZ53UN7ek2gP+VxBtwo/br2DO2uQ4i20926XSHzuw4qyeXbWVY6tVhbUm/6b3t3MXmITo9ekJZUe9FOPpCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202495335137.85087257192765; Sun, 8 Nov 2026 21:34:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzf-000758-8l; Mon, 09 Nov 2026 00:32:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzK-0006ui-R4; Mon, 09 Nov 2026 00:32:15 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzG-0006Hd-Ld; Mon, 09 Nov 2026 00:32:14 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtW046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:35 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=aEnGXpb/Ee4i8OiDpAQ1ZXhwkNY6p0+wMl0QVYOr3B8=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202295; v=1; b=jTWI/o2FVpo5lXL7PzLHYOtJDf9obGRsDtbuN0uZnGCmBUdYHwC9bK6YmI7AsFEN iKIDxe494R0N+0T8vKnaSgwl1vkjl3SjPk1jufI6Hdc2diOi55y9Xotjz6UiG0w5 e2jKzuIFlXVYvJUe3TYV6opt7BpqSM6wgQjflEl5OuYOJAeBsTpVV5zF0k8DQiCx OHCfyyTNbNv8fPNS+hrsxm4aVQpfH2jmUG0e1keTha7LcJhi5yepQ/o9pUEo4f54 AdSFtRe58g0BZUucY04bGJE7Uj2aN9vkCz3VxyM7A/CwbrnPhQVM6ICn0o5QIrU2 Xq0hmI2KlhsrGCwpemBzqg== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:53 +0900 Subject: [PATCH v2 08/14] net/eth.c: Harden _eth_tcp_has_data() against short lengths MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-8-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1896; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=qZ/eQ/j7cwwgbqiXWSNZLjgYeicLWHF//8GM+cIaK04=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqKWb62tn9v95t1BMZYK38aunXw/f3X/z5ZPC8mlvN 5ZWhu8o7yhlYRDjYpAVU2RJKdrNrRFd+6kwIb4FZg4rE8gQBi5OAZhI3llGhku18wLjr7ns3cNw d/K6Bc6eflJ10w2O++le2HL1/vd+vSWMDMuONftuytxsGeV8e67g7t2Ht8z5O/XcHpaZS5Iv7yz Zu5gJAA== X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202496627158500 From: Peter Maydell In _eth_tcp_has_data() we calculate the length of the rest of the packet after the ipv4 header by subtracting the header offset from the packet length. If this subtraction underflows we'll return the wrong answer. This shouldn't cause any problems if other layers of the code are checking lengths and offsets, but defence-in-depth suggests doing a checked-subtraction and returning "has no data" if the subtraction underflows. Cc: qemu-stable@nongnu.org Fixes: eb700029c783 ("net_pkt: Extend packet abstraction as required by e10= 00e functionality") Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- net/eth.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/eth.c b/net/eth.c index 0c3b4e784a59..749866094fa1 100644 --- a/net/eth.c +++ b/net/eth.c @@ -118,10 +118,20 @@ _eth_tcp_has_data(bool is_ip4, uint32_t l4len; =20 if (is_ip4) { - l4len =3D be16_to_cpu(ip4_hdr->ip_len) - IP_HDR_GET_LEN(ip4_hdr); + if (usub32_overflow(be16_to_cpu(ip4_hdr->ip_len), + IP_HDR_GET_LEN(ip4_hdr), &l4len)) { + /* packet too short for claimed IP header: no data */ + return false; + } } else { size_t opts_len =3D full_ip6hdr_len - sizeof(struct ip6_header); - l4len =3D be16_to_cpu(ip6_hdr->ip6_ctlun.ip6_un1.ip6_un1_plen) - o= pts_len; + uint64_t l4len_64; + if (usub64_overflow(be16_to_cpu(ip6_hdr->ip6_ctlun.ip6_un1.ip6_un1= _plen), + opts_len, &l4len_64)) { + /* packet too short for claimed IP header: no data */ + return false; + } + l4len =3D l4len_64; } =20 return l4len > TCP_HEADER_DATA_OFFSET(tcp); --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202481; cv=none; d=zohomail.com; s=zohoarc; b=iw4isMX/n6tKcA1KW+41sIUYq2XKQ38Sk6vkeWbazAm8VDaQYOD8nv2DXpWBYdGJxNCZGdFkTzk5xuhonXBUIXIVJm321st2TMjKTbmOMCPv6EpomfvtdLxtplzyeC45EeShXlFwJ5e/v+xBPwkjgk5N2XnlWiOmj+zB6Md06V4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202481; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hgsLZVIzqN1s0ptlMlimjKPYT6F6BOVi3Flo+YBsffY=; b=g0mfO0hnmkiHwDiqqaSWmEfjqGALpGtAw2wbYQM9FUcuigejAQGqxfKx64n8/1U2eBzLZgOk7r+5Qvm+krgX3ytovmWIklxsulUPfimyw58+N0wmbxzVRxY8G+sqTi5Bsq0cr87zaRXsPklhgDnQy7ohthkp0rL9e0OZYSnZriY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202481360515.4022095444697; Sun, 8 Nov 2026 21:34:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzZ-00072q-Fa; Mon, 09 Nov 2026 00:32:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz9-0006u5-58; Mon, 09 Nov 2026 00:32:07 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006HP-M2; Mon, 09 Nov 2026 00:32:01 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtX046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:35 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=hgsLZVIzqN1s0ptlMlimjKPYT6F6BOVi3Flo+YBsffY=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202296; v=1; b=nXpRvGJ2EHeBP32BpdycoWcqvn8EgaVtQ9ZuHON0Yiy0N7FSdIO9a5ryi9vdOg4k MGyoaH6ibwLzV3h/Rw8foxsjRkS0wX1TpKjmOGqiZDOOH4+lTu5UUYt7FZRupXJt vc2+EJaIo1RP7jyosmxyqUOTzrlgjjch/oE4yGv3EoFFwmV+kRrkjVEumcLyZSem nVqWM7F/BrvVouIcX2xltFCdsuM+DpfEB3DhF858LI/lH974FbAcJhHEGS1Bu4E7 pGYWeAlz2M3xzUDdGZYQ1KYGUgBmWhmVGg//yXkhSIkT52nN270IvzKevEWZndIx QU6stbry6t5pjPQVbKSZ2A== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:54 +0900 Subject: [PATCH v2 09/14] net/eth.c: Tighten size checks in eth_get_l3_proto() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-9-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1695; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=XaT4vcW7ec9yi3UiWa06GbFMZOjuqjipeNY2z1NjG8w=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqKXvqjPu2YfGJD83OuD++EHYhSViCm+WCE64Jb3j9 dueF9K7O0pZGMS4GGTFFFlSinZza0TXfipMiG+BmcPKBDKEgYtTACYSW8TIMElb5P28a38unooK rbv1dgnnx5z+c4YnnzLYtfmJ3yzedJCRYbWCl9q59Pavv1cYslq++NFxoaJ0Q2PA4nUiL8/+tEr M4QYA X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202482468158500 From: Peter Maydell Currently eth_get_l3_proto() has a check that the offset of the protocol field is not off the end of the iovec; this is actually unnecessary because iov_to_buf() guarantees to return 0 for offsets off the end of the iovec. On the other hand, it assumes that the l2hdr_len it is passed is not so small that the protocol offset calculation underflows and it doesn't check that the packet is actually big enough for the l2hdr_len. This shouldn't matter if other parts of the code are checking, but for defence in depth we tighten this check. Cc: qemu-stable@nongnu.org Fixes: eb700029c783 ("net_pkt: Extend packet abstraction as required by e10= 00e functionality") Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- net/eth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/eth.c b/net/eth.c index 749866094fa1..c8ecf6d6dc73 100644 --- a/net/eth.c +++ b/net/eth.c @@ -75,11 +75,13 @@ eth_get_l3_proto(const struct iovec *l2hdr_iov, int iov= cnt, size_t l2hdr_len) uint16_t proto; size_t copied; size_t size =3D iov_size(l2hdr_iov, iovcnt); - size_t proto_offset =3D l2hdr_len - sizeof(proto); + size_t proto_offset; =20 - if (size < proto_offset) { + if (l2hdr_len < sizeof(struct eth_header) || size < l2hdr_len) { + /* We don't have a complete ethernet header */ return ETH_P_UNKNOWN; } + proto_offset =3D l2hdr_len - sizeof(proto); =20 copied =3D iov_to_buf(l2hdr_iov, iovcnt, proto_offset, &proto, sizeof(proto)); --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202432; cv=none; d=zohomail.com; s=zohoarc; b=UfALpVcjk7GSgvbj8T4Lbq7zx4HThMtIiQQ/ffhkKT14RdTVrOBY+NKZ8kf3o5gwkF36HjehgBOqAo6IDR00DlHTEU6sTBs7L3uMjDXJ3GNqNfhGNtGGeF7vzsV2y3ueYu+4grA2ApESGQ7pq0QG0RTZlMrX+yfH0W0WTNb7Aq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202432; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2wrjUJxpcL5RJmg7LEMDArIoydrX9dZrKNP7QWTBW7I=; b=EvgIrk3ja5VOtQTdgiSpaOVLi4Hh45FtBnkqO58Qm8UxD7R5EPK7rgnuUIWaHQ/yOEmQrxGkZZFR5QXmcuUIDScLXQ+O2EFmrGV/Ao+E9lIs4TVBBKdt2sjLkS+RMuJ+wqA0vv4HL1fiPLBpcTXr/MZgO9/dL1rX7OGZeAFoj1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202432202674.8120426219066; Sun, 8 Nov 2026 21:33:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzU-0006zj-7Z; Mon, 09 Nov 2026 00:32:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz9-0006u7-6m; Mon, 09 Nov 2026 00:32:13 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHz4-0006HW-OM; Mon, 09 Nov 2026 00:32:02 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtY046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:36 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=2wrjUJxpcL5RJmg7LEMDArIoydrX9dZrKNP7QWTBW7I=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202296; v=1; b=VWCosyifjhwSuPLLXK7eeQ3uaxmKJ8/XwKKeRFhuHvNfTj3Y+03CXmDF0eN/4W/v yTHCTaY18aTLOofnPaaDY6/VN1lujV9Ic8V8YomxiLtR4kygBF0PswVtNKUlel+x q8CdFm6rJXR8h0mpWKymcbFzXSDIXoyazl6sSs1iG9c+6FOFWyNzTv/dCcr71zgu qCQ0fwede6hNMWB2fbSPyqSxLKfYybSqwVpGaAamYQGqOJMOPqBZDKkEUWn1Ypb1 NLNCz5d7r7pepsmYQMRx1quivG1NV7+uW3V4ffwMhZjBs6aZ8gfOlXKBv9GbE+ln 4LT2J4qdwLMYENCuOF6O/g== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:55 +0900 Subject: [PATCH v2 10/14] include/net/eth.h: Make eth_get_l2_hdr_length_iov() check protocol MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-10-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1531; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=NgOMJSmhGYwbcbhB2p9VTHAfuFHKWgyTeaf3LVJWJm4=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqGVyFptPr/6xVCp/1bZY3fPXnEJuFN32u/Lf4+yGJ M8CI8cZHaUsDGJcDLJiiiwpRbu5NaJrPxUmxLfAzGFlAhnCwMUpABN5n8zwT2fKs/wNd6piso6v 4JZdJp0cdH+uulbVpJmGx3zE+Z9EXmL4p3xO2Wy/MyvvfdMz5YxL7CaurPjndTz9zv2ZUZxp96X 3swMA X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202433717158500 From: Peter Maydell In eth_get_l2_hdr_length() we return sizeof(eth_header) for any protocol other than VLAN or DVLAN. However, in the iov version of this function, if the packet is larger than the ethernet header but not large enough for both the eth_header and the vlan_header we'll end up returning the actual packet size rather than the eth_header size. Fix the "not enough data" return case. This will only cause issues if the caller isn't already checking offsets and sizes, so this is defence-in-depth. It also in theory corrects the result for the hypothetical case of an ethernet-level protocol that allows a payload of less than 4 bytes. Cc: qemu-stable@nongnu.org Fixes: eb700029c783 ("net_pkt: Extend packet abstraction as required by e10= 00e functionality") Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- include/net/eth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/eth.h b/include/net/eth.h index e10684ed9234..3e83f5d68c03 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -321,7 +321,7 @@ eth_get_l2_hdr_length_iov(const struct iovec *iov, size= _t iovcnt, size_t iovoff) size_t copied =3D iov_to_buf(iov, iovcnt, iovoff, p, ARRAY_SIZE(p)); =20 if (copied < ARRAY_SIZE(p)) { - return copied; + return MIN(copied, sizeof(struct eth_header)); } =20 return eth_get_l2_hdr_length(p); --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202483; cv=none; d=zohomail.com; s=zohoarc; b=DWjs2FCgkS7kMv6kbEifnND80x2I5JNlyhY4m46u+NbHASoPgSyANX4TbUYVhOCiCS1Q1rG/iYiajEKu70ZlzilxV1kj+JloOhHrNjMki9XfpLtEFFWgdYxnf0CYwwFSEF4nJRixUoQQZHhxWww/WoZ3LFqQAnj4fXOFtLKuPN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202483; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZKb5PN6RhPS1l3+YDe3BEoCbM5fz7xEF9hZR8A16oZ8=; b=CVIAUNQiVTSAkia1mkJ87+HnQ7wazVwKTuCfflPngXs8CESNL17uXZVHXNXrjsbCBWwl4S7zvpYGQof3w5K8xdtlPtDcQQ+6gFfU8tCp3jj///+HjUZofmXPUgUwA/QcUFaJZa540RvrvdgjXpq0ooYwP86W+xCKv7ehKTEQA0I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202483017668.7093247846041; Sun, 8 Nov 2026 21:34:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzf-00075B-80; Mon, 09 Nov 2026 00:32:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzK-0006uk-UJ; Mon, 09 Nov 2026 00:32:16 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzG-0006HY-IO; Mon, 09 Nov 2026 00:32:14 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtZ046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:36 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=ZKb5PN6RhPS1l3+YDe3BEoCbM5fz7xEF9hZR8A16oZ8=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202296; v=1; b=MhIAChjTBa8oIaC/YpLR7Ldv7CUnkEY8ZSe6EPmO6mrWX1BJKLPa4NnKGucM22F7 gwsPOzfVe6sxG0/5X7ticnGoB6vvrp9xNgiEpy4IHAo+fTq6gLmGR4iBuSo/sn0x Al2FbtF+QrXjGh/BNJDlifE0rIU9BQYwMuJzT3KMFH5NtyhrjruieUdgqzynxYRH NkScjP7j12QZJLSnIYLWEyJYtKjv+wMgYWirHafhxjlxdfFh3rBIj1ifiW4PJfsQ Wboyz9iDnIKw/7dm0nnXw/3vca+OdPT317H/mYusAXT9u+QlottYgfc2qYcpIqWp KSuaHXLHyAwmJ2yOF/5f6Q== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:56 +0900 Subject: [PATCH v2 11/14] hw/net/net_tx_pkt: Sanity check GSO headers in net_tx_pkt_build_vheader() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-11-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2886; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=aw/3ouOQZLGh3jgpEqT+G3NA5+gdqPYnnaYVqZGfkGw=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqGX6jenan2yYfvnnhhhdq95hlXta4d+yS2bH+Yut/ xXwr+DpKGVhEONikBVTZEkp2s2tEV37qTAhvgVmDisTyBAGLk4BmMi8dIa/EqlmvtaLjzuXtq+L lnoaKFW6jld9z2VPKU8jHbdHy597M/z31st9Ws2/Rtutd/9z20U/vqkwuvGZ20W6aDWsK7y/XYc PAA== X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202484470158500 From: Peter Maydell In net_tx_pkt_build_vheader(), we are insufficiently cautious about headers from the packet from the guest. Add more checking: * that the segment offload payload gso_size isn't 0 * that the packet is not too small * that the TCP th_off is inside the payload * that we aren't going to overflow in our header length calculation Of these, the most significant extra check is in calculation of the virt_hdr length. We calculate this with pkt->virt_hdr.hdr_len =3D pkt->hdr_len + l4hdr.th_off * sizeof(uint32_t); The struct field is 16 bits, and so this can overflow if the guest hands us a packet of close to 64K in size and an appropriate l4hdr.th_off. The effect is that we record a bogus virt_hdr.hdr_len, and later on in net_tx_pkt_tcp_fragment_init() this will cause us to make a very large allocation that causes g_malloc() to abort. This is a hardening issue rather than a security issue, because the amount of guest control over the allocation size is such that it can only generate allocations very close to SIZE_MAX which always make g_malloc() abort, and so it's a guest self-denial-of-service only. Cc: qemu-stable@nongnu.org Fixes: e263cd49c73c595 ("Packet abstraction for VMWARE network devices") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3648 Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- hw/net/net_tx_pkt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index b134348fe809..b2935900fe7f 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -335,6 +335,11 @@ bool net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bo= ol tso_enable, break; =20 case VIRTIO_NET_HDR_GSO_UDP: + if (IP_FRAG_ALIGN_SIZE(gso_size) =3D=3D 0 || + pkt->payload_len < sizeof(struct udp_header) || + pkt->hdr_len + sizeof(struct udp_header) > UINT16_MAX) { + return false; + } pkt->virt_hdr.gso_size =3D gso_size; pkt->virt_hdr.hdr_len =3D pkt->hdr_len + sizeof(struct udp_header); break; @@ -344,7 +349,10 @@ bool net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bo= ol tso_enable, bytes_read =3D iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags, 0, &l4hdr, sizeof(l4hd= r)); if (bytes_read < sizeof(l4hdr) || - l4hdr.th_off * sizeof(uint32_t) < sizeof(l4hdr)) { + gso_size =3D=3D 0 || + l4hdr.th_off * sizeof(uint32_t) < sizeof(l4hdr) || + l4hdr.th_off * sizeof(uint32_t) > pkt->payload_len || + pkt->hdr_len + l4hdr.th_off * sizeof(uint32_t) > UINT16_MAX) { return false; } =20 --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202464; cv=none; d=zohomail.com; s=zohoarc; b=Tg0TC9AxaVdxxUqRFxg23xhQRhLqApTmBcibhD88TIL2lYc68Fxna5qS7HOvadbD4S3/owh3jd0hdrKKOFCqFmFIzZ/8yLqdBVDDynVWUf2fiSQrzUNnZDCnjSyNFuAD8tpbdkzp2t/bvv0lrjIU3AIHJVgDc9K1GR0bC9xgRww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202464; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4csluYBe25LxuCIDQT3Str+SAhEBk6uukTzsRZyTsaE=; b=kaGmkSS6C6rvGthaFPwUuXP3k1+hsj+eDYYJgbHhJ9EC+j1VzuwUYnrwYIeoS5nvxAbo7Lxa/yI4px6uC8iSnCRcH3nZiIY9McR/pD1K6ynAI5y4rlxn437WSEJshoXC+2iE4XKE0hSoRLEz+4zuEla9k2aW1csWfvz7Szxv9es= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202463979274.5671048948832; Sun, 8 Nov 2026 21:34:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHze-00074V-Ef; Mon, 09 Nov 2026 00:32:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzK-0006uf-JD; Mon, 09 Nov 2026 00:32:15 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzG-0006HV-I8; Mon, 09 Nov 2026 00:32:13 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLta046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:36 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=4csluYBe25LxuCIDQT3Str+SAhEBk6uukTzsRZyTsaE=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202296; v=1; b=Z60E0rRb+IUzmw2H+VDfungn3Ec6YcxvswHdu5tVqnYRD36NJ/BGh9eDBNYv2ugA Tpm+HoYz3rctjuiZEQUIciO4i7qikQ+3S985m6M/rInw0+jRSLfpRNWxO8kjwo4R 6P4sxsopzWGciJNpif08LUe9VEzFsJatssKP8n6+kVDH/KZx2QZeQSY7r0eNYQsw NoFWFaoESm3Ztmce2EVHLM54oSHWwTGAjfiogSaKX+8pcVIkZ8mzRUXUkwTtXaXj U6uMq2VHrd+bH7hCQnk6wFEqUy8lM1uXBXr6v5b5XCFMXeWmqgvj8mdlWVTGcIAG r9HE6zFs9CIB+ReYwQGLTg== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:57 +0900 Subject: [PATCH v2 12/14] hw/net/net_tx_pkt: Sanity check virt hdr len in net_tx_tcp_fragment_init MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-12-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1427; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=eIT70pmjipb26muzAUE6SmrBPX8sPqDAYTmow90qy2Y=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqOXn9qZw9yWzfJM6nm90/7rn/lyfBRI/VzYF/7gnv iGyJCeso5SFQYyLQVZMkSWlaDe3RnTtp8KE+BaYOaxMIEMYuDgFYCKbLRgZVmxVqS7W6v5+y8yO 5Rfv+p0WJQ+VrmXsjRWbNadrSfj/3wz/40rWemYaxYs12n3aU7d+i9LlLTe6VVtV5m1I4k4ROHC CEQA= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202466190158500 From: Peter Maydell In net_tx_pkt_tcp_fragment_init() we calculate the l4 header size by subtracting the packet's virt_hdr.hdr_len from its overall length, and then we g_malloc() that many bytes. This shouldn't underflow if the caller has been sanity checking sizes and offsets, but as defence-in-depth, check again here before relying on it for the malloc size. This change would suffice to avoid the guest self-denial-of-service via overflowing the virt_hdr.hdr_len calculation in net_tx_pkt_tcp_fragment_init() which we fixed in the preceding commit. Cc: qemu-stable@nongnu.org Fixes: 02ef5fdc092bd4 ("hw/net/net_tx_pkt: Implement TCP segmentation") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3648 Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- hw/net/net_tx_pkt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index b2935900fe7f..dc2563721e84 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -604,7 +604,7 @@ static bool net_tx_pkt_tcp_fragment_init(struct NetTxPk= t *pkt, size_t bytes_read =3D 0; struct tcp_hdr *th; =20 - if (!pkt->payload_frags) { + if (!pkt->payload_frags || pkt->virt_hdr.hdr_len <=3D pkt->hdr_len) { return false; } =20 --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202494; cv=none; d=zohomail.com; s=zohoarc; b=SeQEwvWwK782CmTBpbtI/lJsE8YBNxGvQCwmomUVahMGPTQsjWnzrdB11eGzlrYUDpfzKdtoqk5fCL5gdUTj2Gad0Cr4wIy8Kfu6hEScx1nj4aQ3Zku9dMR97Hx1Hf3W3IiwvL3ptOkDr75dxgMlm4s7+XLKlCBsX42LRm4z4yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202494; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J/catv4i+XykkaGfTRi16jYEyYVpACUaiqWRJZxJ5xQ=; b=J4xoD5ENJZuYNuoYWI9iDRM5U3dVtu3wzlaK4c7ugjtmPYakm9iam5DDiXGBuVcJAUll1y66YDV/PhkUbee/jdI2D7RfT3P3f4aEcPImUawcz8IXDg7JXb6wxfJVfKgvQCDgXtf57PKnGXJbf7NiwWP547laxQjnZeTXevYpgqA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202494141921.84798675052; Sun, 8 Nov 2026 21:34:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzX-00071i-Ap; Mon, 09 Nov 2026 00:32:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzK-0006ug-Jj; Mon, 09 Nov 2026 00:32:15 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzG-0006Hb-JF; Mon, 09 Nov 2026 00:32:13 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtb046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:36 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=J/catv4i+XykkaGfTRi16jYEyYVpACUaiqWRJZxJ5xQ=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202296; v=1; b=KsGM6u9G6YxIKjB94kYqgUMX3IjIPMVBk1TMmPLcTMfQAR5aT8NHDl4Am3dr5pg/ 3J/tNT7I1bfqJFymV3w7prkY+xcpBuyhs9v1AiQaGEEa2XrQ+KUpb2RASIVKISGu HZH4v8Moqatxbenj3+AeKd7A/6AzcQBKuLnx/KerZuf7rhDqyot5c51qKRgf5ldi JjEmei1DcE7/M/1s+xJJyiL4E6JE7QwBHxibHSmgzviq06uxJuD1AXonorkE8zfV fv3qghJtV1WBtbHNsd9NT7l05spsYY/1LMagN5FBdL2HFpGls7bj2LQ7Nn60lp2Y mDJpDNT8udPGRHdAyIzUuA== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:58 +0900 Subject: [PATCH v2 13/14] hw/net/net_tx_pkt: Sanity check L2+L3 header len in net_tx_pkt_parse_headers() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-13-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1248; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=CfOoWANB/lfJxIKzoDtjEy92SfgWDreJBU7vQu4HMjI=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqOWTXAveP57nnzJt5ucX267cOLjK3MOv/rXyjqtCH DMsD/Tu6ShlYRDjYpAVU2RJKdrNrRFd+6kwIb4FZg4rE8gQBi5OAZjIRleGf6pJ1ecPJQZsb8uL ztFf/ZrPS3jzVue8qb/0XKO7f5T/qWVkOPGQLXaj7O+pU5IU/rEs81NI5RZWF1nPe3Wlw4ZzkxP ncgEA X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202494590158500 From: Peter Maydell In net_tx_pkt_parse_headers() we examine the L2 and L3 headers one after the other. Add a sanity check that the two together don't exceed the packet length or the maximum IP packet size. This shouldn't happen if the L3 parsing was done right, but is worth doing for defence-in-depth. Cc: qemu-stable@nongnu.org Fixes: e263cd49c73c595 ("Packet abstraction for VMWARE network devices") Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- hw/net/net_tx_pkt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index dc2563721e84..c331628134e7 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -267,6 +267,14 @@ static bool net_tx_pkt_parse_headers(struct NetTxPkt *= pkt) break; } =20 + if (l2_hdr->iov_len + l3_hdr->iov_len > ETH_MAX_IP_DGRAM_LEN || + l2_hdr->iov_len + l3_hdr->iov_len > + iov_size(pkt->raw, pkt->raw_frags)) { + l2_hdr->iov_len =3D 0; + l3_hdr->iov_len =3D 0; + return false; + } + net_tx_pkt_calculate_hdr_len(pkt); return true; } --=20 2.56.0 From nobody Mon Nov 23 04:30:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1794202487; cv=none; d=zohomail.com; s=zohoarc; b=Qgx8w0+UtEGS5WDI7pxRM9bhuTYAr01lMn7S6bNMGsG3mlgT00s6j42wK+vYNPsC8Z8wg95/zU3IaH0oZAQswUlcAnlWkTvemjBgWxf183r85Dd529tL27LIWpnbm3EzaG5ie1N3LYxpWsJy20jqBPqsiHnnpB7Va+95slYcDK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794202487; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TfeHcxMmuRWst/+r/L4y9LOrxZi5hGJjWVr7etqScZg=; b=DBkwS/E33/S2MMXbtZmSFOP/0VyNBC5fYHKZrM6pL5YTs8cm8GEn+5rA3HMPmCZB8jhWGJfBRnDxWzGvu63Z1fkhEsQpSnOJi1fPVEOReeNCVN8ZVmaMqfM29dkfARKlpkVItutAACPpC2Mf4QpI8ebACoD/oQK8x76JNhk05Fk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794202486160516.4781754589029; Sun, 8 Nov 2026 21:34:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQHzT-0006zJ-Aw; Mon, 09 Nov 2026 00:32:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzK-0006uj-R0; Mon, 09 Nov 2026 00:32:15 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQHzG-0006HZ-JY; Mon, 09 Nov 2026 00:32:14 -0500 Received: from [10.42.0.1] (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6A95VLtc046789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Nov 2026 14:31:36 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=TfeHcxMmuRWst/+r/L4y9LOrxZi5hGJjWVr7etqScZg=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1794202296; v=1; b=NSMVufPsNTxHsT1E/cSU2Uoq04vlx3tW3Yo1zCBCmbYxUxiRK4VDwPOJBCIhIaal 4NbWOR3NVvgTVV76A4tCj0/hnKDzcmjr+YQwswYs/fQ858aHhQbXuEJ5zRI0ItZ0 2Gt7cAmzax1rFzdCuj58B7cE5GJQd37bJBT2kvbdJ1+kHmvDAducO231Prj7Mcea U/sqQFCnWw+rYo5vpS+WmOtIv0bGM0FwnfoqqUw1yCL/S277IfW0eoh53hl9HqTZ d+7qFqwRniykD6RGdn9K8uHj29XxkNgurqLM8OfO7A4cEJe+bwju0LQl6LjzvddY +jkgsP+MS37rLHNc+ISKCA== From: Akihiko Odaki Date: Mon, 09 Nov 2026 14:23:59 +0900 Subject: [PATCH v2 14/14] hw/net/net_rx_pkt: Check for overflow in _net_rx_pkt_calc_l4_csum() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261109-eth-v2-14-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> References: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , David Matlack , Alex Williamson , Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2198; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=SZZFJ0R3Dcjqw4IXPkP9KLwVZexxnp0/tEl0bNvcPvo=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9bHqBXbfGc/XiXzZmVbT2+N5cngg/tZmU8dntzmoHSlL M3/P69MRykLgxgXg6yYIktK0W5ujejaT4UJ8S0wc1iZQIYwcHEKwERU7zIyvE2YVnbv/vM7DV/l eybtrT1ytpth/bZzU/mO6ZpmBRVM28rwP3ifTqaJ+IQpZTx7H9kYZMzg2/vvysnonntOlUdv5Lu kMgMA X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1794202490563158500 From: Peter Maydell In _net_rx_pkt_calc_l4_csum() we calculate the number of bytes to run the checksum over by subtracting the IP header length from the total IP packet size. This shouldn't underflow if other parts of the code have been correctly checking and calculating sizes and offsets, but for defence in depth check here, and don't checksum any bytes if we would otherwise underflow. Cc: qemu-stable@nongnu.org Fixes: eb700029c783 ("net_pkt: Extend packet abstraction as required by e10= 00e functionality") Signed-off-by: Peter Maydell Signed-off-by: Akihiko Odaki Reviewed-by: Akihiko Odaki --- hw/net/net_rx_pkt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index 03a35f03154d..110496e9c818 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -501,8 +501,10 @@ _net_rx_pkt_calc_l4_csum(struct NetRxPkt *pkt) csl =3D be16_to_cpu(pkt->l4hdr_info.hdr.udp.uh_ulen); trace_net_rx_pkt_l4_csum_calc_ip4_udp(); } else { - csl =3D be16_to_cpu(pkt->ip4hdr_info.ip4_hdr.ip_len) - - IP_HDR_GET_LEN(&pkt->ip4hdr_info.ip4_hdr); + uint16_t iplen =3D be16_to_cpu(pkt->ip4hdr_info.ip4_hdr.ip_len= ); + uint16_t iphdr_len =3D IP_HDR_GET_LEN(&pkt->ip4hdr_info.ip4_hd= r); + + csl =3D (iplen >=3D iphdr_len) ? (iplen - iphdr_len) : 0; trace_net_rx_pkt_l4_csum_calc_ip4_tcp(); } =20 @@ -517,9 +519,9 @@ _net_rx_pkt_calc_l4_csum(struct NetRxPkt *pkt) struct ip6_header *ip6hdr =3D &pkt->ip6hdr_info.ip6_hdr; size_t full_ip6hdr_len =3D pkt->l4hdr_off - pkt->l3hdr_off; size_t ip6opts_len =3D full_ip6hdr_len - sizeof(struct ip6_hea= der); + uint16_t plen =3D be16_to_cpu(ip6hdr->ip6_ctlun.ip6_un1.ip6_un= 1_plen); =20 - csl =3D be16_to_cpu(ip6hdr->ip6_ctlun.ip6_un1.ip6_un1_plen) - - ip6opts_len; + csl =3D (plen >=3D ip6opts_len) ? (plen - ip6opts_len) : 0; trace_net_rx_pkt_l4_csum_calc_ip6_tcp(); } =20 --=20 2.56.0